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

#690: Support check for "redundant enclosing brace" in string interpo... #703

Merged
merged 9 commits into from
Jan 31, 2017
Prev Previous commit
Next Next commit
most argss in input are wrapped in braces
  • Loading branch information
Yuriy Susuk committed Jan 30, 2017
commit 8d16d4a0421352612674cfac70b07bf452a65fd0
16 changes: 8 additions & 8 deletions core/src/test/resources/rewrite/RedundantBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -194,35 +194,35 @@ object a {
}
<<< no braces in str interpolation
object c {
s"$a"
s"${a}"
}
>>>
object c {
s"$a"
}
<<< two args no braces in str interpolation
<<< two args in str interpolation
object c {
s"$a$b"
s"${a}${b}"
}
>>>
object c {
s"$a$b"
}
<<< spaces before and after arg no braces in str interpolation
<<< spaces before and after arg in str interpolation
object c {
s" $a "
s" ${a} "
}
>>>
object c {
s" $a "
s" ${a} "
Copy link
Member

Choose a reason for hiding this comment

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

Is this expected output?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's a bug)

}
<<< special symbol after arg no braces in str interpolation
object c {
s"$a-"
s"${a}-"
}
>>>
object c {
s"$a-"
s"${a}-"
Copy link
Member

Choose a reason for hiding this comment

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

Same here, a can be unwrapped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and this one fails s"${a} a${b}b"

Copy link
Collaborator Author

@ysusuk ysusuk Jan 30, 2017

Choose a reason for hiding this comment

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

i was generally thinking about checks like value.isEmpty or starts with \n, \r or anything like this! what else should it be? minus/plus... is there kind a list of them? or do you think there is a better approach?

Copy link
Member

Choose a reason for hiding this comment

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

You can look at the spec https://www.scala-lang.org/files/archive/spec/2.11/01-lexical-syntax.html#identifiers

Seems like this rewrite should not take place when the right hand part starts with underscore or an alphanumeric character. In other cases, you can safely remove the curly brace.

}
<<< number after arg in str interpolation
object c {
Expand Down