-
Notifications
You must be signed in to change notification settings - Fork 39
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
String template curly braces bugfix #427
Conversation
### What's done: * Fixed bug
Codecov Report
@@ Coverage Diff @@
## master #427 +/- ##
============================================
- Coverage 81.94% 81.89% -0.06%
- Complexity 1445 1448 +3
============================================
Files 70 70
Lines 3617 3623 +6
Branches 1155 1158 +3
============================================
+ Hits 2964 2967 +3
Misses 202 202
- Partials 451 454 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/test/resources/test/paragraph3/string_template/StringTemplateExpected.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
### What's done: * Fixed bugs
@@ -22,6 +21,7 @@ class StringTemplateRuleWarnTest : LintTestBase(::StringTemplateFormatRule) { | |||
""" | |||
|class Some { | |||
| val template = "${'$'}{::String} ${'$'}{asd.moo()}" | |||
| val some = "${'$'}{foo as Foo}" |
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.
not much tests for a regression
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
|} | ||
""".trimMargin(), | ||
LintError(2, 20, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{a}", true), | ||
LintError(3, 16, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1.0}", true) | ||
LintError(3, 16, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1.0}", true), | ||
LintError(4, 19, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1}", true) |
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.
Do you mean that braces can be omitted around dollar sign? Then you must ensure that your fixer escapes it for single-quoted strings and doesn't fix ${'$'}
for triple-quoted strings (no way to escape $
there)
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.
No, it was meant that braces can be omitted around integers or floats
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.
But they can't - in your example it's not a part of template, these braces are just regular characters inside the string. ${'$'}
is a template, and {1.0}
that goes after is a regular part of string.
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.
Oh, this warning complains about $
, not 1
? Then it makes sense.. Do you have tests that ${'$'}
is considered valid in triple-quoted strings?
diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/StringTemplateRuleWarnTest.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
### What's done: * Added test
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
|} | ||
""".trimMargin(), | ||
LintError(2, 20, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{a}", true), | ||
LintError(3, 16, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1.0}", true) | ||
LintError(3, 16, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1.0}", true), | ||
LintError(4, 19, ruleId, "${Warnings.STRING_TEMPLATE_CURLY_BRACES.warnText()} ${'$'}{1}", true) |
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.
Oh, this warning complains about $
, not 1
? Then it makes sense.. Do you have tests that ${'$'}
is considered valid in triple-quoted strings?
diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter3/StringTemplateRuleWarnTest.kt
Show resolved
Hide resolved
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Outdated
Show resolved
Hide resolved
### What's done: * Fixed bugs
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/StringTemplateFormatRule.kt
Show resolved
Hide resolved
### What's done: * Fixed bugs
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
What's done:
This pull request closes #401