summaryrefslogtreecommitdiff
path: root/Biz/Lint.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-10 19:56:46 -0400
committerBen Sima <ben@bsima.me>2024-04-10 19:56:46 -0400
commit2c09c7f73e2fc770f42b5dd2588aa9634b4e7c6e (patch)
treea6c49dddb7b1735a0f8de2a9a5f4efb605f16f36 /Biz/Lint.hs
parent051973aba8953ebde51eb1436fb3994e7ae699dc (diff)
Switch from black to ruff format
Ruff is faster and if it supports everything that black supports than why not? I did have to pull in a more recent version from unstable, but that's easy to do now. And I decided to just go ahead and configure ruff by turning on almost all checks, which meant I had to fix a whole bunch of things, but I did that and everything is okay now.
Diffstat (limited to 'Biz/Lint.hs')
-rw-r--r--Biz/Lint.hs33
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