-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 #13809: Kill mutation in CommonUtil #13953
Conversation
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.
Items :
@@ -261,8 +261,8 @@ public static String relativizeAndNormalizePath(final String baseDirectory, fina | |||
resultPath = path; | |||
} | |||
else { | |||
final Path pathAbsolute = Paths.get(path).normalize(); | |||
final Path pathBase = Paths.get(baseDirectory).normalize(); | |||
final Path pathAbsolute = Paths.get(path); |
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.
Looks like we need to test message of violation and validate how path is starting https://www.google.com/amp/s/www.geeksforgeeks.org/path-normalize-method-in-java-with-examples/amp/
To be OS agnostic we usually avoid checking full path in violation, we might do only file name
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.
What we can test is ... We set path with .
and/or ..
but have in violation path without such symbols.
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.
I have tried multiple ways but at the i didn't find a way in which relativize path is getting affected.
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.
yes, such normalization is done by jdk
https://github.com/openjdk/jdk/blob/db3402577a2c14a41045753a1ffe2829a6bdda91/src/java.base/unix/classes/sun/nio/fs/UnixPath.java#L478-L495
we already have test on this
checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilTest.java
Lines 221 to 224 in bd3a9bb
public void testRelativeNormalizedPathWithDenormalizedBaseDirectory() throws IOException { | |
final String sampleAbsolutePath = new File("src/main/java").getCanonicalPath(); | |
final String absoluteFilePath = sampleAbsolutePath + "/SampleFile.java"; | |
final String basePath = sampleAbsolutePath + PATH_DENORMALIZER; |
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.
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.
We do not need to care about path in zips
You may want to recheck this. Some users put configuration files into external JARs controlled by Maven. Those are basically ZIP files.
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.
We will happily fix issue if they will show how to reproduce issue.
It will be easy, revert with already known input how to reproduce it.
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.
ok to merge
|
regression is only covering behavior on config, to make this regression something weird should be done with paths to validate. non of our tools can do this.
jdk relativize does normalize internaly. Do you propose to change name of util method ? |
Regression should also cover file paths which is done by Checker, as 2 paths need to line up for a match for differencing. If it truthfully has no impact, regression will show no differences either way and will show we won't have anything to worry about after merge. I am leaning to changing the util name and javadoc since I assume it was named normalize for the normalize that happened in it. |
method is renamed. |
Github, generate report |
@rnveach , please review. |
@romani Please make sure you are using a config to hit the code. checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java Lines 260 to 265 in c6a59c8
|
Github, generate report |
Report generation failed on phase "make_report", https://github.com/checkstyle/checkstyle/actions/runs/6687338433/job/18167872017#step:9:578
|
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.
lgtm
normalization is done as part of relativize
for UnixPath
d9c038b
to
8eeb6be
Compare
regression report needs to pass, I am not sure why it is failing with exception. |
Github, generate report |
Report generation failed on phase "make_report", |
@romani @Kevin222004 I think there is a problem with relativizing path.
You may want to take a look at https://stackoverflow.com/q/16299604/15412365 |
problem is at config is updated:
|
Github, generate report |
1 similar comment
Github, generate report |
Regression-with-path-for-basedir: |
@rnveach , report is ready. |
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.
Ok to merge
@romani So we are not going to do anything on #13953 (comment) ? |
@rnveach , yes, let's have regression if it's actually matters, I will learn a lot from such usage :). |
Apparently this change failed in backport (JDK 8). Nothing changed in the javadoc for |
Issue #13809: Kill mutation in CommonUtil
regression is taken from #13284
gist: https://gist.github.com/romani/f15f3afabac0f9ad1e63f429b62d445f
Diff Regression config: https://gist.githubusercontent.com/romani/f15f3afabac0f9ad1e63f429b62d445f/raw/40dfb3e50dc3e5606844f00d074f572be4682079/Config.xml
Diff Regression projects: https://gist.githubusercontent.com/Kevin222004/9600f179b602d4c971bdb0a050099005/raw/360a95ed7bb60d7a0956e531199d484c4d6f6617/test-projects.properties
Report label: Regression-with-path-for-basedir