Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -Wall and -Wunused-packages in hlint plugin #4019

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ flag cabal

common cabal
if flag(cabal)
build-depends: haskell-language-server:hls-cabal-plugin
build-depends: haskell-language-server:hls-cabal-plugin
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the noise, but I have editor setup to remove trailing whitespace. I don't think it hurts to clean these up as part of this PR.

cpp-options: -Dhls_cabal

library hls-cabal-plugin
Expand Down Expand Up @@ -223,7 +223,7 @@ flag class

common class
if flag(class)
build-depends: haskell-language-server:hls-class-plugin
build-depends: haskell-language-server:hls-class-plugin
cpp-options: -Dhls_class

library hls-class-plugin
Expand Down Expand Up @@ -284,7 +284,7 @@ flag callHierarchy

common callHierarchy
if flag(callHierarchy)
build-depends: haskell-language-server:hls-call-hierarchy-plugin
build-depends: haskell-language-server:hls-call-hierarchy-plugin
cpp-options: -Dhls_callHierarchy

library hls-call-hierarchy-plugin
Expand Down Expand Up @@ -342,7 +342,7 @@ flag eval

common eval
if flag(eval)
build-depends: haskell-language-server:hls-eval-plugin
build-depends: haskell-language-server:hls-eval-plugin
cpp-options: -Dhls_eval

library hls-eval-plugin
Expand Down Expand Up @@ -480,7 +480,7 @@ flag rename

common rename
if flag(rename)
build-depends: haskell-language-server:hls-rename-plugin
build-depends: haskell-language-server:hls-rename-plugin
cpp-options: -Dhls_rename

library hls-rename-plugin
Expand Down Expand Up @@ -535,7 +535,7 @@ flag retrie

common retrie
if flag(retrie)
build-depends: haskell-language-server:hls-retrie-plugin
build-depends: haskell-language-server:hls-retrie-plugin
cpp-options: -Dhls_retrie

library hls-retrie-plugin
Expand Down Expand Up @@ -596,7 +596,7 @@ flag hlint

common hlint
if flag(hlint) && (impl(ghc < 9.8.0) || flag(ignore-plugins-ghc-bounds))
build-depends: haskell-language-server:hls-hlint-plugin
build-depends: haskell-language-server:hls-hlint-plugin
cpp-options: -Dhls_hlint

library hls-hlint-plugin
Expand All @@ -606,16 +606,10 @@ library hls-hlint-plugin
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 Down Expand Up @@ -669,7 +663,7 @@ flag stan

common stan
if flag(stan) && (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.10.0))
build-depends: haskell-language-server:hls-stan-plugin
build-depends: haskell-language-server:hls-stan-plugin
cpp-options: -Dhls_stan

library hls-stan-plugin
Expand Down Expand Up @@ -742,7 +736,7 @@ flag moduleName

common moduleName
if flag(moduleName)
build-depends: haskell-language-server:hls-module-name-plugin
build-depends: haskell-language-server:hls-module-name-plugin
cpp-options: -Dhls_moduleName

library hls-module-name-plugin
Expand Down Expand Up @@ -784,7 +778,7 @@ flag pragmas

common pragmas
if flag(pragmas)
build-depends: haskell-language-server:hls-pragmas-plugin
build-depends: haskell-language-server:hls-pragmas-plugin
cpp-options: -Dhls_pragmas

library hls-pragmas-plugin
Expand Down Expand Up @@ -829,7 +823,7 @@ flag splice

common splice
if flag(splice)
build-depends: haskell-language-server:hls-splice-plugin
build-depends: haskell-language-server:hls-splice-plugin
cpp-options: -Dhls_splice

library hls-splice-plugin
Expand Down Expand Up @@ -1001,7 +995,7 @@ flag codeRange

common codeRange
if flag(codeRange)
build-depends: haskell-language-server:hls-code-range-plugin
build-depends: haskell-language-server:hls-code-range-plugin
cpp-options: -Dhls_codeRange

library hls-code-range-plugin
Expand Down Expand Up @@ -1058,7 +1052,7 @@ flag changeTypeSignature

common changeTypeSignature
if flag(changeTypeSignature)
build-depends: haskell-language-server:hls-change-type-signature-plugin
build-depends: haskell-language-server:hls-change-type-signature-plugin
cpp-options: -Dhls_changeTypeSignature

library hls-change-type-signature-plugin
Expand Down Expand Up @@ -1115,7 +1109,7 @@ flag gadt

common gadt
if flag(gadt)
build-depends: haskell-language-server:hls-gadt-plugin
build-depends: haskell-language-server:hls-gadt-plugin
cpp-options: -Dhls_gadt

