Skip to content

Commit

Permalink
Restore previous behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed Jan 16, 2020
1 parent bbf8c58 commit ec57779
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/CmdLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import System.Info.Extra
import System.Process
import System.FilePattern

import EmbedData
import Util
import Paths_hlint
import Data.Version
Expand Down Expand Up @@ -215,13 +216,15 @@ mode = cmdArgsMode $ modes
-- * If someone passes cmdWithHints, only look at files they explicitly request
-- * If someone passes an explicit hint name, automatically merge in data/hlint.yaml
-- We want more important hints to go last, since they override
cmdHintFiles :: Cmd -> IO [FilePath]
cmdHintFiles :: Cmd -> IO [(FilePath, Maybe String)]
cmdHintFiles cmd = do
let explicit1 = [hlintYaml | null $ cmdWithHints cmd]
let explicit2 = cmdGivenHints cmd
bad <- filterM (notM . doesFileExist) explicit2
let explicit2' = map (,Nothing) explicit2
when (bad /= []) $
fail $ unlines $ "Failed to find requested hint files:" : map (" "++) bad
if cmdWithHints cmd /= [] then return explicit2 else do
if cmdWithHints cmd /= [] then return $ explicit1 ++ explicit2' else do
-- we follow the stylish-haskell config file search policy
-- 1) current directory or its ancestors; 2) home directory
curdir <- getCurrentDirectory
Expand All @@ -230,7 +233,7 @@ cmdHintFiles cmd = do
implicit <- findM doesFileExist $
map (</> ".hlint.yaml") (ancestors curdir ++ home) -- to match Stylish Haskell
++ ["HLint.hs"] -- the default in HLint 1.*
return $ maybeToList implicit ++ explicit2
return $ explicit1 ++ map (,Nothing) (maybeToList implicit) ++ explicit2'
where
ancestors = init . map joinPath . reverse . inits . splitPath

Expand Down
4 changes: 1 addition & 3 deletions src/Config/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import Config.Haskell
import Config.Yaml
import Data.List.Extra
import System.FilePath
import EmbedData


readFilesConfig :: [(FilePath, Maybe String)] -> IO [Setting]
readFilesConfig files = do
yaml <- mapM (uncurry readFileConfigYaml) yaml'
yaml <- mapM (uncurry readFileConfigYaml) yaml
haskell <- mapM (uncurry readFileConfigHaskell) haskell
return $ concat haskell ++ settingsFromConfigYaml yaml
where
(yaml, haskell) = partition (\(x,_) -> lower (takeExtension x) `elem` [".yml",".yaml"]) files
yaml' = if any ((takeFileName (fst hlintYaml) ==) . takeFileName . fst) yaml then yaml else hlintYaml : yaml
6 changes: 3 additions & 3 deletions src/HLint.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE RecordWildCards, TupleSections #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}

module HLint(hlint, readAllSettings) where
Expand Down Expand Up @@ -87,7 +87,7 @@ hlintTest :: Cmd -> IO ()
hlintTest cmd@CmdTest{..} =
if not $ null cmdProof then do
files <- cmdHintFiles cmd
s <- readFilesConfig $ map (,Nothing) files
s <- readFilesConfig files
let reps = if cmdReports == ["report.html"] then ["report.txt"] else cmdReports
mapM_ (proof reps s) cmdProof
else do
Expand Down Expand Up @@ -153,7 +153,7 @@ readAllSettings args1 cmd@CmdMain{..} = do
files <- cmdHintFiles cmd
settings1 <-
readFilesConfig $
map (,Nothing) files
files
++ [("CommandLine.hs",Just x) | x <- cmdWithHints]
++ [("CommandLine.yaml",Just (enableGroup x)) | x <- cmdWithGroups]
let args2 = [x | SettingArgument x <- settings1]
Expand Down

0 comments on commit ec57779

Please sign in to comment.