Skip to content

Commit efcb8e2

Browse files
Set up partial functions ratchet (#2974)
* HLint partial functions * Delete commented out stuff * Delete flag-based warnings, unclear they add much * Delete DA-specific hints * Delete extra cpp args * Delete extension options relating to dead build system * Don't bother trying to restrict CPP for now, it's everywhere * Make the hlint job fail if there are any errors * Fix for rebase, add unsafePerformIO and fold1 variants * Add some more indexing functions * Try turning off hlint on this test file * Add .hlint.yaml file for hls-hlint-plugin Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3461823 commit efcb8e2

File tree

5 files changed

+193
-184
lines changed

5 files changed

+193
-184
lines changed

.github/workflows/hlint.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- '**'
77

88
jobs:
9-
build10:
9+
hlint:
1010
name: "Hlint check run"
1111
runs-on: ubuntu-latest
1212
steps:
@@ -15,11 +15,12 @@ jobs:
1515
- name: 'Installing'
1616
uses: rwe/actions-hlint-setup@v1
1717
with:
18-
version: '3.3.4'
18+
version: '3.4'
1919

2020
- name: 'Checking code'
2121
uses: rwe/actions-hlint-run@v1
2222
with:
23-
hlint-bin: "hlint --with-group=extra --hint=ghcide/.hlint.yaml"
24-
path: '[ "ghcide/src", "ghcide/exe", "ghcide/bench/lib", "ghcide/bench/exe", "ghcide/bench/hist", "shake-bench/src", "ghcide/test/exe"]'
23+
hlint-bin: "hlint --with-group=extra"
24+
fail-on: error
25+
path: .
2526

.hlint.yaml

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# HLint configuration file
2+
# https://github.com/ndmitchell/hlint
3+
##########################
4+
5+
# To run HLint do:
6+
# $ hlint --git -j4
7+
8+
# Warnings currently triggered by our code
9+
- ignore: {name: "Use <$>"}
10+
- ignore: {name: "Use :"}
11+
- ignore: {name: "Redundant do"}
12+
- ignore: {name: "Avoid lambda"}
13+
- ignore: {name: "Use newtype instead of data"}
14+
- ignore: {name: "Use unless"}
15+
- ignore: {name: "Move brackets to avoid $"}
16+
- ignore: {name: "Eta reduce"}
17+
- ignore: {name: "Parse error"}
18+
- ignore: {name: "Reduce duplication"}
19+
- ignore: {name: "Use ++"}
20+
- ignore: {name: "Use $>"}
21+
- ignore: {name: "Use section"}
22+
- ignore: {name: "Use record patterns"}
23+
- ignore: {name: "Use camelCase"}
24+
- ignore: {name: "Use uncurry"}
25+
- ignore: {name: "Avoid lambda using `infix`"}
26+
27+
# Gives at least one suggestion we don't like.
28+
- ignore: {name: "Use <=<"}
29+
- ignore: {name: "Use zipFrom"}
30+
- ignore: {name: "Use zipWithFrom"}
31+
32+
# We are using the "redundant" return/pure to assign a name. We do not want to
33+
# delete it. In particular, this is not an improvement:
34+
# Found:
35+
# do options <- somethingComplicated
36+
# pure options
37+
# Perhaps:
38+
# do somethingComplicated
39+
- ignore: {name: "Redundant return"}
40+
- ignore: {name: "Redundant pure"}
41+
42+
# Off by default hints we like
43+
- warn: {name: Use module export list}
44+
45+
# Condemn nub and friends
46+
- warn: {lhs: nub (sort x), rhs: Data.List.Extra.nubSort x}
47+
- warn: {lhs: nub, rhs: Data.List.Extra.nubOrd}
48+
- warn: {lhs: nubBy, rhs: Data.List.Extra.nubOrdBy}
49+
- warn: {lhs: Data.List.Extra.nubOn, rhs: Data.List.Extra.nubOrdOn}
50+
51+
- functions:
52+
# Things that are unsafe in Haskell base library
53+
- name: unsafePerformIO
54+
within:
55+
- Development.IDE.Core.Shake
56+
- Development.IDE.GHC.Util
57+
- Development.IDE.Graph.Internal.Database
58+
- Development.IDE.Graph.Internal.Paths
59+
- Development.IDE.Graph.Internal.Profile
60+
- Ide.Types
61+
- Test.Hls
62+
- Test.Hls.Command
63+
- Wingman.Debug
64+
- Wingman.Types
65+
- AutoTupleSpec
66+
- name: unsafeInterleaveIO
67+
within:
68+
- Development.IDE.LSP.LanguageServer
69+
- {name: unsafeDupablePerformIO, within: []}
70+
- name: unsafeCoerce
71+
within:
72+
- Ide.Plugin.Eval.Code
73+
- Development.IDE.Core.Compile
74+
- Development.IDE.Types.Shake
75+
- Wingman.Judgements.SYB
76+
- Ide.Plugin.Properties
77+
78+
# Things that are a bit dangerous in the GHC API
79+
- name: nameModule
80+
within:
81+
- Development.IDE.GHC.CoreFile
82+
- Ide.Plugin.CallHierarchy.Internal
83+
- Ide.Plugin.Rename
84+
- Compat.HieBin
85+
86+
# Partial functions
87+
- name: Data.List.head
88+
within:
89+
- Main
90+
- Experiments
91+
- Development.IDE.Core.Shake
92+
- Development.IDE.Plugin.CodeAction
93+
- Development.IDE.Plugin.Completions
94+
- Development.IDE.Plugin.CodeAction.ExactPrint
95+
- Development.IDE.Session
96+
- Development.IDE.Spans.Documentation
97+
- Ide.Plugin.CallHierarchy.Internal
98+
- TExpectedActual
99+
- TRigidType
100+
- TRigidType
101+
- Ide.Plugin.Class
102+
- Wingman.Tactics
103+
104+
- name: Data.List.tail
105+
within:
106+
- Main
107+
- Development.Benchmark.Rules
108+
- Development.IDE.Plugin.CodeAction
109+
- Development.IDE.Plugin.CodeAction.ExactPrint
110+
- Development.IDE.Session
111+
- IDE.Plugin.Eval.Code
112+
- IDE.Plugin.Eval.Util
113+
- UnificationSpec
114+
115+
- name: Data.List.last
116+
within:
117+
- GenChangelogs
118+
- Main
119+
120+
- name: Data.List.init
121+
within: []
122+
123+
- name: Data.List.foldl1'
124+
within: []
125+
126+
- name: Data.List.foldr1'
127+
within: []
128+
129+
- name: "Data.List.!!"
130+
within:
131+
- Main
132+
- Experiments
133+
- FunctionalCodeAction
134+
- Development.IDE.Plugin.CodeAction
135+
- Development.IDE.Plugin.Completions.Logic
136+
- Development.IDE.Spans.Documentation
137+
- Wingman.CaseSplit
138+
- Wingman.Simplify
139+
140+
141+
- name: Data.Text.head
142+
within:
143+
- Development.IDE.Plugin.CodeAction
144+
- Development.IDE.Plugin.Completions.Logic
145+
146+
- name: Data.Foldable.foldl1
147+
within: []
148+
149+
- name: Data.Foldable.foldr1
150+
within:
151+
- Wingman.Tactics
152+
153+
- name: Data.Maybe.fromJust
154+
within:
155+
- Experiments
156+
- Main
157+
- MultipleImports
158+
- Progress
159+
- Utils
160+
- Development.IDE.Core.Compile
161+
- Development.IDE.Core.Rules
162+
- Development.IDE.Core.Shake
163+
- Development.IDE.Plugin.Completions
164+
- Development.IDE.Plugin.CodeAction.ExactPrint
165+
- Development.IDE.Test
166+
- Development.IDE.Graph.Internal.Profile
167+
- Development.IDE.Graph.Internal.Rules
168+
- Ide.Plugin.Class
169+
170+
- name: "Data.Map.!"
171+
within:
172+
- Wingman.LanguageServer
173+
174+
- name: "Data.IntMap.!"
175+
within: []
176+
177+
- name: "Data.Vector.!"
178+
within: []
179+
180+
- name: "GHC.Arr.!"
181+
within: []
182+
183+
# We really do not want novel usages of restricted functions, and mere
184+
# Warning is not enough to prevent those consistently; you need a build failure.
185+
- error: {name: Avoid restricted function}

ghcide/.hlint.yaml

-180
This file was deleted.

plugins/hls-hlint-plugin/.hlint.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This is here so that the tests in this package don't
2+
# pick up the configuration from HLS's own .hlint.yaml
+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
module WError where
2+
{-# ANN module "HLint: ignore" #-}
23
main = undefined

0 commit comments

Comments
 (0)