-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add a migration rule to help migration to 0.9.28 #1395
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
rule = v0_9_28 | ||
*/ | ||
package fix | ||
|
||
import scalafix.testkit.SemanticRuleSuite | ||
|
||
class OldSemanticRule extends SemanticRuleSuite() { | ||
runAllTests() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fix | ||
|
||
import org.scalatest.FunSuiteLike | ||
import scalafix.testkit.AbstractSemanticRuleSuite | ||
|
||
class OldSemanticRule extends AbstractSemanticRuleSuite with FunSuiteLike { | ||
runAllTests() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fix.v0_9_28 |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||||
package fix | ||||||||||
|
||||||||||
import scala.meta._ | ||||||||||
|
||||||||||
import scalafix.v1._ | ||||||||||
|
||||||||||
class v0_9_28 extends SemanticRule("v0_9_28") { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this migration is for the rule authors (testkit) and not end users (cli/interface), might be worth mentioning it in the name? also a link to the PRs that introduced/enforced the pattern applied here would be useful
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be worth adding a link to #1176 for the record |
||||||||||
override def fix(implicit doc: SemanticDocument): Patch = | ||||||||||
doc.tree.collect { | ||||||||||
case t @ Importee.Name(Name("SemanticRuleSuite")) => | ||||||||||
Patch.removeImportee(t) + | ||||||||||
Patch.addGlobalImport( | ||||||||||
importer"scalafix.testkit.AbstractSemanticRuleSuite" | ||||||||||
) | ||||||||||
case t @ Init(_, _, _) => | ||||||||||
if (t.toString() == "SemanticRuleSuite()") | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use semanticdb information through |
||||||||||
Patch.addGlobalImport(importer"org.scalatest.FunSuiteLike") + | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just had a double-check on the mess that ScalaTest introduced in a minor release:
We currently build against 3.0.8, so the first is the right choice, and users of the testkit which have evicted 3.0.8 with 3.2.x would have runtime failures on We will easily be able to move to |
||||||||||
Patch.replaceTree(t, "AbstractSemanticRuleSuite") + | ||||||||||
Patch.addRight(t, " with FunSuiteLike") | ||||||||||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I guess it does not matter since chances that |
||||||||||
else Patch.empty | ||||||||||
}.asPatch | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fix | ||
|
||
import org.scalatest.FunSuiteLike | ||
import scalafix.testkit.AbstractSemanticRuleSuite | ||
|
||
class RuleSuite extends AbstractSemanticRuleSuite with FunSuiteLike { | ||
runAllTests() | ||
} |
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.
make sure the output compiles with what will become 0.9.28?