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] OnlyOneReturn: false negative with anonymous class by adangel · Pull Request #3274 · pmd/pmd

Conversation

@adangel

@adangel adangel commented May 13, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Converts the rule OnlyOneReturn to use rulechain. Now all method
declarations are visited regardless where they are
nested.

This FN has been found via #2687.

Example code:

public class OnlyOneReturn {
    void foo() {
        Object o = new Object() {
            void method(int i) {
                switch (i) {
                    case 1: return;  // missing violation
                    case 2: return; // missing violation
                }
                return;
            }
        };
    }
}

Note: this rule has already been converted in pmd7

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 adangel added the a:false-negative PMD doesn't flag a problematic piece of code label May 13, 2021
@adangel adangel added this to the 6.35.0 milestone May 13, 2021
@adangel adangel changed the title [java] OnlyOneReturn: False negative with anonymous class [java] OnlyOneReturn: false negative with anonymous class May 13, 2021
@adangel
[java] OnlyOneReturn - fix FN with anonymous class
ebdbec7
Converts this rule to use rulechain. Now all method
declarations are visited regardless where they are
nested.

This FN has been found via pmd#2687.
@adangel
adangel force-pushed the OnlyOneReturn-fp branch from dc7750f to ebdbec7 Compare May 13, 2021 17:02
adangel
adangel commented May 13, 2021
View reviewed changes
Comment thread pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/OnlyOneReturn.xml Resolved

Uh oh!

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

@ghost

ghost commented May 13, 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 62 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 2 errors and 2 configuration errors.
Full report
✅ This changeset changes 0 violations,
introduces 62 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 2 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
Update pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule…
00418c1
…/codestyle/xml/OnlyOneReturn.xml
@oowekyala

oowekyala commented May 14, 2021

Copy link
Copy Markdown
Member

It would be nice eventually to make this rule report violations only once per method, like what you did with #3255. I'll make a ticket for that

adangel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@oowekyala oowekyala self-assigned this May 14, 2021
@oowekyala
oowekyala merged commit 53bba78 into pmd:master May 14, 2021
@adangel
adangel deleted the OnlyOneReturn-fp branch May 14, 2021 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.