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

Resolve Pitest Issues - IllegalImportCheck (1) #7854

Closed
rnveach opened this issue Mar 15, 2020 · 5 comments
Closed

Resolve Pitest Issues - IllegalImportCheck (1) #7854

rnveach opened this issue Mar 15, 2020 · 5 comments

Comments

@rnveach
Copy link
Member

rnveach commented Mar 15, 2020

Child issue of #7797 ,

"IllegalImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (regexp) {</span></pre></td></tr>"

@akki111singh
Copy link
Contributor

Hey ! Have you started worked on this isuue! if not can you please do the other one Resolve Pitest Issues - IllegalImportCheck (3) beacause by mistake i worked on this and solved it

@akki111singh
Copy link
Contributor

akki111singh commented Mar 21, 2020

1.Pitest Report

2.Mutated Branch

  • Hardcoded Mutated commit: 981403f
  • Since the mutation was removed conditional - replaced equality check with true → SURVIVEDso therefore the if-else statement was removed to set the execution of all the statements to always true.

3. Regression Report

  • Regression Report: https://akki111singh.github.io/diff/index.html

  • Modules used in the config file:

     <module name="IllegalImport">
        <property name="regexp" value="true"/>
        <property name="illegalPkgs" value="java\.util"/>
      </module>
      
      <module name="IllegalImport">
        <property name="illegalPkgs" value="java.io, java.sql"/>
      </module>	        
    

4. Regression and code Logic

Although there is no diff found in Regression diff report, I find that the reason why the surviving mutation exists is maybe due to the reason as follows:
When we specify packages or classes to reject, if regexp property is not set, checks if import is the part of package or classes. If regexp property is set, then list of packages or classes will be interpreted as regular expressions and all properties for the match will be used.

If we keep the regexp value always set then it will anyway matches the classes or packages names. So therefore this is the cause of mutation as keeping the regex value always true works as regex will matches the whole package or class name.

Although i figured out a test case :

<property name="illegalClasses" value="java.io.*"/>

Keeping the regex true value here will match all the imports beginning
java.io else it will only match java.io.*,

Adding the above test-case Killed the mutation

Pitest-report : https://akki111singh.github.io/pit-reports2/202003202255/com.puppycrawl.tools.checkstyle.checks.imports/IllegalImportCheck.java.html

on line 440 : 3. removed conditional - replaced equality check with true → SURVIVED -> The mutation is killed

@akki111singh
Copy link
Contributor

@rnveach please review

akki111singh added a commit to akki111singh/checkstyle that referenced this issue Mar 21, 2020
@rnveach
Copy link
Member Author

rnveach commented Mar 21, 2020

Everything looks good to me.

@strkkk
Copy link
Member

strkkk commented Mar 23, 2020

Fix is merged

@strkkk strkkk closed this as completed Mar 23, 2020
@strkkk strkkk added this to the 8.31 milestone Mar 23, 2020
Abhishek-kumar09 pushed a commit to Abhishek-kumar09/checkstyle that referenced this issue Apr 5, 2020
RayRCaringal pushed a commit to RayRCaringal/checkstyle that referenced this issue Apr 7, 2020
RayRCaringal pushed a commit to RayRCaringal/checkstyle that referenced this issue Apr 7, 2020
ImmortalRabbit pushed a commit to ImmortalRabbit/checkstyle that referenced this issue Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants