GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] New Rule: MutableStaticState by vszholobov · Pull Request #3246 · pmd/pmd

Conversation

@vszholobov

@vszholobov vszholobov commented Apr 30, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Describe the PR

(My first PR against PMD. Hello World!)

Added new rule: Visible static fields must be made constants (or immutable references) by declaring them final.

Related issues

  • Fixes [java] New Rule: Public and protected static fields must be final #2987

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adangel reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Vsevolod
#2987 New Rule: Public and protected static fields must be final
fdb1420
@vszholobov vszholobov changed the title New Rule: Public and protected static fields must be final [java] New Rule: Public and protected static fields must be final Apr 30, 2021
@oowekyala oowekyala added the a:new-rule Proposal to add a new built-in rule label May 4, 2021
@ghost

ghost commented May 4, 2021 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
1 Message
📖 This changeset changes 0 violations,
introduces 286 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
✅ This changeset changes 0 violations,
introduces 286 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
✅ This changeset changes 0 violations,
introduces 2548 new violations, 15 new errors and 0 new configuration errors,
removes 1877 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

oowekyala
oowekyala reviewed May 6, 2021
View reviewed changes

@oowekyala oowekyala left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome and thanks for your contribution! I have a couple of suggestions, please take a look when you can.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/StaticFieldMustBeFinal.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/security.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/resources/category/java/security.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

adangel
adangel reviewed May 8, 2021
View reviewed changes
Comment thread pmd-java/src/main/resources/category/java/security.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Vsevolod
Rename StaticFieldMustBeFinal rule to MutableStaticState
dfcf0d0
Move MutableStaticState from security to design.

Change description to clarify what "visible field" is.

Change "since" attribute from 6.34.0 to 6.35.0.

Add AssignmentToNonFinalStatic rule reference.
@vszholobov vszholobov changed the title [java] New Rule: Public and protected static fields must be final [java] New Rule: MutableStaticState May 11, 2021
adangel
adangel reviewed May 13, 2021
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, please have a look at my comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-java/src/main/resources/category/java/design.xml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/MutableStaticState.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Vsevolod
Rename MutableStaticState class to MutableStaticStateTest
01b572c
Change description to make it more soft and add reasoning why
the non-private static non-final fields should be made
constants or immutable references.
@adangel adangel added this to the 6.35.0 milestone May 18, 2021
adangel
adangel approved these changes May 18, 2021
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me!
Now the rule tests are also executed:

2021-05-18T18:00:27.2691443Z [INFO] Running net.sourceforge.pmd.lang.java.rule.design.MutableStaticStateTest
2021-05-18T18:00:27.2982628Z [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in net.sourceforge.pmd.lang.java.rule.design.MutableStaticStateTest

(https://github.com/pmd/pmd/runs/2613100760#step:7:3100)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@adangel adangel self-assigned this May 24, 2021
adangel added a commit that referenced this pull request May 25, 2021
@adangel
[doc] Update release notes (#2987, #3246)
e0be13a
adangel added a commit that referenced this pull request May 25, 2021
@adangel
Merge pull request #3246 from vszholobov:visibleStaticFieldsMustBeFinal
a8f5a71
[java] New Rule: MutableStaticState #3246
@adangel
adangel merged commit da36bb3 into pmd:master May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@oowekyala oowekyala oowekyala left review comments
@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adangel adangel

Labels

a:new-rule Proposal to add a new built-in rule

Projects

None yet

Milestone

6.35.0

Development

Successfully merging this pull request may close these issues.

[java] New Rule: Public and protected static fields must be final

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vszholobov @adangel @oowekyala
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.