-
-
Notifications
You must be signed in to change notification settings - Fork 767
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
Refactor CLI args processing #7092
Conversation
These aren't required and also aren't specified in CliArgs in detekt-cli
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.
Mostly nits
detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/ArgumentConverters.kt
Outdated
Show resolved
Hide resolved
description = "Input paths to analyze." | ||
) | ||
private var input: String? = null | ||
var inputPath: List<Path> = emptyList() |
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.
Q: moving from String?
to List<Path>
makes an empty input valid? Should we check inside PathValidator
that the input is not empty?
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.
If input is empty JCommander returns an error.
java -jar detekt-generator-1.23.6-all.jar -c . -d . -i
returns ParameterException: Expected a value after parameter -i
.
Any other value is validated to check that the paths exist. The only way to pass an empty list is to pass only a separator like -i ,
or -i ;
but I don't think it's worth guarding against this.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7092 +/- ##
============================================
+ Coverage 83.67% 83.72% +0.05%
+ Complexity 3957 3951 -6
============================================
Files 578 578
Lines 12164 12147 -17
Branches 2514 2502 -12
============================================
- Hits 10178 10170 -8
+ Misses 731 730 -1
+ Partials 1255 1247 -8 ☔ View full report in Codecov by Sentry. |
This PR also have another functional change that I think is good but just to point it out. When passing the inputs we allowed things like this Also the new exception doesn't allow to spot those errors easily because the path doesn't quote the path so it is really difficult to spot that space. I'm going to create a new PR to fix this last point. |
Also we should use the splitter on the |
The only functional change is that directories passed to detekt CLI are validated as directories. Other than that, this just makes the code a bit more consistent by using more of JCommander's features, and using stronger typing when args are processed.