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] GuardLogStatement false positive on return statements and Math.log #869

Closed
vanniktech opened this Issue Jan 21, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@vanniktech
Contributor

vanniktech commented Jan 21, 2018

Affects PMD Version:

6.0.1 (did not happen with 6.0.0)

Rule:

GuardLogStatement

Description:

The code below gets flagged although it should not since I'm not using any exception.

Code Sample demonstrating the issue:

return Single.error(new IllegalStateException("No permission was pre-configured for " + permission));

You can also check out this PR - vanniktech/RxPermission#21 - which fails

Report

<?xml version="1.0" encoding="UTF-8"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd"
    version="6.0.1" timestamp="2018-01-21T19:15:40.307">
<file name="/Users/nik/tmp/RxPermission/library/src/main/java/com/vanniktech/rxpermission/MockRxPermission.java">
<violation beginline="32" endline="32" begincolumn="12" endcolumn="104" rule="GuardLogStatement" ruleset="Best Practices" package="com.vanniktech.rxpermission" class="MockRxPermission" method="request" externalInfoUrl="https://pmd.github.io/pmd-6.0.1/pmd_rules_java_bestpractices.html#guardlogstatement" priority="2">
There is log block not surrounded by if
</violation>
</file>
</pmd>

Running PMD through: [Gradle]

@jsotuyod

This comment has been minimized.

Member

jsotuyod commented Jan 21, 2018

Interesting... seems like #806 fixed #783 but introduced this...

@jsotuyod jsotuyod added this to the 6.1.0 milestone Jan 21, 2018

@ben-manes

This comment has been minimized.

ben-manes commented Jan 25, 2018

I got a false positive with Math.log...

this.depth = (int) Math.ceil(-Math.log(1 - confidence) / Math.log(2));

@adangel adangel modified the milestones: 6.1.0, 6.2.0 Feb 25, 2018

@adangel adangel modified the milestones: 6.2.0, 6.3.0 Mar 26, 2018

@adangel adangel modified the milestones: 6.3.0, 6.4.0 Apr 28, 2018

@jsotuyod jsotuyod modified the milestones: 6.4.0, 6.5.0 May 29, 2018

@adangel adangel self-assigned this May 31, 2018

@adangel adangel changed the title from [java] GuardLogStatement false positive when using an exception to [java] GuardLogStatement false positive on return statements and Math.log May 31, 2018

adangel added a commit to adangel/pmd that referenced this issue May 31, 2018

adangel added a commit to adangel/pmd that referenced this issue May 31, 2018

@adangel adangel added the has:pr label May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment