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

Issue #598: Forbid field access check implemented #813

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yaziza
Copy link
Member

@yaziza yaziza commented Apr 14, 2020

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 96.346% when pulling 76c9cd6 on yaziza:598-forbid-field-access into bd5ca6b on sevntu-checkstyle:master.

Copy link
Contributor

@rnveach rnveach left a 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,
Copy link
Contributor

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;
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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);
Copy link
Contributor

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.

@rnveach
Copy link
Contributor

rnveach commented Oct 10, 2022

@yaziza ping
Do you plan to continue this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants