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 - ImportOrderCheck (2) #7873

Closed
rnveach opened this issue Mar 16, 2020 · 3 comments · Fixed by #8081
Closed

Resolve Pitest Issues - ImportOrderCheck (2) #7873

rnveach opened this issue Mar 16, 2020 · 3 comments · Fixed by #8081

Comments

@rnveach
Copy link
Member

rnveach commented Mar 16, 2020

Child issue of #7797 ,

"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> final boolean separatorBetween = isStatic != lastImportStatic</span></pre></td></tr>"

@DXTkastb
Copy link
Contributor

I'm on it.

DXTkastb added a commit to DXTkastb/checkstyle that referenced this issue Apr 12, 2020
@DXTkastb
Copy link
Contributor

DXTkastb commented Apr 12, 2020

Pitest report:
https://dxtkastb.github.io/checkstyle/reports/ImportOrder/repo/com.puppycrawl.tools.checkstyle.checks.imports/ImportOrderCheck.java.html

Better Pitest report:
https://dxtkastb.github.io/checkstyle/reports/ImportOrder/repo-edited/com.puppycrawl.tools.checkstyle.checks.imports/ImportOrderCheck.java.html

Surviving Mutation:

"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> final boolean separatorBetween = isStatic != lastImportStatic</span></pre></td></tr>"

Hardcoded Branch:
https://github.com/DXTkastb/checkstyle/blob/5bb8ae24bb6dd655ad3789d69e3a363d37828043/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java#L698-L699

Pitest regression report:
https://dxtkastb.github.io/checkstyle/reports/ImportOrder/repo/diff/index.html
https://dxtkastb.github.io/checkstyle/reports/ImportOrder/newdiff/index.html

Code analysis:
The regression report did not provide much help.

/**
* Checks whether import groups should be separated.
* @param isStatic whether the token is static or not.
* @return true if imports groups should be separated.
*/
private boolean needSeparator(boolean isStatic) {
final boolean typeImportSeparator = !isStatic && separated;
final boolean staticImportSeparator;
if (staticImportsApart) {
staticImportSeparator = isStatic && separatedStaticGroups;
}
else {
staticImportSeparator = isStatic && separated;
}
final boolean separatorBetween = isStatic != lastImportStatic
&& (separated || separatedStaticGroups) && staticImportsApart;
return typeImportSeparator || staticImportSeparator || separatorBetween;
}

Line 698: We need to check when:

final boolean separatorBetween =
isStatic != lastImportStatic is true and
(separated || separatedStaticGroups) is true and
staticImportsApart is false

which will affect :

return typeImportSeparator || staticImportSeparator || separatorBetween;

if option property is not set to top/bottom then, staticImportsApart and separatedStaticGroups is false. If so, then separatorBetween will be false, but simultaneously typeImportSeparator/staticImportSeparator will be true somehow because(separated is true) :

 final boolean typeImportSeparator = !isStatic && separated; 
staticImportSeparator = isStatic && separated

if I set separated to false, then (separated || separatedStaticGroups) will shoot false and staticImportsApart will lose its last bit of importance.

@rnveach
Copy link
Member Author

rnveach commented May 17, 2020

Fix was merged

@rnveach rnveach added this to the 8.33 milestone May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants