Skip to content

Commit 8ae28bf

Browse files
committed
Fix -Wall and -Wunused-packages in hlint plugin
1 parent 4f473a9 commit 8ae28bf

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

plugins/hls-hlint-plugin/hls-hlint-plugin.cabal

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ flag pedantic
2929
default: False
3030
manual: True
3131

32+
common warnings
33+
ghc-options:
34+
-Wall -Wredundant-constraints -Wunused-packages
35+
-Wno-name-shadowing -Wno-unticked-promoted-constructors
36+
3237
library
38+
import: warnings
3339
exposed-modules: Ide.Plugin.Hlint
3440
hs-source-dirs: src
3541
build-depends:
3642
, aeson
3743
, base >=4.12 && <5
38-
, binary
3944
, bytestring
4045
, containers
41-
, data-default
4246
, deepseq
43-
, Diff ^>=0.4.0
44-
, directory
45-
, extra
4647
, filepath
47-
, ghc-exactprint >=0.6.3.4
4848
, ghcide == 2.6.0.0
4949
, hashable
5050
, hlint >= 3.5 && < 3.9
@@ -64,9 +64,6 @@ library
6464
, apply-refact
6565

6666
cpp-options: -DHLINT_ON_GHC_LIB
67-
ghc-options:
68-
-Wall -Wredundant-constraints -Wno-name-shadowing
69-
-Wno-unticked-promoted-constructors
7067

7168
if flag(pedantic)
7269
ghc-options: -Werror
@@ -77,6 +74,7 @@ library
7774
TypeOperators
7875

7976
test-suite tests
77+
import: warnings
8078
type: exitcode-stdio-1.0
8179
default-language: Haskell2010
8280
hs-source-dirs: test

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
{-# LANGUAGE ScopedTypeVariables #-}
1717
{-# LANGUAGE StrictData #-}
1818
{-# LANGUAGE TupleSections #-}
19-
{-# LANGUAGE TypeApplications #-}
2019
{-# LANGUAGE TypeFamilies #-}
2120
{-# LANGUAGE ViewPatterns #-}
2221
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -142,8 +141,7 @@ import Development.IDE.Spans.Pragmas (LineSplitTe
142141
lineSplitTextEdits,
143142
nextPragmaLine)
144143
import GHC.Generics (Generic)
145-
#if MIN_VERSION_apply_refact(0,12,0)
146-
#else
144+
#if !MIN_VERSION_apply_refact(0,12,0)
147145
import System.Environment (setEnv,
148146
unsetEnv)
149147
#endif

plugins/hls-hlint-plugin/test/Main.hs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ module Main
99

1010
import Control.Lens ((^.))
1111
import Control.Monad (when)
12-
import Data.Aeson (Value (..), object, toJSON, (.=))
12+
import Data.Aeson (Value (..), object, (.=))
1313
import Data.Functor (void)
1414
import Data.List (find)
1515
import qualified Data.Map as Map
1616
import Data.Maybe (fromJust, isJust)
1717
import Data.Row ((.+), (.==))
1818
import qualified Data.Text as T
19-
import Ide.Plugin.Config (Config (..), PluginConfig (..))
19+
import Ide.Plugin.Config (Config (..))
2020
import qualified Ide.Plugin.Config as Plugin
2121
import qualified Ide.Plugin.Hlint as HLint
22-
import Ide.Types (PluginId)
2322
import qualified Language.LSP.Protocol.Lens as L
2423
import System.FilePath ((</>))
2524
import Test.Hls
@@ -383,10 +382,6 @@ data Point = Point {
383382
column :: !Int
384383
}
385384

386-
makePoint line column
387-
| line >= 1 && column >= 1 = Point line column
388-
| otherwise = error "Line or column is less than 1."
389-
390385
pointToRange :: Point -> Range
391386
pointToRange Point {..}
392387
| line <- fromIntegral $ subtract 1 line
@@ -402,10 +397,6 @@ makeCodeActionNotFoundAtString :: Point -> String
402397
makeCodeActionNotFoundAtString Point {..} =
403398
"CodeAction not found at line: " <> show line <> ", column: " <> show column
404399

405-
makeCodeActionFoundAtString :: Point -> String
406-
makeCodeActionFoundAtString Point {..} =
407-
"CodeAction found at line: " <> show line <> ", column: " <> show column
408-
409400
ignoreHintGoldenTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
410401
ignoreHintGoldenTest testCaseName goldenFilename point hintName =
411402
goldenTest testCaseName goldenFilename point (getIgnoreHintText hintName)
@@ -417,7 +408,7 @@ applyHintGoldenTest testCaseName goldenFilename point hintName = do
417408
goldenTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
418409
goldenTest testCaseName goldenFilename point hintText =
419410
setupGoldenHlintTest testCaseName goldenFilename $ \document -> do
420-
waitForDiagnosticsFromSource document "hlint"
411+
_ <- waitForDiagnosticsFromSource document "hlint"
421412
actions <- getCodeActions document $ pointToRange point
422413
case find ((== Just hintText) . getCodeActionTitle) actions of
423414
Just (InR codeAction) -> do
@@ -441,7 +432,7 @@ applyHintGoldenResolveTest testCaseName goldenFilename point hintName = do
441432
goldenResolveTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
442433
goldenResolveTest testCaseName goldenFilename point hintText =
443434
setupGoldenHlintResolveTest testCaseName goldenFilename $ \document -> do
444-
waitForDiagnosticsFromSource document "hlint"
435+
_ <- waitForDiagnosticsFromSource document "hlint"
445436
actions <- getAndResolveCodeActions document $ pointToRange point
446437
case find ((== Just hintText) . getCodeActionTitle) actions of
447438
Just (InR codeAction) -> executeCodeAction codeAction

0 commit comments

Comments
 (0)