-
Notifications
You must be signed in to change notification settings - Fork 65
[MCHECKSTYLE-397] support ${config_loc} on checkstyle xml #36
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -584,6 +584,20 @@ private Properties getOverridingProperties( CheckstyleExecutorRequest request ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| //${config_loc} for the origin dir of the configLocation, just like eclipsecs | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // so we config such as `${config_loc}/checkstyle-suppressions.xml` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+587
to
+588
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| //${config_loc} for the origin dir of the configLocation, just like eclipsecs | |
| // so we config such as `${config_loc}/checkstyle-suppressions.xml` | |
| /* | |
| * Sets the config_loc property to the directory portion of configLocation. | |
| * This allows Checkstyle configurations to reference the config directory using ${config_loc}, | |
| * similar to Eclipse CS plugin behavior. | |
| */ |
Copilot
AI
Nov 8, 2025
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.
The code only handles forward slash / as a path separator, but Windows systems use backslash \. This will cause the config_loc property to be incorrectly set on Windows when the config location contains backslashes. Consider using Math.max(configLocation.lastIndexOf('/'), configLocation.lastIndexOf('\\')) to handle both path separators, or use a platform-independent approach.
| final int idx = configLocation.lastIndexOf( '/' ); | |
| final int idx = Math.max(configLocation.lastIndexOf('/'), configLocation.lastIndexOf('\\')); |
Copilot
AI
Nov 8, 2025
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.
Potential NullPointerException: The code doesn't check if configLocation is null before calling lastIndexOf(). While getConfigFile() is currently called before this method in getConfiguration(), this creates a fragile implicit dependency. Add a null check to make the code more robust: if (configLocation != null) { ... }.
| final int idx = configLocation.lastIndexOf( '/' ); | |
| final String configLoc; | |
| if ( idx == -1 ) | |
| { | |
| configLoc = ""; | |
| } | |
| else | |
| { | |
| configLoc = configLocation.substring( 0, idx ); | |
| final String configLoc; | |
| if (configLocation != null) | |
| { | |
| final int idx = configLocation.lastIndexOf( '/' ); | |
| if ( idx == -1 ) | |
| { | |
| configLoc = ""; | |
| } | |
| else | |
| { | |
| configLoc = configLocation.substring( 0, idx ); | |
| } | |
| } | |
| else | |
| { | |
| configLoc = ""; |
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.
Grammatical error in comment: "so we config such as" should be "so we can configure such as" or "allowing configuration such as".