-
-
Notifications
You must be signed in to change notification settings - Fork 794
Add StringShouldBeRawString.kt rule #5705
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
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Fixed
Show fixed
Hide fixed
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Fixed
Show fixed
Hide fixed
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Fixed
Show fixed
Hide fixed
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Fixed
Show fixed
Hide fixed
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Fixed
Show fixed
Hide fixed
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Fixed
Show fixed
Hide fixed
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Fixed
Show fixed
Hide fixed
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Fixed
Show fixed
Hide fixed
3f0c9fa
to
dbc255b
Compare
Codecov Report
@@ Coverage Diff @@
## main #5705 +/- ##
===========================================
+ Coverage 0 84.46% +84.46%
- Complexity 0 3753 +3753
===========================================
Files 0 544 +544
Lines 0 12763 +12763
Branches 0 2236 +2236
===========================================
+ Hits 0 10780 +10780
- Misses 0 865 +865
- Partials 0 1118 +1118
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Couple of notes:
|
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Fixed
Show fixed
Hide fixed
The second example on the issue doesn't talk about multi-line. A regex is a good example of a single line raw string that is better than a normal string. |
Good point. I only looked at this very quickly, but the issue being fixed is "Rule for encouraging MultilineRawString". The proposed rule is a bit different. Agree that this proposal makes sense as is, so ignore my comment :) |
Rename fun to getStringSequenceExcludingRawString
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.
It looks good :)
...style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawStringSpec.kt
Outdated
Show resolved
Hide resolved
if (maxEscapedCharacterCount == Int.MAX_VALUE) { | ||
return | ||
} |
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 the user doesn't want this rule s/he should disable it. We don't need to have two different ways to disable 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.
Sure. But currently if we set Int.MAX_VALUE in the detekt.yml
the working of rule breaks. BTW @BraisGabin is there any sanitisation on user input through detekt.yml
?
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.
Int.MAX_VALUE doesn't seems like a sane value. We shouldn't care about that. If they would like the max value of a long it wouldn't work either 🤷.
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 there is little sanitation on that regard as far as I know.
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Outdated
Show resolved
Hide resolved
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Outdated
Show resolved
Hide resolved
...les-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/StringShouldBeRawString.kt
Outdated
Show resolved
Hide resolved
Remove corresponding Int tests Make extension parameter non null
Hi @BraisGabin is this PR good for merge? Or some changes are required? cc @cortinico @TWiStErRob for their inputs as well |
This is good to go! Sorry for the delay :) |
Fixes #5697