-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RedundantSyntax: distinguish single and triple quotes
- Loading branch information
Showing
7 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
scalafix-tests/input/src/main/scala-2.12/test/redundantSyntax/StringInterpolator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
rules = RedundantSyntax | ||
RedundantSyntax.stringInterpolator = true | ||
*/ | ||
|
||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = s"foo" | ||
b = s"foo $a bar" | ||
//b = s"my \"quoted\" string" does not compile as of 2.12.18 as https://github.com/scala/scala/pull/8830 was not backported | ||
|
||
b = """foo""" | ||
b = | ||
s"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = f"foo" | ||
b = f"foo $a%2.2f" | ||
b = f"foo \n bar" | ||
|
||
b = raw"foo $a \nbar" | ||
b = raw"""foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = raw"foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
scalafix-tests/input/src/main/scala-3/test/redundantSyntax/StringInterpolator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
rules = RedundantSyntax | ||
RedundantSyntax.stringInterpolator = true | ||
*/ | ||
|
||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = s"foo" | ||
b = s"foo $a bar" | ||
b = s"my \"quoted\" string" | ||
|
||
b = """foo""" | ||
b = | ||
s"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = f"foo" | ||
b = f"foo $a%2.2f" | ||
b = f"foo \n bar" | ||
|
||
b = raw"foo $a \nbar" | ||
b = raw"""foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = raw"foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
scalafix-tests/output/src/main/scala-2.12/test/redundantSyntax/StringInterpolator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = "foo" | ||
b = s"foo $a bar" | ||
//b = s"my \"quoted\" string" does not compile as of 2.12.18 as https://github.com/scala/scala/pull/8830 was not backported | ||
|
||
b = """foo""" | ||
b = | ||
"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = "foo" | ||
b = f"foo $a%2.2f" | ||
b = "foo \n bar" | ||
|
||
b = raw"foo $a \nbar" | ||
b = """foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = "foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
scalafix-tests/output/src/main/scala-3/test/redundantSyntax/StringInterpolator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = "foo" | ||
b = s"foo $a bar" | ||
b = "my \"quoted\" string" | ||
|
||
b = """foo""" | ||
b = | ||
"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = "foo" | ||
b = f"foo $a%2.2f" | ||
b = "foo \n bar" | ||
|
||
b = raw"foo $a \nbar" | ||
b = """foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = "foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |