From 52fcc3012f9960738f8d15713003eb7074a9fedd Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:22:09 +0100 Subject: [PATCH 01/12] HLint partial functions --- ghcide/.hlint.yaml => .hlint.yaml | 81 ++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 7 deletions(-) rename ghcide/.hlint.yaml => .hlint.yaml (78%) diff --git a/ghcide/.hlint.yaml b/.hlint.yaml similarity index 78% rename from ghcide/.hlint.yaml rename to .hlint.yaml index a188671994..e030348940 100644 --- a/ghcide/.hlint.yaml +++ b/.hlint.yaml @@ -137,20 +137,87 @@ # Things that are unsafe in Haskell base library - {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]} - {name: unsafeDupablePerformIO, within: []} - - {name: unsafeCoerce, within: [Ide.Plugin.Eval.Code, Development.IDE.Core.Compile, Development.IDE.Types.Shake]} + - name: unsafeCoerce + within: + - Ide.Plugin.Eval.Code + - Development.IDE.Core.Compile + - Development.IDE.Types.Shake + - Wingman.Judgements.SYB + - Ide.Plugin.Properties + # Things that are a bit dangerous in the GHC API - - {name: nameModule, within: []} - # Partials and their legacy locations - - name: tail + - name: nameModule + within: + - Ide.Plugin.CallHierarchy.Internal + - Ide.Plugin.Rename + - Compat.HieBin + + # Partial functions + - name: Data.List.head + within: + - Main + - Experiments + - Development.IDE.Core.Shake + - Development.IDE.Plugin.CodeAction + - Development.IDE.Plugin.Completions + - Development.IDE.Plugin.CodeAction.ExactPrint + - Development.IDE.Session + - Development.IDE.Spans.Documentation + - Ide.Plugin.CallHierarchy.Internal + - TExpectedActual + - TRigidType + - TRigidType + - Ide.Plugin.Class + - Wingman.Tactics + + - name: Data.List.tail within: + - Main - Development.Benchmark.Rules - Development.IDE.Plugin.CodeAction - Development.IDE.Plugin.CodeAction.ExactPrint - Development.IDE.Session - # ghcide/test/exe + - IDE.Plugin.Eval.Code + - IDE.Plugin.Eval.Util + - UnificationSpec + + - name: "Data.List.!!" + within: - Main - # plugins/hls-tactics-plugin/test - # - UnificationSpec + - Experiments + - FunctionalCodeAction + - Development.IDE.Plugin.CodeAction + - Development.IDE.Plugin.Completions.Logic + - Development.IDE.Spans.Documentation + - Wingman.CaseSplit + - Wingman.Simplify + + + - name: Data.Text.head + within: + - Development.IDE.Plugin.CodeAction + - Development.IDE.Plugin.Completions.Logic + + - name: Data.Maybe.fromJust + within: + - Experiments + - Main + - MultipleImports + - Progress + - Utils + - Development.IDE.Core.Compile + - Development.IDE.Core.Rules + - Development.IDE.Core.Shake + - Development.IDE.Plugin.Completions + - Development.IDE.Plugin.CodeAction.ExactPrint + - Development.IDE.Test + - Development.IDE.Graph.Internal.Profile + - Development.IDE.Graph.Internal.Rules + - Ide.Plugin.Class + + - name: "Data.Map.!" + within: + - Wingman.LanguageServer # We really do not want novel usages of restricted functions, and mere # Warning is not enough to prevent those consistently; you need a build failure. From 19d54aa224197714c778b8053b6a93e987c63122 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:29:52 +0100 Subject: [PATCH 02/12] Delete commented out stuff --- .hlint.yaml | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index e030348940..fb24ff8f14 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -129,10 +129,7 @@ - {name: [-Wno-dodgy-imports,-Wno-incomplete-uni-patterns], within: [Main, Development.IDE.GHC.Compat, Development.IDE.GHC.Compat.Core, Development.Benchmark.Rules]} - {name: [-Wno-unused-imports], within: [Development.IDE.GHC.Compat.Core]} - {name: [-Wno-deprecations, -Wno-unticked-promoted-constructors], within: [Main, Experiments]} -# - modules: -# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set' -# - {name: Control.Arrow, within: []} # Certain modules are banned entirely -# + - functions: # Things that are unsafe in Haskell base library - {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]} @@ -222,26 +219,3 @@ # We really do not want novel usages of restricted functions, and mere # Warning is not enough to prevent those consistently; you need a build failure. - error: {name: Avoid restricted function} - -# Add custom hints for this project -# -# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar" -# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x} - -# Turn on hints that are off by default -# -# Ban "module X(module X) where", to require a real export list -# - warn: {name: Use explicit module export list} -# -# Replace a $ b $ c with a . b $ c -# - group: {name: dollar, enabled: true} -# -# Generalise map to fmap, ++ to <> -# - group: {name: generalise, enabled: true} - -# Ignore some builtin hints -# - ignore: {name: Use let} -# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules - -# Define some custom infix operators -# - fixity: infixr 3 ~^#^~ From fd08faa267fa4e4b9b465268f073e990881c94e2 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:30:15 +0100 Subject: [PATCH 03/12] Delete flag-based warnings, unclear they add much --- .hlint.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index fb24ff8f14..ee074cf634 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -123,13 +123,6 @@ - Development.IDE.Plugin.Completions.Logic - Development.IDE.Types.Location -- flags: - - default: false - - {name: [-Wno-missing-signatures, -Wno-orphans, -Wno-overlapping-patterns, -Wno-incomplete-patterns, -Wno-missing-fields, -Wno-unused-matches]} - - {name: [-Wno-dodgy-imports,-Wno-incomplete-uni-patterns], within: [Main, Development.IDE.GHC.Compat, Development.IDE.GHC.Compat.Core, Development.Benchmark.Rules]} - - {name: [-Wno-unused-imports], within: [Development.IDE.GHC.Compat.Core]} - - {name: [-Wno-deprecations, -Wno-unticked-promoted-constructors], within: [Main, Experiments]} - - functions: # Things that are unsafe in Haskell base library - {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]} From 59471c84c30fc2691661ff7de22bdfef0c2eaf98 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:30:30 +0100 Subject: [PATCH 04/12] Delete DA-specific hints --- .hlint.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index ee074cf634..e99767a4d7 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -48,16 +48,6 @@ - warn: {lhs: nubBy, rhs: Data.List.Extra.nubOrdBy} - warn: {lhs: Data.List.Extra.nubOn, rhs: Data.List.Extra.nubOrdOn} -# DA specific hints -- warn: {lhs: Data.Text.pack (DA.Pretty.renderPlain x), rhs: DA.Pretty.renderPlain x} -- warn: {lhs: Data.Text.Extended.pack (DA.Pretty.renderPlain x), rhs: DA.Pretty.renderPlain x} -- warn: {lhs: DA.Pretty.renderPlain (DA.Pretty.pretty x), rhs: DA.Pretty.renderPretty x} -- warn: {lhs: Data.Text.readFile, rhs: Data.Text.Extended.readFileUtf8} -- warn: {lhs: Data.Text.writeFile, rhs: Data.Text.Extended.writeFileUtf8} -- warn: {lhs: Data.Text.Lazy.readFile, rhs: Data.Text.Extended.readFileUtf8} -- warn: {lhs: Data.Text.Lazy.writeFile, rhs: Data.Text.Extended.writeFileUtf8} -- warn: {lhs: System.Environment.setEnv, rhs: System.Environment.Blank.setEnv} - # Specify additional command line arguments # - arguments: ["--cpp-include=include"] From c242e41e51a592846185fe1823c11a528c3f3743 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:30:44 +0100 Subject: [PATCH 05/12] Delete extra cpp args --- .hlint.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index e99767a4d7..a52cbfc512 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -48,10 +48,6 @@ - warn: {lhs: nubBy, rhs: Data.List.Extra.nubOrdBy} - warn: {lhs: Data.List.Extra.nubOn, rhs: Data.List.Extra.nubOrdOn} -# Specify additional command line arguments -# -- arguments: ["--cpp-include=include"] - - extensions: - default: true From 5774fc163852dcaec80bb414f39f85869f104283 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:30:57 +0100 Subject: [PATCH 06/12] Delete extension options relating to dead build system --- .hlint.yaml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index a52cbfc512..ac727f5f4d 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -51,25 +51,6 @@ - extensions: - default: true - # Extensions enabled by `bazel` and `da-ghci` by default. We ban them here - # to avoid useless pragmas piling up on the top of files. - - {name: BangPatterns, within: []} - - {name: DeriveDataTypeable, within: []} - - {name: DeriveFoldable, within: []} - - {name: DeriveFunctor, within: []} - - {name: DeriveGeneric, within: []} - - {name: DeriveTraversable, within: []} - - {name: FlexibleContexts, within: []} - - {name: GeneralizedNewtypeDeriving, within: []} - - {name: LambdaCase, within: []} - - {name: NamedFieldPuns, within: []} - - {name: RecordWildCards, within: []} - - {name: ScopedTypeVariables, within: []} - - {name: StandaloneDeriving, within: []} - - {name: TupleSections, within: []} - - {name: TypeApplications, within: []} - - {name: ViewPatterns, within: []} - # Shady extensions - name: CPP within: From 29f34bf2c6fdc1db992ad7c8c87f54756214ad56 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:31:22 +0100 Subject: [PATCH 07/12] Don't bother trying to restrict CPP for now, it's everywhere --- .hlint.yaml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index ac727f5f4d..7a1ac5fb6e 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -48,48 +48,6 @@ - warn: {lhs: nubBy, rhs: Data.List.Extra.nubOrdBy} - warn: {lhs: Data.List.Extra.nubOn, rhs: Data.List.Extra.nubOrdOn} -- extensions: - - default: true - - # Shady extensions - - name: CPP - within: - - Development.IDE.Compat - - Development.IDE.Core.FileStore - - Development.IDE.Core.FileUtils - - Development.IDE.Core.Compile - - Development.IDE.Core.Rules - - Development.IDE.Core.Tracing - - Development.IDE.GHC.Compat - - Development.IDE.GHC.Compat.Core - - Development.IDE.GHC.Compat.Env - - Development.IDE.GHC.Compat.ExactPrint - - Development.IDE.GHC.Compat.Iface - - Development.IDE.GHC.Compat.Logger - - Development.IDE.GHC.Compat.Outputable - - Development.IDE.GHC.Compat.Parser - - Development.IDE.GHC.Compat.Plugins - - Development.IDE.GHC.Compat.Units - - Development.IDE.GHC.Compat.Util - - Development.IDE.GHC.CPP - - Development.IDE.GHC.Dump - - Development.IDE.GHC.ExactPrint - - Development.IDE.GHC.Orphans - - Development.IDE.GHC.Util - - Development.IDE.Import.FindImports - - Development.IDE.LSP.Outline - - Development.IDE.Spans.Calculate - - Development.IDE.Spans.Documentation - - Development.IDE.Spans.Common - - Development.IDE.Spans.AtPoint - - Development.IDE.Spans.Pragmas - - Development.IDE.Plugin.CodeAction - - Development.IDE.Plugin.CodeAction.Args - - Development.IDE.Plugin.CodeAction.ExactPrint - - Development.IDE.Plugin.Completions - - Development.IDE.Plugin.Completions.Logic - - Development.IDE.Types.Location - - functions: # Things that are unsafe in Haskell base library - {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]} From 7bc240a1d28768fe48df15e3268352955cbc022b Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 12:36:34 +0100 Subject: [PATCH 08/12] Make the hlint job fail if there are any errors --- .github/workflows/hlint.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hlint.yml b/.github/workflows/hlint.yml index f39191b48a..053c49a03d 100644 --- a/.github/workflows/hlint.yml +++ b/.github/workflows/hlint.yml @@ -6,7 +6,7 @@ on: - '**' jobs: - build10: + hlint: name: "Hlint check run" runs-on: ubuntu-latest steps: @@ -15,11 +15,12 @@ jobs: - name: 'Installing' uses: rwe/actions-hlint-setup@v1 with: - version: '3.3.4' + version: '3.4' - name: 'Checking code' uses: rwe/actions-hlint-run@v1 with: - hlint-bin: "hlint --with-group=extra --hint=ghcide/.hlint.yaml" - path: '[ "ghcide/src", "ghcide/exe", "ghcide/bench/lib", "ghcide/bench/exe", "ghcide/bench/hist", "shake-bench/src", "ghcide/test/exe"]' + hlint-bin: "hlint --with-group=extra" + fail-on: error + path: . From ac538fa7d1cb8b00f32c0714b105883ff5bf6c18 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 13:37:10 +0100 Subject: [PATCH 09/12] Fix for rebase, add unsafePerformIO and fold1 variants --- .hlint.yaml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.hlint.yaml b/.hlint.yaml index 7a1ac5fb6e..ff84728d1a 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -50,7 +50,22 @@ - functions: # Things that are unsafe in Haskell base library - - {name: unsafeInterleaveIO, within: [Development.IDE.LSP.LanguageServer]} + - name: unsafePerformIO + within: + - Development.IDE.Core.Shake + - Development.IDE.GHC.Util + - Development.IDE.Graph.Internal.Database + - Development.IDE.Graph.Internal.Paths + - Development.IDE.Graph.Internal.Profile + - Ide.Types + - Test.Hls + - Test.Hls.Command + - Wingman.Debug + - Wingman.Types + - AutoTupleSpec + - name: unsafeInterleaveIO + within: + - Development.IDE.LSP.LanguageServer - {name: unsafeDupablePerformIO, within: []} - name: unsafeCoerce within: @@ -63,6 +78,7 @@ # Things that are a bit dangerous in the GHC API - name: nameModule within: + - Development.IDE.GHC.CoreFile - Ide.Plugin.CallHierarchy.Internal - Ide.Plugin.Rename - Compat.HieBin @@ -96,6 +112,20 @@ - IDE.Plugin.Eval.Util - UnificationSpec + - name: Data.List.last + within: + - GenChangelogs + - Main + + - name: Data.List.init + within: [] + + - name: Data.List.foldl1' + within: [] + + - name: Data.List.foldr1' + within: [] + - name: "Data.List.!!" within: - Main @@ -113,6 +143,13 @@ - Development.IDE.Plugin.CodeAction - Development.IDE.Plugin.Completions.Logic + - name: Data.Foldable.foldl1 + within: [] + + - name: Data.Foldable.foldr1 + within: + - Wingman.Tactics + - name: Data.Maybe.fromJust within: - Experiments From bf82912cdd2a683193594710ecaf310dfc240afd Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 14:06:24 +0100 Subject: [PATCH 10/12] Add some more indexing functions --- .hlint.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.hlint.yaml b/.hlint.yaml index ff84728d1a..e8cf2d9751 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -171,6 +171,15 @@ within: - Wingman.LanguageServer + - name: "Data.IntMap.!" + within: [] + + - name: "Data.Vector.!" + within: [] + + - name: "GHC.Arr.!" + within: [] + # We really do not want novel usages of restricted functions, and mere # Warning is not enough to prevent those consistently; you need a build failure. - error: {name: Avoid restricted function} From b6a91b0a96cceb4f01cfcf592cd9631c32d05557 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Jun 2022 21:36:45 +0100 Subject: [PATCH 11/12] Try turning off hlint on this test file --- test/testdata/wErrorTest/src/WError.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/testdata/wErrorTest/src/WError.hs b/test/testdata/wErrorTest/src/WError.hs index 86e0ad2a3d..70db26840d 100644 --- a/test/testdata/wErrorTest/src/WError.hs +++ b/test/testdata/wErrorTest/src/WError.hs @@ -1,2 +1,3 @@ module WError where +{-# ANN module "HLint: ignore" #-} main = undefined From 08771a10bacda4e1f9c5d469dde4ff90b7360dd8 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Tue, 21 Jun 2022 11:37:44 +0100 Subject: [PATCH 12/12] Add .hlint.yaml file for hls-hlint-plugin --- plugins/hls-hlint-plugin/.hlint.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 plugins/hls-hlint-plugin/.hlint.yaml diff --git a/plugins/hls-hlint-plugin/.hlint.yaml b/plugins/hls-hlint-plugin/.hlint.yaml new file mode 100644 index 0000000000..7bcab2e941 --- /dev/null +++ b/plugins/hls-hlint-plugin/.hlint.yaml @@ -0,0 +1,2 @@ +# This is here so that the tests in this package don't +# pick up the configuration from HLS's own .hlint.yaml