From e78475737636a5d1e0d0a36b475c300cc7bb56cc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Jul 2011 03:12:05 -0400 Subject: hlint tweaks Did all sources except Remotes/* and Command/* --- Upgrade/V0.hs | 2 +- Upgrade/V1.hs | 25 +++++++++++-------------- Upgrade/V2.hs | 12 ++++++------ 3 files changed, 18 insertions(+), 21 deletions(-) (limited to 'Upgrade') diff --git a/Upgrade/V0.hs b/Upgrade/V0.hs index eabd03009..071fd12ee 100644 --- a/Upgrade/V0.hs +++ b/Upgrade/V0.hs @@ -48,7 +48,7 @@ lookupFile0 = Upgrade.V1.lookupFile1 getKeysPresent0 :: FilePath -> Annex [Key] getKeysPresent0 dir = do exists <- liftIO $ doesDirectoryExist dir - if (not exists) + if not exists then return [] else do contents <- liftIO $ getDirectoryContents dir diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs index 165a48262..8a3d37a64 100644 --- a/Upgrade/V1.hs +++ b/Upgrade/V1.hs @@ -94,7 +94,7 @@ updateSymlinks = do showNote "updating symlinks..." g <- Annex.gitRepo files <- liftIO $ LsFiles.inRepo g [Git.workTree g] - forM_ files $ fixlink + forM_ files fixlink where fixlink f = do r <- lookupFile1 f @@ -119,7 +119,7 @@ moveLocationLogs = do if exists then do contents <- liftIO $ getDirectoryContents dir - return $ catMaybes $ map oldlog2key contents + return $ mapMaybe oldlog2key contents else return [] move (l, k) = do g <- Annex.gitRepo @@ -196,17 +196,14 @@ lookupFile1 file = do Left _ -> return Nothing Right l -> makekey l where - getsymlink = do - l <- readSymbolicLink file - return $ takeFileName l - makekey l = do - case maybeLookupBackendName bname of - Nothing -> do - unless (null kname || null bname || - not (isLinkToAnnex l)) $ - warning skip - return Nothing - Just backend -> return $ Just (k, backend) + getsymlink = return . takeFileName =<< readSymbolicLink file + makekey l = case maybeLookupBackendName bname of + Nothing -> do + unless (null kname || null bname || + not (isLinkToAnnex l)) $ + warning skip + return Nothing + Just backend -> return $ Just (k, backend) where k = fileKey1 l bname = keyBackendName k @@ -221,7 +218,7 @@ getKeyFilesPresent1 = do getKeyFilesPresent1' :: FilePath -> Annex [FilePath] getKeyFilesPresent1' dir = do exists <- liftIO $ doesDirectoryExist dir - if (not exists) + if not exists then return [] else do dirs <- liftIO $ getDirectoryContents dir diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs index 4824f4bba..99c7806d2 100644 --- a/Upgrade/V2.hs +++ b/Upgrade/V2.hs @@ -10,7 +10,7 @@ module Upgrade.V2 where import System.Directory import System.FilePath import Control.Monad.State (unless, when, liftIO) -import List +import Data.List import Data.Maybe import Types.Key @@ -61,7 +61,7 @@ upgrade = do Git.run g "rm" [Param "-r", Param "-f", Param "-q", File (olddir g)] unless bare $ gitAttributesUnWrite g - unless bare $ push + unless bare push return True @@ -70,11 +70,11 @@ locationLogs repo = liftIO $ do levela <- dirContents dir levelb <- mapM tryDirContents levela files <- mapM tryDirContents (concat levelb) - return $ catMaybes $ map islogfile (concat files) + return $ mapMaybe islogfile (concat files) where tryDirContents d = catch (dirContents d) (return . const []) dir = gitStateDir repo - islogfile f = maybe Nothing (\k -> Just $ (k, f)) $ + islogfile f = maybe Nothing (\k -> Just (k, f)) $ logFileKey $ takeFileName f inject :: FilePath -> FilePath -> Annex () @@ -131,10 +131,10 @@ gitAttributesUnWrite repo = do whenM (doesFileExist attributes) $ do c <- readFileStrict attributes liftIO $ viaTmp writeFile attributes $ unlines $ - filter (\l -> not $ l `elem` attrLines) $ lines c + filter (`notElem` attrLines) $ lines c Git.run repo "add" [File attributes] stateDir :: FilePath -stateDir = addTrailingPathSeparator $ ".git-annex" +stateDir = addTrailingPathSeparator ".git-annex" gitStateDir :: Git.Repo -> FilePath gitStateDir repo = addTrailingPathSeparator $ Git.workTree repo stateDir -- cgit v1.2.3