Skip to content
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

StringTemplateRule: don't report when template expression is keyword #888

Merged
merged 1 commit into from
Sep 6, 2020

Conversation

t-kameyama
Copy link
Contributor

Fixes #883

@@ -41,13 +46,15 @@ class StringTemplateRule : Rule("string-template") {
) {
emit(dot.startOffset, "Redundant \"toString()\" call in string template", true)
if (autoCorrect) {
entryExpression = (entryExpression as? KtDotQualifiedExpression)?.receiverExpression
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line for?

Copy link
Contributor Author

@t-kameyama t-kameyama Sep 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this line is not exists, testFormat will fail because entryExpression is KtDotQualifiedExpression.

callExpression of dotQualifiedExpression will be removed in the next line, so we need to save receiverExpression in entryExpression.

@romtsn romtsn merged commit b9b5e07 into pinterest:master Sep 6, 2020
@romtsn
Copy link
Collaborator

romtsn commented Sep 6, 2020

Thanks!

@t-kameyama t-kameyama deleted the issue_883 branch September 6, 2020 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-formatting redundant curly braces in specific string template fails to compile
2 participants