File: hint.test

package info (click to toggle)
hlint 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 980 kB
  • sloc: haskell: 7,035; lisp: 86; makefile: 5
file content (241 lines) | stat: -rw-r--r-- 7,098 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
---------------------------------------------------------------------
RUN tests/newtype-derive.hs --hint=data/hlint.yaml
FILE tests/newtype-derive.hs
{-# LANGUAGE DeriveTraversable #-} -- Implies DeriveFoldable and DeriveFunctor
{-# LANGUAGE DeriveDataTypeable #-}
module Test(A) where

import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
import Data.Typeable (Typeable)

newtype A f = A f
  deriving (Foldable, Functor, Traversable, Typeable)
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/note.hs
FILE tests/note.hs
{-# LANGUAGE RecordWildCards #-}

module Sample(test) where

test xs = length xs == 0
OUTPUT
tests/note.hs:1:1-32: Warning: Unused LANGUAGE pragma
Found:
  {-# LANGUAGE RecordWildCards #-}
Perhaps you should remove it.
Note: may require `{-# LANGUAGE DisambiguateRecordFields #-}` adding to the top of the file

tests/note.hs:5:11-24: Suggestion: Use null
Found:
  length xs == 0
Perhaps:
  null xs
Note: increases laziness

2 hints

---------------------------------------------------------------------
RUN tests/brackets.hs
FILE tests/brackets.hs
test = if isNothing x then (-1.0) else fromJust x
OUTPUT
tests/brackets.hs:1:8-49: Warning: Use fromMaybe
Found:
  if isNothing x then (- 1.0) else fromJust x
Perhaps:
  fromMaybe (- 1.0) x

1 hint

---------------------------------------------------------------------
RUN tests/typesig-ignore.hs
FILE tests/typesig-ignore.hs
-- Bug #563
module Foo(foobar) where
{-# ANN foobar "HLint: ignore Use String" #-}

foobar :: [Char]
foobar = []
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/typesig-ignore2.hs
FILE tests/typesig-ignore2.hs
-- Bug #563
module Foo(foobar) where
{-# HLINT ignore foobar "Use String" #-}

foobar :: [Char]
foobar = []
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/restricted-module.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-module.lhs
> import Restricted.Module
OUTPUT
tests/restricted-module.lhs:1:3-26: Warning: Avoid restricted module
Found:
  import Restricted.Module
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-module-message.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-module-message.lhs
> import Restricted.Module.Message
OUTPUT
tests/restricted-module-message.lhs:1:3-34: Warning: Avoid restricted module
Found:
  import Restricted.Module.Message
Note: Custom message

1 hint

---------------------------------------------------------------------
RUN tests/restricted-badidents-bad.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-badidents-bad.lhs
> import Restricted.Module.BadIdents (bad)
OUTPUT
tests/restricted-badidents-bad.lhs:1:3-42: Warning: Avoid restricted identifiers
Found:
  import Restricted.Module.BadIdents ( bad )
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-badidents-multibad.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-badidents-multibad.lhs
> import Restricted.Module.BadIdents (bad, good)
OUTPUT
tests/restricted-badidents-multibad.lhs:1:3-48: Warning: Avoid restricted identifiers
Found:
  import Restricted.Module.BadIdents ( bad, good )
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-badidents-valid.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-badidents-valid.lhs
> import Restricted.Module.BadIdents (good)
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/restricted-badidents-universal.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-badidents-universal.lhs
> import Restricted.Module.BadIdents
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/restricted-onlyidents-bad.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-onlyidents-bad.lhs
> import Restricted.Module.OnlyIdents (bad)
OUTPUT
tests/restricted-onlyidents-bad.lhs:1:3-43: Warning: Avoid restricted identifiers
Found:
  import Restricted.Module.OnlyIdents ( bad )
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-onlyidents-multibad.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-onlyidents-multibad.lhs
> import Restricted.Module.OnlyIdents (bad, good)
OUTPUT
tests/restricted-onlyidents-multibad.lhs:1:3-49: Warning: Avoid restricted identifiers
Found:
  import Restricted.Module.OnlyIdents ( bad, good )
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-onlyidents-valid.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-onlyidents-valid.lhs
> import Restricted.Module.OnlyIdents (good)
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/restricted-onlyidents-universal.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-onlyidents-universal.lhs
> import Restricted.Module.OnlyIdents
OUTPUT
No hints

---------------------------------------------------------------------
RUN tests/restricted-function.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-function.lhs
> main = restricted ()
OUTPUT
tests/restricted-function.lhs:1:10-19: Warning: Avoid restricted function
Found:
  restricted
Note: may break the code

1 hint

---------------------------------------------------------------------
RUN tests/restricted-function-message.lhs --hint=data/test-restrict.yaml
FILE tests/restricted-function-message.lhs
> main = restrictedMessage ()
OUTPUT
tests/restricted-function-message.lhs:1:10-26: Warning: Avoid restricted function
Found:
  restrictedMessage
Note: Custom message

1 hint

---------------------------------------------------------------------
RUN tests/restricted-extension.hs --hint=data/test-restrict.yaml
FILE tests/restricted-extension.hs
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Test(A) where

import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
import Data.Typeable (Typeable)

newtype A f = A f
  deriving (Foldable, Functor, Traversable, Typeable)
OUTPUT
OUTPUT
tests/restricted-extension.hs:1:1-31: Warning: Unused LANGUAGE pragma
Found:
  {-# LANGUAGE DeriveFoldable #-}
Perhaps you should remove it.
Note: Extension DeriveFoldable is implied by DeriveTraversable

tests/restricted-extension.hs:2:1-30: Warning: Unused LANGUAGE pragma
Found:
  {-# LANGUAGE DeriveFunctor #-}
Perhaps you should remove it.
Note: Extension DeriveFunctor is implied by DeriveTraversable

tests/restricted-extension.hs:2:1-30: Warning: Avoid restricted extensions
Found:
  {-# LANGUAGE DeriveFunctor #-}
Note: may break the code

tests/restricted-extension.hs:3:1-34: Warning: Avoid restricted extensions
Found:
  {-# LANGUAGE DeriveTraversable #-}
Note: Custom message

4 hints