library hls-gadt-plugin
Expand Down Expand Up @@ -1165,7 +1159,7 @@ flag explicitFixity

common explicitFixity
if flag(explicitFixity)
build-depends: haskell-language-server:hls-explicit-fixity-plugin
build-depends: haskell-language-server:hls-explicit-fixity-plugin
cpp-options: -DexplicitFixity

library hls-explicit-fixity-plugin
Expand Down Expand Up @@ -1209,7 +1203,7 @@ flag explicitFields

common explicitFields
if flag(explicitFields)
build-depends: haskell-language-server:hls-explicit-record-fields-plugin
build-depends: haskell-language-server:hls-explicit-record-fields-plugin
cpp-options: -DexplicitFields

library hls-explicit-record-fields-plugin
Expand All @@ -1231,7 +1225,7 @@ library hls-explicit-record-fields-plugin

if flag(pedantic)
ghc-options: -Wwarn=incomplete-record-updates

test-suite hls-explicit-record-fields-plugin-tests
import: defaults, test-defaults, warnings
type: exitcode-stdio-1.0
Expand All @@ -1255,7 +1249,7 @@ flag overloadedRecordDot

common overloadedRecordDot
if flag(overloadedRecordDot)
build-depends: haskell-language-server:hls-overloaded-record-dot-plugin
build-depends: haskell-language-server:hls-overloaded-record-dot-plugin
cpp-options: -Dhls_overloaded_record_dot

library hls-overloaded-record-dot-plugin
Expand Down Expand Up @@ -1302,7 +1296,7 @@ flag floskell

common floskell
if flag(floskell) && (impl(ghc < 9.7) || flag(ignore-plugins-ghc-bounds))
build-depends: haskell-language-server:hls-floskell-plugin
build-depends: haskell-language-server:hls-floskell-plugin
cpp-options: -Dhls_floskell

library hls-floskell-plugin
Expand Down Expand Up @@ -1341,7 +1335,7 @@ flag fourmolu

common fourmolu
if flag(fourmolu)
build-depends: haskell-language-server:hls-fourmolu-plugin
build-depends: haskell-language-server:hls-fourmolu-plugin
cpp-options: -Dhls_fourmolu

library hls-fourmolu-plugin
Expand Down Expand Up @@ -1391,7 +1385,7 @@ flag ormolu

common ormolu
if flag(ormolu)
build-depends: haskell-language-server:hls-ormolu-plugin
build-depends: haskell-language-server:hls-ormolu-plugin
cpp-options: -Dhls_ormolu

library hls-ormolu-plugin
Expand Down Expand Up @@ -1441,7 +1435,7 @@ flag stylishHaskell

common stylishHaskell
if flag(stylishHaskell) && (impl(ghc < 9.8.0) || flag(ignore-plugins-ghc-bounds))
build-depends: haskell-language-server:hls-stylish-haskell-plugin
build-depends: haskell-language-server:hls-stylish-haskell-plugin
cpp-options: -Dhls_stylishHaskell

library hls-stylish-haskell-plugin
Expand Down Expand Up @@ -1483,7 +1477,7 @@ flag refactor

common refactor
if flag(refactor)
build-depends: haskell-language-server:hls-refactor-plugin
build-depends: haskell-language-server:hls-refactor-plugin
cpp-options: -Dhls_refactor

library hls-refactor-plugin
Expand Down Expand Up @@ -1561,7 +1555,7 @@ test-suite hls-refactor-plugin-tests
hs-source-dirs: plugins/hls-refactor-plugin/test
main-is: Main.hs
other-modules: Test.AddArgument
ghc-options: -O0
ghc-options: -O0
build-depends:
, base
, filepath
Expand Down Expand Up @@ -1596,7 +1590,7 @@ flag semanticTokens

common semanticTokens
if flag(semanticTokens)
build-depends: haskell-language-server:hls-semantic-tokens-plugin
build-depends: haskell-language-server:hls-semantic-tokens-plugin
cpp-options: -Dhls_semanticTokens

library hls-semantic-tokens-plugin
Expand Down Expand Up @@ -1854,7 +1848,7 @@ test-suite func-test
type: exitcode-stdio-1.0
build-tool-depends:
haskell-language-server:haskell-language-server,
ghcide:ghcide-test-preprocessor
ghcide:ghcide-test-preprocessor

build-depends:
, bytestring
Expand Down Expand Up @@ -1907,7 +1901,7 @@ test-suite wrapper-test
type: exitcode-stdio-1.0
build-tool-depends:
haskell-language-server:haskell-language-server-wrapper,
haskell-language-server:haskell-language-server
haskell-language-server:haskell-language-server

build-depends:
process
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
Loading