From 49857931373f60676d8475c41c4ba2e0edf296ac Mon Sep 17 00:00:00 2001 From: Jan Hrcek <2716069+jhrcek@users.noreply.github.com> Date: Mon, 13 May 2024 11:10:32 +0200 Subject: [PATCH] Actually enable pedantic flag in ci flags job (#4224) * Actually enable pedantic flag in ci flags job * Address reviwe comments * Fixes after rebase * Tweak warning configs --- .github/workflows/flags.yml | 6 +-- .hlint.yaml | 1 - ghcide/exe/Main.hs | 3 -- ghcide/test/exe/DiagnosticTests.hs | 6 +-- ghcide/test/exe/TestUtils.hs | 43 ++++++++----------- haskell-language-server.cabal | 37 ++++++++-------- hls-test-utils/hls-test-utils.cabal | 6 ++- .../src/Ide/Plugin/Literals.hs | 3 +- plugins/hls-class-plugin/test/Main.hs | 1 - .../src/Ide/Plugin/Eval/Parse/Comments.hs | 2 +- .../src/Development/IDE/Plugin/CodeAction.hs | 13 +++--- 11 files changed, 56 insertions(+), 65 deletions(-) diff --git a/.github/workflows/flags.yml b/.github/workflows/flags.yml index 1b9c46210a..111dbd40a7 100644 --- a/.github/workflows/flags.yml +++ b/.github/workflows/flags.yml @@ -76,10 +76,10 @@ jobs: - name: Configue non-default flags for all components run: | cabal configure \ - --constraint "hls-graph +embed-files +stm-stats" \ + --constraint "haskell-language-server +pedantic" \ + --constraint "hls-graph +embed-files +pedantic +stm-stats" \ --constraint "ghcide +ekg +executable +test-exe" \ - --constraint "hls-plugin-api -use-fingertree" \ - --constraint "all +pedantic" + --constraint "hls-plugin-api +pedantic -use-fingertree" cat cabal.project.local - name: Build everything with non-default flags diff --git a/.hlint.yaml b/.hlint.yaml index 89b65dfc24..0bf0e0a313 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -94,7 +94,6 @@ - Main - Experiments - Development.Benchmark.Rules - - Development.IDE.Plugin.CodeAction - Development.IDE.Plugin.Completions - Development.IDE.Plugin.CodeAction.ExactPrint - Development.IDE.Spans.Documentation diff --git a/ghcide/exe/Main.hs b/ghcide/exe/Main.hs index 3344648150..b3b63fbaf5 100644 --- a/ghcide/exe/Main.hs +++ b/ghcide/exe/Main.hs @@ -6,14 +6,11 @@ module Main(main) where import Arguments (Arguments (..), getArguments) -import Control.Monad.Extra (unless) import Control.Monad.IO.Class (liftIO) import Data.Default (def) import Data.Function ((&)) import Data.Version (showVersion) import Development.GitRev (gitHash) -import Development.IDE (action) -import Development.IDE.Core.OfInterest (kick) import Development.IDE.Core.Rules (mainRule) import qualified Development.IDE.Core.Rules as Rules import Development.IDE.Core.Tracing (withTelemetryRecorder) diff --git a/ghcide/test/exe/DiagnosticTests.hs b/ghcide/test/exe/DiagnosticTests.hs index c0678aaf18..1c5adff70d 100644 --- a/ghcide/test/exe/DiagnosticTests.hs +++ b/ghcide/test/exe/DiagnosticTests.hs @@ -36,10 +36,8 @@ import Control.Monad.Extra (whenJust) import Data.Default (def) import Development.IDE.Plugin.Test (WaitForIdeRuleResult (..)) import System.Time.Extra -import Test.Hls (runSessionWithServer', - runSessionWithServerInTmpDirCont, - waitForProgressBegin, - waitForTypecheck) +import Test.Hls (runSessionWithServerInTmpDirCont, + waitForProgressBegin) import Test.Hls.FileSystem (directCradle, file, text, toAbsFp) import Test.Tasty diff --git a/ghcide/test/exe/TestUtils.hs b/ghcide/test/exe/TestUtils.hs index 60c98b5a41..0b9ce03eb2 100644 --- a/ghcide/test/exe/TestUtils.hs +++ b/ghcide/test/exe/TestUtils.hs @@ -1,46 +1,37 @@ - {-# LANGUAGE GADTs #-} module TestUtils where -import Control.Applicative.Combinators import Control.Concurrent.Async -import Control.Exception (bracket_, finally) -import Control.Lens ((.~)) -import qualified Control.Lens as Lens -import qualified Control.Lens.Extras as Lens -import Control.Monad +import Control.Exception (bracket_, finally) import Data.Foldable -import Data.Function ((&)) import Data.Maybe -import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion) -import qualified Development.IDE.Main as IDE -import Development.IDE.Test (configureCheckProject, - expectNoMoreDiagnostics) +import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion) +import qualified Development.IDE.Main as IDE +import Development.IDE.Test (configureCheckProject, + expectNoMoreDiagnostics) import Development.IDE.Test.Runfiles import Development.IDE.Types.Location -import Development.Shake (getDirectoryFilesIO) -import Ide.Logger (Recorder, WithPriority, - cmapWithPrio) -import qualified Language.LSP.Protocol.Lens as L -import Language.LSP.Protocol.Message -import Language.LSP.Protocol.Types hiding - (SemanticTokenAbsolute (..), - SemanticTokenRelative (..), - SemanticTokensEdit (..), - mkRange) +import Development.Shake (getDirectoryFilesIO) +import Ide.Logger (Recorder, WithPriority, + cmapWithPrio) +import Language.LSP.Protocol.Types hiding + (SemanticTokenAbsolute (..), + SemanticTokenRelative (..), + SemanticTokensEdit (..), + mkRange) import Language.LSP.Test import System.Directory -import System.Environment.Blank (getEnv, setEnv, unsetEnv) +import System.Environment.Blank (getEnv, setEnv, unsetEnv) import System.FilePath -import System.Info.Extra (isMac, isWindows) +import System.Info.Extra (isMac, isWindows) import qualified System.IO.Extra -import System.Process.Extra (createPipe) +import System.Process.Extra (createPipe) import Test.Tasty import Test.Tasty.ExpectedFailure import Test.Tasty.HUnit -import Config (lspTestCaps) +import Config (lspTestCaps) import LogType diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index bbe36a733a..5f673caafe 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -44,7 +44,10 @@ common defaults default-extensions: ExplicitNamespaces common test-defaults - ghc-options: -threaded -rtsopts -with-rtsopts=-N + ghc-options: -threaded -rtsopts -with-rtsopts=-N + if impl(ghc >= 9.8) + -- We allow using partial functions in tests + ghc-options: -Wno-x-partial -- Default warnings in HLS common warnings @@ -1676,25 +1679,23 @@ test-suite hls-refactor-plugin-tests ghc-options: -O0 build-depends: , base + , data-default + , directory + , extra , filepath + , ghcide:ghcide , haskell-language-server:hls-refactor-plugin , hls-test-utils == 2.8.0.0 , lens + , lsp-test , lsp-types - , text - , hls-plugin-api , parser-combinators - , data-default - , extra - , ghcide:ghcide - , shake - , hls-plugin-api - , lsp-test - , directory , regex-tdfa - , tasty-hunit - , tasty-expected-failure + , shake , tasty + , tasty-expected-failure + , tasty-hunit + , text ----------------------------- -- semantic tokens plugin @@ -1763,19 +1764,17 @@ test-suite hls-semantic-tokens-plugin-tests , aeson , base , containers + , data-default , filepath + , ghcide == 2.8.0.0 , haskell-language-server:hls-semantic-tokens-plugin - , hls-test-utils == 2.8.0.0 - , hls-plugin-api + , hls-plugin-api == 2.8.0.0 + , hls-test-utils == 2.8.0.0 , lens , lsp - , text-rope , lsp-test , text - , data-default - , ghcide == 2.8.0.0 - , hls-plugin-api == 2.8.0.0 - , data-default + , text-rope ----------------------------- -- notes plugin diff --git a/hls-test-utils/hls-test-utils.cabal b/hls-test-utils/hls-test-utils.cabal index f6233a08aa..cebf06629b 100644 --- a/hls-test-utils/hls-test-utils.cabal +++ b/hls-test-utils/hls-test-utils.cabal @@ -57,7 +57,11 @@ library , temporary , text - ghc-options: -Wall -Wunused-packages -Wno-name-shadowing + ghc-options: + -Wall + -Wunused-packages + -Wno-name-shadowing + -Wno-unticked-promoted-constructors if flag(pedantic) ghc-options: -Werror diff --git a/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/Literals.hs b/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/Literals.hs index 233745f021..3b463509c7 100644 --- a/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/Literals.hs +++ b/plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/Literals.hs @@ -9,9 +9,10 @@ module Ide.Plugin.Literals ( import Data.Maybe (maybeToList) import Data.Text (Text) -import qualified Data.Text as T #if __GLASGOW_HASKELL__ >= 908 import qualified Data.Text.Encoding as T +#else +import qualified Data.Text as T #endif import Development.IDE.GHC.Compat hiding (getSrcSpan) import Development.IDE.Graph.Classes (NFData (rnf)) diff --git a/plugins/hls-class-plugin/test/Main.hs b/plugins/hls-class-plugin/test/Main.hs index 93b23b4aee..ea4da718ff 100644 --- a/plugins/hls-class-plugin/test/Main.hs +++ b/plugins/hls-class-plugin/test/Main.hs @@ -1,5 +1,4 @@ {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse/Comments.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse/Comments.hs index 8fdf64bc96..07667cc1bd 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse/Comments.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Parse/Comments.hs @@ -57,7 +57,7 @@ We build parsers combining the following three kinds of them: -} -- | Line parser -type LineParser a = forall m. Monad m => ParsecT Void String m a +type LineParser a = forall m. ParsecT Void String m a -- | Line comment group parser type LineGroupParser = Parsec Void [(Range, RawLineComment)] diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index c3dbca86f8..5c25c5f960 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -1085,11 +1085,14 @@ suggestImportDisambiguation df (Just txt) ps fileContents diag@Diagnostic {..} _ -> False ] ++ [HideOthers restImports | not (null restImports)] - ] ++ [ ( renderUniquify mode T.empty symbol True - , disambiguateSymbol ps fileContents diag symbol mode - ) | local, not (null targetsWithRestImports) - , let mode = HideOthers (uncurry (:) (head targetsWithRestImports)) - ] + ] ++ case targetsWithRestImports of + (m,ms):_ | local -> + let mode = HideOthers (m:ms) + in [( renderUniquify mode T.empty symbol True + , disambiguateSymbol ps fileContents diag symbol mode + )] + _ -> [] + renderUniquify HideOthers {} modName symbol local = "Use " <> (if local then "local definition" else modName) <> " for " <> symbol <> ", hiding other imports" renderUniquify (ToQualified _ qual) _ symbol _ =