Skip to content

Fix -Wall and -Wunused-packages in fourmolu and ormolu plugins #4007

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

Merged
merged 2 commits into from
Jan 23, 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
10 changes: 6 additions & 4 deletions plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ source-repository head
type: git
location: git://github.com/haskell/haskell-language-server.git

common warnings
ghc-options: -Wall -Wunused-packages

library
import: warnings
exposed-modules:
Ide.Plugin.Fourmolu
hs-source-dirs: src
ghc-options: -Wall
build-depends:
, base >=4.12 && <5
, filepath
, fourmolu ^>= 0.14
, ghc
, ghc-boot-th
, ghcide == 2.6.0.0
, hls-plugin-api == 2.6.0.0
Expand All @@ -45,17 +47,17 @@ library
default-language: Haskell2010

test-suite tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
main-is: Main.hs
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-tool-depends:
fourmolu:fourmolu
build-depends:
, base >=4.12 && <5
, aeson
, containers
, filepath
, hls-fourmolu-plugin
, hls-plugin-api
Expand Down
9 changes: 5 additions & 4 deletions plugins/hls-ormolu-plugin/hls-ormolu-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ source-repository head
type: git
location: https://github.com/haskell/haskell-language-server.git

common warnings
ghc-options: -Wall -Wunused-packages

library
import: warnings
exposed-modules: Ide.Plugin.Ormolu
hs-source-dirs: src
build-depends:
, base >=4.12 && <5
, extra
, filepath
, ghc
, ghc-boot-th
, ghcide == 2.6.0.0
, hls-plugin-api == 2.6.0.0
, lens
, lsp
, mtl
, process-extras >= 0.7.1
Expand All @@ -44,6 +46,7 @@ library
default-language: Haskell2010

test-suite tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
Expand All @@ -54,11 +57,9 @@ test-suite tests
build-depends:
, base
, aeson
, containers
, filepath
, hls-ormolu-plugin
, hls-plugin-api
, hls-test-utils == 2.6.0.0
, lsp-types
, text
, ormolu
8 changes: 2 additions & 6 deletions plugins/hls-ormolu-plugin/src/Ide/Plugin/Ormolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ where
import Control.Exception (Handler (..), IOException,
SomeException (..), catches,
handle)
import Control.Monad.Except (ExceptT (ExceptT), runExceptT,
throwError)
import Control.Monad.Except (runExceptT, throwError)
import Control.Monad.Extra
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans
import Control.Monad.Trans.Except (ExceptT (..), mapExceptT,
runExceptT)
import Control.Monad.Trans.Except (ExceptT (..), mapExceptT)
import Data.Functor ((<&>))
import Data.List (intercalate)
import Data.Maybe (catMaybes)
Expand All @@ -38,7 +35,6 @@ import Ide.Plugin.Properties
import Ide.PluginUtils
import Ide.Types hiding (Config)
import qualified Ide.Types as Types
import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
import Language.LSP.Server hiding (defaultConfig)
import Ormolu
Expand Down
7 changes: 4 additions & 3 deletions plugins/hls-ormolu-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Main
) where

import Data.Aeson
import qualified Data.Aeson.KeyMap as KM
import Data.Functor
import qualified Data.Text as T
import Ide.Plugin.Config
import qualified Ide.Plugin.Ormolu as Ormolu
import Language.LSP.Protocol.Types
Expand Down Expand Up @@ -34,9 +34,10 @@ tests = testGroup "ormolu" $
]

goldenWithOrmolu :: Bool -> TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
goldenWithOrmolu cli title path desc = goldenWithHaskellDocFormatter def ormoluPlugin "ormolu" def title testDataDir path desc "hs"
goldenWithOrmolu cli title path desc =
goldenWithHaskellDocFormatter def ormoluPlugin "ormolu" conf title testDataDir path desc "hs"
where
conf = def{plcConfig = (\(Object obj) -> obj) $ object ["external" .= cli]}
conf = def{plcConfig = KM.fromList ["external" .= cli]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The fact that conf was unused was actual test bug - the tests only ever executed with the default configuration (only def was passed to goldenWithHaskellDocFormatter).


testDataDir :: FilePath
testDataDir = "test" </> "testdata"