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] AvoidFieldNameMatchingTypeName: False negative with interfaces by adangel · Pull Request #3249 · pmd/pmd

Conversation

@adangel

@adangel adangel commented May 4, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Fields in interfaces and nested classes have not been considered, e.g.

interface Operation {
    Object apply();

    final Operation OPERATION = () -> { return null; };  // Violation expected here

    class Inner {
        int inner; // Violation expected here
    }
}

This was originally found by #2687 in https://github.com/checkstyle/checkstyle/blob/checkstyle-8.10/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/finallocalvariable/InputFinalLocalVariableNameLambda.java#L31

It's fixed by using rulechain and skipping interfaces. The rule name just mentions "type name", in the rule description for AvoidFieldNameMatchingTypeName it says "class". But I don't see a reason, why to exclude interfaces here.

Note: This rule has not been converted on the pmd7 branch yet (#2701).

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.

All reactions
@adangel
[java] AvoidFieldNameMatchingTypeName fix FN with interfaces
7648b85
Fields in interfaces and nested classes have not been considered.
@adangel adangel added the a:false-negative PMD doesn't flag a problematic piece of code label May 4, 2021
@adangel adangel added this to the 6.35.0 milestone May 4, 2021
@adangel
[doc] Update release notes, rule doc for AvoidFieldNameMatchingTypeName
a8da3d5
- refs pmd#3249
@ghost

ghost commented May 4, 2021

Copy link
Copy Markdown
1 Message
📖 This changeset changes 0 violations,
introduces 106 new violations, 15 new errors and 0 new configuration errors,
removes 241 violations, 0 errors and 2 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.

@adangel

adangel commented May 6, 2021

Copy link
Copy Markdown
Member Author

There are some errors: https://chunk.io/pmd/0263b81c16b8417b993b6ea93f55d7be/diff/spring-framework/index.html#section-errors - I'll look into these (probably unrelated to this PR).

All reactions

Sorry, something went wrong.

Uh oh!

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

@adangel
adangel marked this pull request as ready for review May 6, 2021 13:54
oowekyala
oowekyala approved these changes May 14, 2021
View reviewed changes
@oowekyala oowekyala self-assigned this May 14, 2021
@oowekyala
oowekyala merged commit 53e4515 into pmd:master May 14, 2021
@adangel
adangel deleted the avoidfieldnamematichingtypename-rulechain branch May 14, 2021 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@oowekyala oowekyala oowekyala approved these changes

Uh oh!

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

Assignees

@oowekyala oowekyala

Labels

a:false-negative PMD doesn't flag a problematic piece of code

Projects

None yet

Milestone

6.35.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@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.