-
Notifications
You must be signed in to change notification settings - Fork 146
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
Issue #598: Forbid field access check implemented #813
base: master
Are you sure you want to change the base?
Conversation
b34f0b6
to
4fc30e4
Compare
4fc30e4
to
76c9cd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A rebase is needed.
https://travis-ci.org/github/sevntu-checkstyle/sevntu.checkstyle/jobs/675051592#L751
To be able to merge this new check, violations in main repository need to be fixed.
return new int[] { | ||
TokenTypes.STATIC_IMPORT, | ||
TokenTypes.IMPORT, | ||
TokenTypes.IDENT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to view PACKAGE_DEF as the class being looked for can be in the same package.
/** | ||
* Whether the field class was imported. | ||
*/ | ||
private boolean wasPackageImported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need a beginTree method to reset this variable on each new file.
import static java.util.Locale.ROOT; | ||
import static java.lang.Integer.MAX_VALUE; | ||
|
||
public class InputForbidFieldAccessCheckStaticTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input files should not end with Test
. It will confuse people with actual tests.
import java.util.Locale; | ||
import java.lang.Integer; | ||
|
||
public class InputForbidFieldAccessCheckTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
public class InputForbidFieldAccessCheckStaticTest { | ||
|
||
public static void setLocaleToRoot() { | ||
LocalizedMessage.setLocale(ROOT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example has to be added in another file when using the fully qualified class name and no import. It should not conflict with any similar named classes in the file.
@yaziza ping |
#598