Skip to content

Commit 30e7640

Browse files
zlavclaude
andcommitted
Strategy/Scala: refactor detectDependencyPlugins to find-based lookup
Replace the nested if-then-else with a `find` over a precedence-ordered lookup table. Behavior is identical: `find` returns the first match so ModernDependencyTreePlugin still wins over Legacy, and the shared ": enabled in" suffix keeps the three effective marker strings unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6cda958 commit 30e7640

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/Strategy/Scala/Plugin.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Strategy.Scala.Plugin (
1010

1111
import Control.Effect.Diagnostics (Diagnostics, fatalText)
1212
import Control.Effect.Stack (context)
13+
import Data.List (find)
1314
import Data.Maybe (mapMaybe)
1415
import Data.String.Conversion (ConvertUtf8 (decodeUtf8), toString)
1516
import Data.Text (Text)
@@ -82,15 +83,15 @@ hasDependencyPlugins projectDir = do
8283
detectDependencyPlugins :: Text -> DependencyPluginsDetected
8384
detectDependencyPlugins stdoutText =
8485
DependencyPluginsDetected
85-
{ hasMiniDependencyTreePlugin = "sbt.plugins.MiniDependencyTreePlugin: enabled in" `Text.isInfixOf` stdoutText
86-
, dependencyTreePlugin =
87-
if "sbt.plugins.DependencyTreePlugin: enabled in" `Text.isInfixOf` stdoutText
88-
then Just ModernDependencyTreePlugin
89-
else
90-
if "net.virtualvoid.sbt.graph.DependencyGraphPlugin: enabled in" `Text.isInfixOf` stdoutText
91-
then Just LegacyDependencyGraphPlugin
92-
else Nothing
86+
{ hasMiniDependencyTreePlugin = enabled "sbt.plugins.MiniDependencyTreePlugin"
87+
, dependencyTreePlugin = snd <$> find (enabled . fst) treePlugins
9388
}
89+
where
90+
enabled name = (name <> ": enabled in") `Text.isInfixOf` stdoutText
91+
treePlugins =
92+
[ ("sbt.plugins.DependencyTreePlugin", ModernDependencyTreePlugin)
93+
, ("net.virtualvoid.sbt.graph.DependencyGraphPlugin", LegacyDependencyGraphPlugin)
94+
]
9495

9596
-- | The sbt task that writes @tree.html@/@tree.json@ alongside its dependency
9697
-- output. Plugin name vs task casing:

0 commit comments

Comments
 (0)