From 31ae312de34f848d7c653cbcef75e35d7fbab166 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Sun, 18 Jun 2023 11:17:08 -0400 Subject: [PATCH] Create default hlint configuration (with tidy up) * hlint --default -j . > .hlint.yaml * Ignore modules that #include "MachDeps.h" Warning: Can't find file "MachDeps.h" in directories ./cabal-testsuite/PackageTests/CmmSources/src . Asked for by: ./cabal-testsuite/PackageTests/CmmSources/src/Demo.hs at line 8 col 1 Warning: Can't find file "MachDeps.h" in directories ./cabal-testsuite/PackageTests/CmmSourcesDyn/src . Asked for by: ./cabal-testsuite/PackageTests/CmmSourcesDyn/src/Demo.hs at line 8 col 1 * Ignore the manually generated Lexer.hs templates/Lexer.x:10:1-20: Warning: Use fewer LANGUAGE pragmas Found: {-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-} Perhaps: {-# LANGUAGE CPP #-} 1 hint * Ignore templates/Paths_pkg.template.hs for its parse error * Ignore templates/SPDX*.hs for their parse errors * Add a linting workflow and rename the formatting one * Redo default configuration with hlint-3.5 I had mistakenly used a development build before: $ hlint --version HLint v3.6.20230213, (C) Neil Mitchell 2006-2022 * Shorten github workflow --- .github/workflows/{linting.yml => format.yml} | 2 +- .github/workflows/lint.yml | 18 +++ .hlint.yaml | 105 ++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) rename .github/workflows/{linting.yml => format.yml} (97%) create mode 100644 .github/workflows/lint.yml create mode 100644 .hlint.yaml diff --git a/.github/workflows/linting.yml b/.github/workflows/format.yml similarity index 97% rename from .github/workflows/linting.yml rename to .github/workflows/format.yml index 47595b1f527..0308e4a595c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/format.yml @@ -1,4 +1,4 @@ -name: Linting +name: Formatting on: pull_request: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..8eea2ece61b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Linting + +on: + pull_request: + push: + +jobs: + hlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: haskell/actions/hlint-setup@v2 + with: + version: "3.5" + - uses: haskell/actions/hlint-run@v2 + with: + path: "." + fail-on: suggestion \ No newline at end of file diff --git a/.hlint.yaml b/.hlint.yaml new file mode 100644 index 00000000000..54771486d1b --- /dev/null +++ b/.hlint.yaml @@ -0,0 +1,105 @@ +# Warnings currently triggered by your code +- ignore: {name: "Avoid lambda"} # 49 hints +- ignore: {name: "Avoid lambda using `infix`"} # 19 hints +- ignore: {name: "Eta reduce"} # 91 hints +- ignore: {name: "Evaluate"} # 9 hints +- ignore: {name: "Functor law"} # 14 hints +- ignore: {name: "Fuse concatMap/map"} # 3 hints +- ignore: {name: "Fuse foldr/map"} # 3 hints +- ignore: {name: "Fuse mapMaybe/map"} # 2 hints +- ignore: {name: "Fuse traverse_/map"} # 1 hint +- ignore: {name: "Hoist not"} # 30 hints +- ignore: {name: "Missing NOINLINE pragma"} # 1 hint +- ignore: {name: "Monoid law, left identity"} # 3 hints +- ignore: {name: "Monoid law, right identity"} # 3 hints +- ignore: {name: "Move brackets to avoid $"} # 25 hints +- ignore: {name: "Move guards forward"} # 4 hints +- ignore: {name: "Redundant $"} # 125 hints +- ignore: {name: "Redundant $!"} # 4 hints +- ignore: {name: "Redundant <$>"} # 6 hints +- ignore: {name: "Redundant =="} # 1 hint +- ignore: {name: "Redundant bracket"} # 206 hints +- ignore: {name: "Redundant guard"} # 2 hints +- ignore: {name: "Redundant if"} # 1 hint +- ignore: {name: "Redundant lambda"} # 22 hints +- ignore: {name: "Redundant list comprehension"} # 3 hints +- ignore: {name: "Redundant map"} # 1 hint +- ignore: {name: "Redundant multi-way if"} # 1 hint +- ignore: {name: "Redundant return"} # 4 hints +- ignore: {name: "Redundant where"} # 3 hints +- ignore: {name: "Replace case with fromMaybe"} # 5 hints +- ignore: {name: "Replace case with maybe"} # 10 hints +- ignore: {name: "Unused LANGUAGE pragma"} # 121 hints +- ignore: {name: "Use $>"} # 5 hints +- ignore: {name: "Use ++"} # 4 hints +- ignore: {name: "Use :"} # 28 hints +- ignore: {name: "Use <$"} # 2 hints +- ignore: {name: "Use <$>"} # 67 hints +- ignore: {name: "Use <&>"} # 14 hints +- ignore: {name: "Use <=<"} # 5 hints +- ignore: {name: "Use =<<"} # 6 hints +- ignore: {name: "Use =="} # 2 hints +- ignore: {name: "Use >=>"} # 3 hints +- ignore: {name: "Use ?~"} # 1 hint +- ignore: {name: "Use Just"} # 2 hints +- ignore: {name: "Use all"} # 8 hints +- ignore: {name: "Use bimap"} # 1 hint +- ignore: {name: "Use camelCase"} # 68 hints +- ignore: {name: "Use catMaybes"} # 3 hints +- ignore: {name: "Use concatMap"} # 1 hint +- ignore: {name: "Use const"} # 38 hints +- ignore: {name: "Use elem"} # 3 hints +- ignore: {name: "Use fewer imports"} # 13 hints +- ignore: {name: "Use first"} # 2 hints +- ignore: {name: "Use fmap"} # 28 hints +- ignore: {name: "Use fold"} # 1 hint +- ignore: {name: "Use for"} # 1 hint +- ignore: {name: "Use forM_"} # 1 hint +- ignore: {name: "Use for_"} # 1 hint +- ignore: {name: "Use fromMaybe"} # 2 hints +- ignore: {name: "Use fromRight"} # 1 hint +- ignore: {name: "Use fst"} # 1 hint +- ignore: {name: "Use if"} # 4 hints +- ignore: {name: "Use infix"} # 19 hints +- ignore: {name: "Use isAsciiLower"} # 2 hints +- ignore: {name: "Use isAsciiUpper"} # 2 hints +- ignore: {name: "Use isDigit"} # 2 hints +- ignore: {name: "Use isJust"} # 2 hints +- ignore: {name: "Use isNothing"} # 3 hints +- ignore: {name: "Use lambda-case"} # 49 hints +- ignore: {name: "Use lefts"} # 1 hint +- ignore: {name: "Use list comprehension"} # 11 hints +- ignore: {name: "Use list literal"} # 3 hints +- ignore: {name: "Use list literal pattern"} # 11 hints +- ignore: {name: "Use map"} # 5 hints +- ignore: {name: "Use map once"} # 6 hints +- ignore: {name: "Use mapMaybe"} # 11 hints +- ignore: {name: "Use max"} # 1 hint +- ignore: {name: "Use maybe"} # 10 hints +- ignore: {name: "Use newtype instead of data"} # 19 hints +- ignore: {name: "Use notElem"} # 11 hints +- ignore: {name: "Use null"} # 3 hints +- ignore: {name: "Use or"} # 1 hint +- ignore: {name: "Use record patterns"} # 16 hints +- ignore: {name: "Use replicateM"} # 1 hint +- ignore: {name: "Use replicateM_"} # 6 hints +- ignore: {name: "Use rights"} # 2 hints +- ignore: {name: "Use second"} # 7 hints +- ignore: {name: "Use section"} # 19 hints +- ignore: {name: "Use sortOn"} # 15 hints +- ignore: {name: "Use traverse"} # 1 hint +- ignore: {name: "Use traverse_"} # 1 hint +- ignore: {name: "Use tuple-section"} # 28 hints +- ignore: {name: "Use typeRep"} # 2 hints +- ignore: {name: "Use unless"} # 17 hints +- ignore: {name: "Use unwords"} # 8 hints +- ignore: {name: "Use void"} # 17 hints +- ignore: {name: "Use when"} # 1 hint + +- arguments: + - --ignore-glob=cabal-testsuite/PackageTests/CmmSources/src/Demo.hs + - --ignore-glob=cabal-testsuite/PackageTests/CmmSourcesDyn/src/Demo.hs + - --ignore-glob=Cabal-syntax/src/Distribution/Fields/Lexer.hs + - --ignore-glob=templates/Paths_pkg.template.hs + - --ignore-glob=templates/SPDX.LicenseExceptionId.template.hs + - --ignore-glob=templates/SPDX.LicenseId.template.hs