Skip to content

Commit a32db0b

Browse files
Hlint more partial functions, and Debug.Trace (#3000)
* Add partial functions under alternative import names * Ban tracing functions also Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 1bc1def commit a32db0b

File tree

2 files changed

+87
-4
lines changed

2 files changed

+87
-4
lines changed

.hlint.yaml

+87-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@
8484
- Compat.HieBin
8585

8686
# Partial functions
87+
88+
# For some reason we need to check fucntions which
89+
# are typically exported multiple ways under both names,
90+
# see https://github.com/ndmitchell/hlint/issues/1389
91+
- name: Prelude.head
92+
within:
93+
- Main
94+
- Development.Benchmark.Rules
95+
- Development.IDE.Plugin.CodeAction
96+
- Development.IDE.Plugin.Completions
97+
- Development.IDE.Plugin.CodeAction.ExactPrint
98+
- Development.IDE.Spans.Documentation
99+
- Ide.Plugin.CallHierarchy.Internal
100+
- Ide.Plugin.Eval.Code
101+
- Ide.Plugin.Eval.Util
102+
- Ide.Plugin.Floskell
103+
- Ide.Plugin.ModuleName
104+
- Ide.Plugin.Rename
105+
- Ide.Plugin.Class.ExactPrint
106+
- TExpectedActual
107+
- TRigidType
108+
- RightToLeftFixities
109+
- Typeclass
110+
- Wingman.Judgements
111+
- Wingman.Machinery
112+
87113
- name: Data.List.head
88114
within:
89115
- Main
@@ -94,11 +120,18 @@
94120
- Development.IDE.Session
95121
- Development.IDE.Spans.Documentation
96122
- Ide.Plugin.CallHierarchy.Internal
97-
- TExpectedActual
98-
- TRigidType
99-
- TRigidType
100123
- Ide.Plugin.Class
101124
- Wingman.Tactics
125+
- TExpectedActual
126+
- TRigidType
127+
128+
- name: Prelude.tail
129+
within:
130+
- Main
131+
- Development.Benchmark.Rules
132+
- Development.IDE.Plugin.CodeAction
133+
- Development.IDE.Plugin.CodeAction.ExactPrint
134+
- UnificationSpec
102135

103136
- name: Data.List.tail
104137
within:
@@ -111,11 +144,31 @@
111144
- IDE.Plugin.Eval.Util
112145
- UnificationSpec
113146

147+
- name: Prelude.last
148+
within:
149+
- Main
150+
- Development.IDE.Plugin.CodeAction
151+
- Development.IDE.Plugin.CodeAction.ExactPrint
152+
- Development.IDE.Spans.Common
153+
- Development.IDE.Graph.Internal.Types
154+
- Ide.PluginUtils
155+
- Ide.Plugin.Eval.Parse.Comments
156+
- Ide.Plugin.Eval.CodeLens
157+
114158
- name: Data.List.last
115159
within:
116160
- GenChangelogs
117161
- Main
118162

163+
- name: Prelude.init
164+
within:
165+
- Main
166+
- Development.IDE.Spans.Common
167+
- Ide.PluginUtils
168+
- Wingman.Metaprogramming.Parser
169+
- Development.Benchmark.Rules
170+
- ErrorGivenPartialSignature
171+
119172
- name: Data.List.init
120173
within: []
121174

@@ -125,6 +178,16 @@
125178
- name: Data.List.foldr1'
126179
within: []
127180

181+
- name: "Prelude.!!"
182+
within:
183+
- Main
184+
- Development.IDE.Plugin.CodeAction
185+
- Development.IDE.Plugin.Completions.Logic
186+
- Development.IDE.Spans.Documentation
187+
- TErrorGivenPartialSignature
188+
- Wingman.CaseSplit
189+
- Wingman.Simplify
190+
128191
- name: "Data.List.!!"
129192
within:
130193
- Main
@@ -178,6 +241,27 @@
178241
- name: "GHC.Arr.!"
179242
within: []
180243

244+
# Tracing functions
245+
# We ban an explicit list rather than the
246+
# Debug.Trace, because that module also
247+
# includes the eventlog tracing functions,
248+
# which are legitimate to use.
249+
- name:
250+
- Debug.Trace.trace
251+
- Debug.Trace.traceId
252+
- Debug.Trace.traceShow
253+
- Debug.Trace.traceShowId
254+
- Debug.Trace.traceStack
255+
- Debug.Trace.traceIO
256+
- Debug.Trace.traceM
257+
- Debug.Trace.traceShowM
258+
- Debug.Trace.putTraceMsg
259+
within:
260+
- Development.IDE.Core.Compile
261+
- Development.IDE.Graph.Internal.Database
262+
- Development.IDE.GHC.Util
263+
- Wingman.Debug
264+
181265
# We really do not want novel usages of restricted functions, and mere
182266
# Warning is not enough to prevent those consistently; you need a build failure.
183267
- error: {name: Avoid restricted function}

plugins/hls-alternate-number-format-plugin/test/Main.hs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Data.Either (rights)
77
import Data.List (find)
88
import Data.Text (Text)
99
import qualified Data.Text as T
10-
import Debug.Trace
1110
import qualified Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat
1211
import qualified Ide.Plugin.Conversion as Conversion
1312
import Language.LSP.Types (toEither)

0 commit comments

Comments
 (0)