-
-
Notifications
You must be signed in to change notification settings - Fork 794
Use stdlib functions for file & path operations #5754
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
Conversation
detekt-report-html/src/main/kotlin/io/github/detekt/report/html/HtmlOutputReport.kt
Fixed
Show fixed
Hide fixed
Codecov Report
@@ Coverage Diff @@
## main #5754 +/- ##
============================================
- Coverage 84.60% 84.59% -0.02%
Complexity 3790 3790
============================================
Files 547 547
Lines 12917 12909 -8
Branches 2262 2262
============================================
- Hits 10929 10920 -9
- Misses 861 862 +1
Partials 1127 1127
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
And these ones
detekt/detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/ArgumentConverters.kt
Lines 15 to 18 in 80bae4b
val config = File(value).toPath() | |
if (Files.notExists(config)) { | |
throw ParameterException("Provided path '$value' does not exist!") | |
} |
detekt/detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/ArgumentConverters.kt
Lines 23 to 27 in 80bae4b
class PathConverter : IStringConverter<Path> { | |
override fun convert(value: String): Path { | |
return Paths.get(value) | |
} | |
} |
You are right, just see it. |
|
||
fun Path.exists(): Boolean = Files.exists(this) | ||
fun Path.isFile(): Boolean = Files.isRegularFile(this) | ||
fun Path.isDirectory(): Boolean = Files.isDirectory(this) |
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.
<3
Great work! |
I set out to remove these imports and use replacements from stdlib:
java.io.File
java.nio.file.Files
java.nio.file.Paths
I was mostly successful, held back by the detekt-gradle-plugin being on API version 1.4, and a couple of stdlib functions which still require an opt in. I chose not to use the opt in functions until they're stable, hopefully in Kotlin 1.9 if not before.
I recommend reviewing by individual commit as I've broken up the changes into logical chunks.