Skip to content

Commit

Permalink
Fix -Wall and -Wunused-packages in hlint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrcek committed Feb 1, 2024
1 parent 90eed1a commit a92f44a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
11 changes: 2 additions & 9 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,16 @@ common hlint
cpp-options: -Dhls_hlint

library hls-hlint-plugin
import: warnings
exposed-modules: Ide.Plugin.Hlint
hs-source-dirs: plugins/hls-hlint-plugin/src
build-depends:
, aeson
, base >=4.12 && <5
, binary
, bytestring
, containers
, data-default
, deepseq
, Diff ^>=0.4.0
, directory
, extra
, filepath
, ghc-exactprint >=0.6.3.4
, ghcide == 2.6.0.0
, hashable
, hlint >= 3.5 && < 3.9
Expand All @@ -653,9 +648,6 @@ library hls-hlint-plugin
, apply-refact

cpp-options: -DHLINT_ON_GHC_LIB
ghc-options:
-Wall -Wredundant-constraints -Wno-name-shadowing
-Wno-unticked-promoted-constructors

if flag(pedantic)
ghc-options: -Werror
Expand All @@ -666,6 +658,7 @@ library hls-hlint-plugin
TypeOperators

test-suite hls-hlint-plugin-tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: plugins/hls-hlint-plugin/test
Expand Down
4 changes: 1 addition & 3 deletions plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
Expand Down Expand Up @@ -142,8 +141,7 @@ import Development.IDE.Spans.Pragmas (LineSplitTe
lineSplitTextEdits,
nextPragmaLine)
import GHC.Generics (Generic)
#if MIN_VERSION_apply_refact(0,12,0)
#else
#if !MIN_VERSION_apply_refact(0,12,0)
import System.Environment (setEnv,
unsetEnv)
#endif
Expand Down
17 changes: 4 additions & 13 deletions plugins/hls-hlint-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ module Main

import Control.Lens ((^.))
import Control.Monad (when)
import Data.Aeson (Value (..), object, toJSON, (.=))
import Data.Aeson (Value (..), object, (.=))
import Data.Functor (void)
import Data.List (find)
import qualified Data.Map as Map
import Data.Maybe (fromJust, isJust)
import Data.Row ((.+), (.==))
import qualified Data.Text as T
import Ide.Plugin.Config (Config (..), PluginConfig (..))
import Ide.Plugin.Config (Config (..))
import qualified Ide.Plugin.Config as Plugin
import qualified Ide.Plugin.Hlint as HLint
import Ide.Types (PluginId)
import qualified Language.LSP.Protocol.Lens as L
import System.FilePath ((</>))
import Test.Hls
Expand Down Expand Up @@ -383,10 +382,6 @@ data Point = Point {
column :: !Int
}

makePoint line column
| line >= 1 && column >= 1 = Point line column
| otherwise = error "Line or column is less than 1."

pointToRange :: Point -> Range
pointToRange Point {..}
| line <- fromIntegral $ subtract 1 line
Expand All @@ -402,10 +397,6 @@ makeCodeActionNotFoundAtString :: Point -> String
makeCodeActionNotFoundAtString Point {..} =
"CodeAction not found at line: " <> show line <> ", column: " <> show column

makeCodeActionFoundAtString :: Point -> String
makeCodeActionFoundAtString Point {..} =
"CodeAction found at line: " <> show line <> ", column: " <> show column

ignoreHintGoldenTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
ignoreHintGoldenTest testCaseName goldenFilename point hintName =
goldenTest testCaseName goldenFilename point (getIgnoreHintText hintName)
Expand All @@ -417,7 +408,7 @@ applyHintGoldenTest testCaseName goldenFilename point hintName = do
goldenTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
goldenTest testCaseName goldenFilename point hintText =
setupGoldenHlintTest testCaseName goldenFilename $ \document -> do
waitForDiagnosticsFromSource document "hlint"
_ <- waitForDiagnosticsFromSource document "hlint"
actions <- getCodeActions document $ pointToRange point
case find ((== Just hintText) . getCodeActionTitle) actions of
Just (InR codeAction) -> do
Expand All @@ -441,7 +432,7 @@ applyHintGoldenResolveTest testCaseName goldenFilename point hintName = do
goldenResolveTest :: TestName -> FilePath -> Point -> T.Text -> TestTree
goldenResolveTest testCaseName goldenFilename point hintText =
setupGoldenHlintResolveTest testCaseName goldenFilename $ \document -> do
waitForDiagnosticsFromSource document "hlint"
_ <- waitForDiagnosticsFromSource document "hlint"
actions <- getAndResolveCodeActions document $ pointToRange point
case find ((== Just hintText) . getCodeActionTitle) actions of
Just (InR codeAction) -> executeCodeAction codeAction
Expand Down

0 comments on commit a92f44a

Please sign in to comment.