Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] JUnitAssertionsShouldIncludeMessage false positive with method call #2883

Closed
adangel opened this issue Oct 29, 2020 · 3 comments · Fixed by #2899
Closed

[java] JUnitAssertionsShouldIncludeMessage false positive with method call #2883

adangel opened this issue Oct 29, 2020 · 3 comments · Fixed by #2899
Labels
a:false-positive PMD flags a piece of code that is not problematic good first issue A great starting point for new contributors help-wanted
Milestone

Comments

@adangel
Copy link
Member

adangel commented Oct 29, 2020

Affects PMD Version: 6.30.0-SNAPSHOT

Rule: JUnitAssertionsShouldIncludeMessage

Description:

From #2871 (comment)

Code Sample demonstrating the issue:

https://chunk.io/pmd/fc7db65b2c6a46eca4c9a0c3012482e2/diff/spring-framework/index.html#A6120

import static org.junit.Assert.assertEquals;

public class AssertionMessageTest {
    public void bar(int expectedLength) {
        try {
            Integer.parseInt("a");
        } catch (RuntimeException e) {
            assertEquals(e.toString(), expectedLength, e.getMessage().length()); // no warning expected
        }
    }
}

Expected outcome:

  • Does PMD report a violation, where there shouldn't be one? -> false-positive

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

@adangel adangel added good first issue A great starting point for new contributors a:false-positive PMD flags a piece of code that is not problematic help-wanted labels Oct 29, 2020
@oowekyala
Copy link
Member

I'm pretty sure this is fixed in #2899

oowekyala added a commit to oowekyala/pmd that referenced this issue Nov 5, 2020
@oowekyala oowekyala linked a pull request Nov 10, 2020 that will close this issue
5 tasks
@oowekyala oowekyala removed a link to a pull request Nov 10, 2020
5 tasks
@oowekyala oowekyala added this to the 7.0.0 milestone Nov 10, 2020
@oowekyala oowekyala linked a pull request Nov 10, 2020 that will close this issue
5 tasks
@adangel
Copy link
Member Author

adangel commented Dec 11, 2020

Fixed via #2899 for PMD 7.

@adangel adangel closed this as completed Dec 11, 2020
@adangel
Copy link
Member Author

adangel commented Dec 11, 2020

Fixed via #2899 for PMD 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic good first issue A great starting point for new contributors help-wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants