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] ControlStatementBraces is missing checkIfStmt property #1004

Closed
huxi opened this issue Mar 26, 2018 · 1 comment
Closed

[java] ControlStatementBraces is missing checkIfStmt property #1004

huxi opened this issue Mar 26, 2018 · 1 comment
Assignees
Labels
an:enhancement An improvement on existing features / rules good first issue A great starting point for new contributors
Milestone

Comments

@huxi
Copy link

huxi commented Mar 26, 2018

Affects PMD Version:
6.2.0

Rule:
category/java/codestyle.xml/ControlStatementBraces

Description:
ControlStatementBraces is supposed to replace IfStmtMustUseBraces and IfElseStmtMustUseBraces but it only has a checkIfElseStmt property, not a checkIfStmt property.

We currently exclude IfStmtsMustUseBraces in our configurations, but not IfElseStmtMustUseBraces. The rationale for this is to allow logging guards like the one in the example code below.

The only way to allow those with the ControlStatementBraces rule is by setting checkIfElseStmt to false. This disables more checks than with the previous rules.

Code Sample demonstrating the issue:

if(logger.isDebugEnabled()) logger.debug("{}", foo);

Running PMD through: Gradle

@oowekyala
Copy link
Member

Hi, thanks for the report! That's definitely an oversight, we'll add a new property to cover your use case.

@oowekyala oowekyala added the good first issue A great starting point for new contributors label Mar 26, 2018
@jsotuyod jsotuyod added the an:enhancement An improvement on existing features / rules label Apr 7, 2018
@jsotuyod jsotuyod added this to the 6.3.0 milestone Apr 7, 2018
@jsotuyod jsotuyod added good first issue A great starting point for new contributors and removed good first issue A great starting point for new contributors labels Apr 7, 2018
@oowekyala oowekyala self-assigned this Apr 27, 2018
oowekyala added a commit to oowekyala/pmd that referenced this issue Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an:enhancement An improvement on existing features / rules good first issue A great starting point for new contributors
Projects
None yet
Development

No branches or pull requests

3 participants