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] LinguisticNaming should support AtomicBooleans #1334

Closed
SamCarlberg opened this Issue Sep 7, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@SamCarlberg

SamCarlberg commented Sep 7, 2018

Affects PMD Version:
6.7.0

Rule:
LinguisticNaming

Description:
Fields of type AtomicBoolean are prohibited from following the naming patterns isX, shouldX, hasX, etc., e.g. isFlagSet. In my view, AtomicBooleans are simply threadsafe wrappers around boolean values and are therefore perfectly valid to have a boolean-style name prefix.

Code Sample demonstrating the issue:

All of the following fields will trigger the rule:

private final AtomicBoolean isX = new AtomicBoolean(true);
private final AtomicBoolean hasX = new AtomicBoolean(true);
private final AtomicBoolean canX = new AtomicBoolean(true);
private final AtomicBoolean haveX = new AtomicBoolean(true);
private final AtomicBoolean willX = new AtomicBoolean(true);
private final AtomicBoolean shouldX = new AtomicBoolean(true);

Running PMD through: Gradle

@SamCarlberg SamCarlberg changed the title from [java] Should LinguisticNaming allow AtomicBooleans to be prefixed with "is"? to [java] Should LinguisticNaming allow AtomicBooleans to use boolean name prefixes? Sep 7, 2018

@jsotuyod jsotuyod added this to the 6.8.0 milestone Sep 7, 2018

@jsotuyod

This comment has been minimized.

Member

jsotuyod commented Sep 7, 2018

@SamCarlberg sounds very reasonable, thanks for the feedback

@adangel

This comment has been minimized.

Member

adangel commented Sep 7, 2018

👍 Yes, that absolutely makes sense. We should treat AtomicBoolean the same way as boolean for this rule.

@adangel adangel self-assigned this Sep 7, 2018

@adangel adangel changed the title from [java] Should LinguisticNaming allow AtomicBooleans to use boolean name prefixes? to [java] LinguisticNaming should support AtomicBooleans Sep 7, 2018

adangel added a commit to adangel/pmd that referenced this issue Sep 7, 2018

@adangel adangel added the has:pr label Sep 7, 2018

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