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

fixed RequireThisCheck and enum constants handling #5361

Merged
merged 1 commit into from Dec 15, 2017

Conversation

Projects
None yet
3 participants
@rnveach
Member

rnveach commented Dec 15, 2017

Identified at #5307 (comment)

Enumerations don't see enumeration constants at all.

Easy printout of frame tree with this changes: rnveach@b584070#diff-6b1f89f1bde0470d4bd42580d1aa8bfb
Regression: http://rveach.no-ip.org/checkstyle/regression/reports/143/

Regression was done in parallel with #5351 and it only showed regression for the other PR, so there is no regression with this PR.
Most likely it is because users don't write non-static variables in this casing.

The following shows the issue without the enum constants using the input file with the released CS version:

$ cat TestClass.java
package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;

public class InputRequireThisEnumConstant {
    private final String TEST = "";
    
    public enum TestEnum {
        TEST;

        public TestEnum method() {
            return TEST;
        }
    }
}


$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="RequireThisCheck">
<property name="validateOnlyOverlapping" value="false" />
</module>
    </module>
</module>

$ java -jar checkstyle-8.5-all.jar -c TestConfig.xml TestClass.java
Starting audit...
[ERROR] TestClass.java:10:20: Reference to instance variable 'TEST' needs "InputRequireThisEnumConstant.this.". [RequireThis]
Audit done.
Checkstyle ends with 1 errors.

TEST can't be this because we are referencing the enum's constant and not the class' field.

@rnveach rnveach requested a review from romani Dec 15, 2017

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Dec 15, 2017

Codecov Report

Merging #5361 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #5361   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         296     296           
  Lines       16199   16202    +3     
  Branches     3699    3699           
======================================
+ Hits        16199   16202    +3
Impacted Files Coverage Δ
...ols/checkstyle/checks/coding/RequireThisCheck.java 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62d4be2...7cc9e4d. Read the comment docs.

codecov-io commented Dec 15, 2017

Codecov Report

Merging #5361 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #5361   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         296     296           
  Lines       16199   16202    +3     
  Branches     3699    3699           
======================================
+ Hits        16199   16202    +3
Impacted Files Coverage Δ
...ols/checkstyle/checks/coding/RequireThisCheck.java 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62d4be2...7cc9e4d. Read the comment docs.

@romani romani merged commit e702daf into checkstyle:master Dec 15, 2017

9 checks passed

Codacy/PR Quality Review Good work! A positive pull request.
Details
IDEA Inspections Pull Request (Checkstyle) TeamCity build finished
Details
Shippable Run 5778 status is SUCCESS.
Details
codecov/patch 100% of diff hit (target 100%)
Details
codecov/project 100% (+0%) compared to 62d4be2
Details
continuous-integration/Distelli
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
wercker/build Wercker pipeline passed
Details

@romani romani changed the title from Pull #5361: fixed RequireThisCheck and enum constants handling to fixed RequireThisCheck and enum constants handling Dec 15, 2017

@romani romani added this to the 8.6 milestone Dec 15, 2017

@rnveach rnveach deleted the rnveach:pr_5307_2 branch Dec 15, 2017

timurt added a commit to timurt/checkstyle that referenced this pull request Dec 19, 2017

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