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

feat: use OrganizeImports scalafix built-in rule, MISC-485 #205

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

Isammoc
Copy link
Member

@Isammoc Isammoc commented Jan 20, 2025

Motivation:
NeQuissimus/sort-imports is no longer maintained. Even though it works very well, scalafix complains about it being compiled against scalafix 0.9 and pollutes the logs.

Modifications:

  • Configure the "new" OrganizeImports built-in rule to be as close as possible from current code

Result:
Small changes in code but use an uptodate version of scalafix rule

@@ -1,13 +1,20 @@
rule = [
SortImports
OrganizeImports,
RedundantSyntax // remove extra string interpolator when not needed
Copy link
Member Author

Choose a reason for hiding this comment

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

I know this one is "extra"
But it is harmless and may clean the code :)

Comment on lines +6 to +20
OrganizeImports {
blankLines = Auto
expandRelative = true
groupedImports = Merge
groups = [
"re:javax?\\.",
"scala.",
"io.gatling.",
"*",
"re:x?sbti?\\."
]
importSelectorsOrder = SymbolsFirst
importsOrder = SymbolsFirst
removeUnused = false
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Way more detailed than before, but the defaults are different

@@ -16,8 +16,7 @@

package io.gatling.build

import io.gatling.build.automated.GatlingAutomatedScalafixPlugin
import io.gatling.build.automated.GatlingAutomatedScalafmtPlugin
import io.gatling.build.automated.{GatlingAutomatedScalafixPlugin, GatlingAutomatedScalafmtPlugin}
Copy link
Member Author

Choose a reason for hiding this comment

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

Application of the "groupedImports = Merge" clause

otherwise the plugin wanted to explode every import...
Maybe we should do it (java style?) to limit impact (and possible conflict) on git diff?

Copy link
Member Author

Choose a reason for hiding this comment

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

Arf! outdated because I forgot to compile (and trigger scalafmt after scalafix)

Comment on lines +64 to +67
override def buildSettings: Seq[Def.Setting[_]] = Seq(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
Copy link
Member Author

Choose a reason for hiding this comment

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

we need to activate semanticdb now

@@ -91,7 +91,7 @@ object GatlingSonatypePlugin extends AutoPlugin {
* - inject it to the state needed by publishSigned task
* - call sonatypeClose command with full state from sonatypeOpen
*/
state.log.info(s"Opening sonatype staging")
state.log.info("Opening sonatype staging")
Copy link
Member Author

Choose a reason for hiding this comment

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

Application of the "RedundantSyntax" rule :)

@Isammoc Isammoc force-pushed the misc-485-sort-import branch from 8353826 to 838bf65 Compare January 20, 2025 19:57
Copy link
Member

@slandelle slandelle left a comment

Choose a reason for hiding this comment

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

Great!

Copy link
Member

@slandelle slandelle left a comment

Choose a reason for hiding this comment

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

Motivation:
NeQuissimus/sort-imports is no longer maintained. Even though it works very
well, scalafix complains about it being compiled against scalafix 0.9 and
pollutes the logs.

Modifications:
 * Configure the "new" OrganizeImports built-in rule to be as close as possible
    from current code
 * Upgrade sbt and scalaVersion for scripted test

Result:
Small changes in code but use an uptodate version of scalafix rule
@Isammoc Isammoc force-pushed the misc-485-sort-import branch from 838bf65 to 6978fdb Compare January 20, 2025 20:08
@slandelle slandelle merged commit 36f6023 into main Jan 20, 2025
1 check passed
@slandelle slandelle deleted the misc-485-sort-import branch January 20, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants