diff options
Diffstat (limited to 'Biz/Lint.hs')
-rw-r--r-- | Biz/Lint.hs | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/Biz/Lint.hs b/Biz/Lint.hs index d27ca1d..d387db0 100644 --- a/Biz/Lint.hs +++ b/Biz/Lint.hs @@ -10,7 +10,6 @@ -- : out lint -- : run ormolu -- : run hlint --- : run black -- : run ruff -- : run deadnix -- : run shellcheck @@ -138,7 +137,7 @@ data Linter = Linter fixArgs :: Maybe [Text], -- | An optional function to format the output of the linter as you want -- it, perhaps decoding json or something - formatter :: Maybe (String -> String) + decoder :: Maybe (String -> String) } ormolu :: Linter @@ -147,7 +146,7 @@ ormolu = { exe = "ormolu", checkArgs = ["--mode", "check", "--no-cabal"], fixArgs = Just ["--mode", "inplace", "--no-cabal"], - formatter = Nothing + decoder = Nothing } hlint :: Linter @@ -158,16 +157,16 @@ hlint = -- needs apply-refact >0.9.1.0, which needs ghc >9 -- fixArgs = Just ["--refactor", "--refactor-options=-i"] fixArgs = Nothing, - formatter = Nothing + decoder = Nothing } -black :: Linter -black = +ruffFormat :: Linter +ruffFormat = Linter - { exe = "black", - checkArgs = ["--check"], - fixArgs = Just [], - formatter = Nothing + { exe = "ruff", + checkArgs = ["format", "--check", "--silent"], + fixArgs = Just ["format", "--silent"], + decoder = Nothing } ruff :: Linter @@ -176,7 +175,7 @@ ruff = { exe = "ruff", checkArgs = ["check"], fixArgs = Just ["check", "--fix"], - formatter = Nothing + decoder = Nothing } data DeadnixOutput = DeadnixOutput @@ -199,7 +198,7 @@ deadnix = { exe = "deadnix", checkArgs = "--fail" : commonArgs, fixArgs = Just <| "--edit" : commonArgs, - formatter = Just decodeDeadnixOutput + decoder = Just decodeDeadnixOutput } where commonArgs = @@ -227,7 +226,7 @@ nixfmt = { exe = "nixfmt", checkArgs = ["--check"], fixArgs = Nothing, - formatter = Nothing + decoder = Nothing } shellcheck :: Linter @@ -236,7 +235,7 @@ shellcheck = { exe = "shellcheck", checkArgs = [], fixArgs = Nothing, - formatter = Nothing + decoder = Nothing } indent :: Linter @@ -245,7 +244,7 @@ indent = { exe = "indent", checkArgs = [], fixArgs = Nothing, - formatter = Nothing + decoder = Nothing } data Status = Good | Bad String @@ -272,7 +271,7 @@ runOne mode (ext, ns's) = results +> traverse printResult lint mode hlint ns's ] Namespace.Py -> - [ lint mode black ns's, + [ lint mode ruffFormat ns's, lint mode ruff ns's ] Namespace.Sh -> [lint mode shellcheck ns's] @@ -294,7 +293,7 @@ lint mode linter@Linter {..} ns's = >> Process.readProcessWithExitCode (str exe) args "" /> \case (Exit.ExitSuccess, _, _) -> Done linter Good - (Exit.ExitFailure _, msg, _) -> case formatter of + (Exit.ExitFailure _, msg, _) -> case decoder of Nothing -> Done linter <| Bad msg Just fmt -> Done linter <| Bad <| fmt msg where |