hlint
authorJoey Hess <joey@kitenet.net>
Wed, 3 Apr 2013 07:52:41 +0000 (03:52 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 3 Apr 2013 07:52:41 +0000 (03:52 -0400)
26 files changed:
Annex/Branch.hs
Annex/Content/Direct.hs
Annex/Direct.hs
Annex/FileMatcher.hs
Annex/Ssh.hs
Assistant.hs
Assistant/Types/NamedThread.hs
Assistant/Types/NetMessager.hs
Backend.hs
Creds.hs
Crypto.hs
Init.hs
Limit.hs
Logs/Group.hs
Logs/Remote.hs
Logs/Transfer.hs
Logs/Trust.hs
Logs/Unused.hs
Messages.hs
Messages/JSON.hs
Remote.hs
Remote/Rsync.hs
Seek.hs
Test.hs
Types/GitConfig.hs
Types/StandardGroups.hs

index 4a36de66aaa8191afbd3ebe0a221b473de0fcb9f..021cd392674ee70f4e93717143b1e80d7bd29bb7 100644 (file)
@@ -189,7 +189,7 @@ change file a = lockJournal $ a <$> getStale file >>= set file
 
 {- Records new content of a file into the journal -}
 set :: FilePath -> String -> Annex ()
-set file content = setJournalFile file content
+set = setJournalFile
 
 {- Stages the journal, and commits staged changes to the branch. -}
 commit :: String -> Annex ()
@@ -197,7 +197,7 @@ commit message = whenM journalDirty $ lockJournal $ do
        cleanjournal <- stageJournal
        ref <- getBranch
        withIndex $ commitBranch ref message [fullname]
-       liftIO cleanjournal
+       liftIO cleanjournal
 
 {- Commits the staged changes in the index to the branch.
  - 
@@ -355,7 +355,7 @@ stageJournal = withIndex $ do
                Git.UpdateIndex.streamUpdateIndex g
                        [genstream dir h fs]
                hashObjectStop h
-       return $ liftIO $ mapM_ removeFile $ map (dir </>) fs
+       return $ liftIO $ mapM_ (removeFile . (dir </>)) fs
   where
        genstream dir h fs streamer = forM_ fs $ \file -> do
                let path = dir </> file
index bbf6e310d4c2b122264d00b59604c30d9089d031..25e257918d0a4f4be8d59060a1709851bc6a3c5a 100644 (file)
@@ -139,11 +139,10 @@ sameFileStatus :: Key -> FileStatus -> Annex Bool
 sameFileStatus key status = do
        old <- recordedInodeCache key
        let curr = toInodeCache status
-       r <- case (old, curr) of
+       case (old, curr) of
                (Just o, Just c) -> compareInodeCaches o c
                (Nothing, Nothing) -> return True
                _ -> return False
-       return r
 
 {- If the inodes have changed, only the size and mtime are compared. -}
 compareInodeCaches :: InodeCache -> InodeCache -> Annex Bool
index a88a045e77d38e2db661f5a7a167bfad2c5665a2..7836ceb9632e6bef9e530aa2f469d39602e975e7 100644 (file)
@@ -122,7 +122,7 @@ mergeDirectCleanup :: FilePath -> Git.Ref -> Git.Ref -> Annex ()
 mergeDirectCleanup d oldsha newsha = do
        (items, cleanup) <- inRepo $ DiffTree.diffTreeRecursive oldsha newsha
        forM_ items updated
-       void $ liftIO cleanup
+       void $ liftIO cleanup
        liftIO $ removeDirectoryRecursive d
   where
        updated item = do
index c32402baf072be9b40566e257c95fd0c4f206fe1..220fea286a0b2385badaf103142ad878402ba2ab 100644 (file)
@@ -47,7 +47,7 @@ parsedToMatcher parsed = case partitionEithers parsed of
 
 parseToken :: MkLimit -> GroupMap -> String -> Either String (Token MatchFiles)
 parseToken checkpresent groupmap t
-       | any (== t) Utility.Matcher.tokens = Right $ Utility.Matcher.token t
+       | t `elem` tokens = Right $ token t
        | t == "present" = use checkpresent
        | otherwise = maybe (Left $ "near " ++ show t) use $ M.lookup k $
                M.fromList
@@ -61,7 +61,7 @@ parseToken checkpresent groupmap t
                        ]
   where
        (k, v) = separate (== '=') t
-       use a = Utility.Matcher.Operation <$> a v
+       use a = Operation <$> a v
 
 {- This is really dumb tokenization; there's no support for quoted values.
  - Open and close parens are always treated as standalone tokens;
@@ -76,7 +76,7 @@ tokenizeMatcher = filter (not . null ) . concatMap splitparens . words
 largeFilesMatcher :: Annex FileMatcher
 largeFilesMatcher = go =<< annexLargeFiles <$> Annex.getGitConfig
   where
-       go Nothing = return matchAll
+       go Nothing = return matchAll
        go (Just expr) = do
                m <- groupMap
                u <- getUUID
index a8bd1f7b6203d01721caa0929b5a1000f45af22c..0b8ce3b93ccecc01ee3610852ee396294c79727e 100644 (file)
@@ -79,7 +79,7 @@ sshCacheDir
        gettmpdir = liftIO $ getEnv "GIT_ANNEX_TMP_DIR"
        usetmpdir tmpdir = liftIO $ catchMaybeIO $ do
                createDirectoryIfMissing True tmpdir
-               return tmpdir
+               return tmpdir
 
 portParams :: Maybe Integer -> [CommandParam]
 portParams Nothing = []
index 8ea6692e3d2d779d5bdcbfc273e66dd60d2783b0..ebe1b92e3df1bf46f9bea6ff45dcfcee5683ac78 100644 (file)
@@ -196,7 +196,8 @@ startDaemon assistant foreground startbrowser = do
                | otherwise = "watch"
        start daemonize webappwaiter = withThreadState $ \st -> do
                checkCanWatch
-               when assistant $ checkEnvironment
+               when assistant
+                       checkEnvironment
                dstatus <- startDaemonStatus
                logfile <- fromRepo gitAnnexLogFile
                liftIO $ debugM desc $ "logging to " ++ logfile
index 0e884637a3107a9a852e19910ffa68b31237dab6..a65edc20d725a5516c4b2612349cbb9636e0aa65 100644 (file)
@@ -14,4 +14,4 @@ import Assistant.Types.ThreadName
 data NamedThread = NamedThread ThreadName (Assistant ())
 
 namedThread :: String -> Assistant () -> NamedThread
-namedThread name a = NamedThread (ThreadName name) a
+namedThread = NamedThread . ThreadName
index 05e51045dd2a26014017c8bc599aa0e7a5ef7c4a..1ea7db7ce48337c3f940c0c32a5252ac0ca51600 100644 (file)
@@ -104,7 +104,7 @@ getSide side m = m side
 
 data NetMessager = NetMessager
        -- outgoing messages
-       { netMessages :: TChan (NetMessage)
+       { netMessages :: TChan NetMessage
        -- important messages for each client
        , importantNetMessages :: TMVar (M.Map ClientID (S.Set NetMessage))
        -- important messages that are believed to have been sent to a client
index 8bf29846c5690f549518c1bbc61ddc6b5cd6fbed..2ee14acc61a625bc7dcd1d6464fb3cf97c46235b 100644 (file)
@@ -94,8 +94,7 @@ lookupFile file = do
   where
        makeret k = let bname = keyBackendName k in
                case maybeLookupBackendName bname of
-                       Just backend -> do
-                               return $ Just (k, backend)
+                       Just backend -> return $ Just (k, backend)
                        Nothing -> do
                                warning $
                                        "skipping " ++ file ++
index ee0a67398d42801142c8ad3627dda134cdd1a698..4c6896663def0208dab0a7d916b1132db6c255fe 100644 (file)
--- a/Creds.hs
+++ b/Creds.hs
@@ -92,7 +92,7 @@ getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
                Just credpair -> do
                        writeCacheCredPair credpair storage
                        return $ Just credpair
-               _ -> do error $ "bad creds"
+               _ -> error "bad creds"
 
 {- Gets a CredPair from the environment. -}
 getEnvCredPair :: CredPairStorage -> IO (Maybe CredPair)
index 0a403d117591d404e93a6d57491ab1a46ae64f28..be326bf4c323a85a980d7e74c194e0b4660a79c0 100644 (file)
--- a/Crypto.hs
+++ b/Crypto.hs
@@ -100,7 +100,7 @@ encryptCipher :: Cipher -> KeyIds -> IO StorableCipher
 encryptCipher (Cipher c) (KeyIds ks) = do
        -- gpg complains about duplicate recipient keyids
        let ks' = nub $ sort ks
-       encipher <- Gpg.pipeStrict ([ Params "--encrypt" ] ++ recipients ks') c
+       encipher <- Gpg.pipeStrict (Params "--encrypt" : recipients ks') c
        return $ EncryptedCipher encipher (KeyIds ks')
   where
        recipients l = force_recipients :
diff --git a/Init.hs b/Init.hs
index 358a54e8188ddbf2bc437c5aedf45d5a38ebee4f..0ada312e74d681cd04f6355bf7ef6bb19852f970 100644 (file)
--- a/Init.hs
+++ b/Init.hs
@@ -33,7 +33,7 @@ import Backend
 genDescription :: Maybe String -> Annex String
 genDescription (Just d) = return d
 genDescription Nothing = do
-       hostname <- maybe "" id <$> liftIO getHostname
+       hostname <- fromMaybe "" <$> liftIO getHostname
        let at = if null hostname then "" else "@"
        username <- liftIO myUserName
        reldir <- liftIO . relHome =<< fromRepo Git.repoPath
@@ -132,7 +132,7 @@ probeCrippledFileSystem = do
                return True
 
 checkCrippledFileSystem :: Annex ()
-checkCrippledFileSystem = whenM (probeCrippledFileSystem) $ do
+checkCrippledFileSystem = whenM probeCrippledFileSystem $ do
        warning "Detected a crippled filesystem."
        setCrippledFileSystem True
        unlessM isDirect $ do
index 1d8646bb17e9386ffc0ec76c99ba14b2fb9c5556..745f2cd2272106e6d954303588a87dc70b053c7d 100644 (file)
--- a/Limit.hs
+++ b/Limit.hs
@@ -5,7 +5,7 @@
  - Licensed under the GNU GPL version 3 or higher.
  -}
 
-{-# LANGUAGE PackageImports, CPP #-}
+{-# LANGUAGE CPP #-}
 
 module Limit where
 
@@ -128,7 +128,7 @@ limitIn name = Right $ \notpresent -> check $
 limitPresent :: Maybe UUID -> MkLimit
 limitPresent u _ = Right $ const $ check $ \key -> do
        hereu <- getUUID
-       if u == Just hereu || u == Nothing
+       if u == Just hereu || isNothing u
                then inAnnex key
                else do
                        us <- Remote.keyLocations key
index a069edcdf38cf7c11c43c46f79a718882cdde309..c08feffde61749a5ddeb7ec577559576cd2cbbd1 100644 (file)
@@ -66,11 +66,11 @@ makeGroupMap :: M.Map UUID (S.Set Group) -> GroupMap
 makeGroupMap byuuid = GroupMap byuuid bygroup
   where
        bygroup = M.fromListWith S.union $
-               concat $ map explode $ M.toList byuuid
+               concatMap explode $ M.toList byuuid
        explode (u, s) = map (\g -> (g, S.singleton u)) (S.toList s)
 
 {- If a repository is in exactly one standard group, returns it. -}
 getStandardGroup :: S.Set Group -> Maybe StandardGroup
-getStandardGroup s = case catMaybes $ map toStandardGroup $ S.toList s of
+getStandardGroup s = case mapMaybe toStandardGroup $ S.toList s of
        [g] -> Just g
        _ -> Nothing
index 55fb40f4b1c899ed56e2368f0e5bd3a747a6ecb4..89792b0545d1d68bce95771250344d8c017fdb63 100644 (file)
@@ -93,7 +93,7 @@ prop_idempotent_configEscape s = s == (configUnEscape . configEscape) s
 prop_parse_show_Config :: RemoteConfig -> Bool
 prop_parse_show_Config c
        -- whitespace and '=' are not supported in keys
-       | any (\k -> any isSpace k || any (== '=') k) (M.keys c) = True
+       | any (\k -> any isSpace k || elem '=' k) (M.keys c) = True
        | otherwise = parseConfig (showConfig c) ~~ Just c
   where
        normalize v = sort . M.toList <$> v
index 921d8f81593b2b35fdd17e976abd790cb3d9052e..778932510e60bc2e115cb168400900c4ff625698 100644 (file)
@@ -130,8 +130,8 @@ runTransfer t file shouldretry a = do
                        Just fd -> do
                                locked <- catchMaybeIO $
                                        setLock fd (WriteLock, AbsoluteSeek, 0, 0)
-                               when (locked == Nothing) $
-                                       error "transfer already in progress"
+                               when (isNothing locked) $
+                                       error "transfer already in progress"
                                void $ tryIO $ writeTransferInfoFile info tfile
                                return mfd
        cleanup _ Nothing = noop
@@ -169,7 +169,7 @@ mkProgressUpdater t info = do
   where
        updater tfile mvar b = modifyMVar_ mvar $ \oldbytes -> do
                let newbytes = fromBytesProcessed b
-               if (newbytes - oldbytes >= mindelta)
+               if newbytes - oldbytes >= mindelta
                        then do
                                let info' = info { bytesComplete = Just newbytes }
                                _ <- tryIO $ writeTransferInfoFile info' tfile
@@ -213,7 +213,7 @@ checkTransfer t = do
 {- Gets all currently running transfers. -}
 getTransfers :: Annex [(Transfer, TransferInfo)]
 getTransfers = do
-       transfers <- catMaybes . map parseTransferFile . concat <$> findfiles
+       transfers <- mapMaybe parseTransferFile . concat <$> findfiles
        infos <- mapM checkTransfer transfers
        return $ map (\(t, Just i) -> (t, i)) $
                filter running $ zip transfers infos
@@ -265,7 +265,7 @@ transferLockFile infofile = let (d,f) = splitFileName infofile in
 {- Parses a transfer information filename to a Transfer. -}
 parseTransferFile :: FilePath -> Maybe Transfer
 parseTransferFile file
-       | "lck." `isPrefixOf` (takeFileName file) = Nothing
+       | "lck." `isPrefixOf` takeFileName file = Nothing
        | otherwise = case drop (length bits - 3) bits of
                [direction, u, key] -> Transfer
                        <$> readLcDirection direction
@@ -291,17 +291,17 @@ writeTransferInfoFile info tfile = do
 writeTransferInfo :: TransferInfo -> String
 writeTransferInfo info = unlines
        [ (maybe "" show $ startedTime info) ++
-         (maybe "" (\b -> " " ++ show b) $ bytesComplete info)
+         (maybe "" (\b -> ' ' : show b) (bytesComplete info))
        , fromMaybe "" $ associatedFile info -- comes last; arbitrary content
        ]
 
-readTransferInfoFile :: (Maybe ProcessID) -> FilePath -> IO (Maybe TransferInfo)
+readTransferInfoFile :: Maybe ProcessID -> FilePath -> IO (Maybe TransferInfo)
 readTransferInfoFile mpid tfile = catchDefaultIO Nothing $ do
        h <- openFile tfile ReadMode
        fileEncoding h
        hClose h `after` (readTransferInfo mpid <$> hGetContentsStrict h)
 
-readTransferInfo :: (Maybe ProcessID) -> String -> Maybe TransferInfo
+readTransferInfo :: Maybe ProcessID -> String -> Maybe TransferInfo
 readTransferInfo mpid s = TransferInfo
        <$> time
        <*> pure mpid
@@ -353,8 +353,8 @@ instance Arbitrary TransferInfo where
 
 prop_read_write_transferinfo :: TransferInfo -> Bool
 prop_read_write_transferinfo info
-       | transferRemote info /= Nothing = True -- remote not stored
-       | transferTid info /= Nothing = True -- tid not stored
+       | isJust (transferRemote info) = True -- remote not stored
+       | isJust (transferTid info) = True -- tid not stored
        | otherwise = Just (info { transferPaused = False }) == info'
   where
        info' = readTransferInfo (transferPid info) (writeTransferInfo info)
index 058250740fa40625ef63f6bed3511bf5bf5e2bfb..89a5404f7229ef6b56a75a716fcb730f90c9f241 100644 (file)
@@ -70,7 +70,7 @@ trustPartition level ls
                return $ partition (`elem` candidates) ls
 
 {- Filters UUIDs to those not matching a TrustLevel. -}
-trustExclude :: TrustLevel -> [UUID] -> Annex ([UUID])
+trustExclude :: TrustLevel -> [UUID] -> Annex [UUID]
 trustExclude level ls = snd <$> trustPartition level ls
 
 {- trustLog in a map, overridden with any values from forcetrust or
index bef78a992a4d6c26fe2b3a716873bdc506e2a783..437b01f713a8025d3aab228a950320f3c68ee29c 100644 (file)
@@ -31,7 +31,7 @@ readUnusedLog :: FilePath -> Annex UnusedMap
 readUnusedLog prefix = do
        f <- fromRepo $ gitAnnexUnusedLog prefix
        ifM (liftIO $ doesFileExist f)
-               ( M.fromList . catMaybes . map parse . lines
+               ( M.fromList . mapMaybe parse . lines
                        <$> liftIO (readFile f)
                , return M.empty
                )
index 13b786a318591a6c1ee6185a01f2707805437d63..cc82b905058425f313badc099974d89a0ca82e0f 100644 (file)
@@ -71,7 +71,7 @@ showProgress = handle q $
 
 {- Shows a progress meter while performing a transfer of a key.
  - The action is passed a callback to use to update the meter. -}
-metered :: (Maybe MeterUpdate) -> Key -> (MeterUpdate -> Annex a) -> Annex a
+metered :: Maybe MeterUpdate -> Key -> (MeterUpdate -> Annex a) -> Annex a
 metered combinemeterupdate key a = go (keySize key)
   where
        go (Just size) = meteredBytes combinemeterupdate size a
@@ -79,7 +79,7 @@ metered combinemeterupdate key a = go (keySize key)
 
 {- Shows a progress meter while performing an action on a given number
  - of bytes. -}
-meteredBytes :: (Maybe MeterUpdate) -> Integer -> (MeterUpdate -> Annex a) -> Annex a
+meteredBytes :: Maybe MeterUpdate -> Integer -> (MeterUpdate -> Annex a) -> Annex a
 meteredBytes combinemeterupdate size a = withOutputType go
   where
        go NormalOutput = do
index e262192a8400992d6ff349ec6965f953272256b5..d57d69318be120a1b127a4df918a9f791b06271e 100644 (file)
@@ -34,7 +34,4 @@ add :: JSON a => [(String, a)] -> IO ()
 add v = putStr $ Stream.add v
 
 complete :: JSON a => [(String, a)] -> IO ()
-complete v = putStr $ concat
-       [ Stream.start v
-       , Stream.end
-       ]
+complete v = putStr $ Stream.start v ++ Stream.end
index 01d6da3cc3790d27dce7a11a16957a99880e1864..7affb93af6378af896531fbff33d1f7985978f36 100644 (file)
--- a/Remote.hs
+++ b/Remote.hs
@@ -150,7 +150,7 @@ prettyListUUIDs :: [UUID] -> Annex [String]
 prettyListUUIDs uuids = do
        hereu <- getUUID
        m <- uuidDescriptions
-       return $ map (\u -> prettify m hereu u) uuids
+       return $ map (prettify m hereu) uuids
   where
        finddescription m u = M.findWithDefault "" u m
        prettify m hereu u
index 9563b43e82e67848fb1ce343c3b6abac15080e28..a5750437d0ff6878cec300f6eb7e024f9a262878 100644 (file)
@@ -127,7 +127,7 @@ retrieveCheap :: RsyncOpts -> Key -> FilePath -> Annex Bool
 retrieveCheap o k f = ifM (preseedTmp k f) ( retrieve o k undefined f , return False )
 
 retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> FilePath -> Annex Bool
-retrieveEncrypted o (cipher, enck) _ f = withTmp enck $ \tmp -> do
+retrieveEncrypted o (cipher, enck) _ f = withTmp enck $ \tmp ->
        ifM (retrieve o enck undefined tmp)
                ( liftIO $ catchBoolIO $ do
                        decrypt cipher (feedFile tmp) $
diff --git a/Seek.hs b/Seek.hs
index 6f87e8e6c65774093c9ad8cdfd9c04eb6a87caec..70f5a907b953fabd21550e51fc19335601011e28 100644 (file)
--- a/Seek.hs
+++ b/Seek.hs
@@ -28,7 +28,7 @@ seekHelper a params = do
                runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g) params
        {- Show warnings only for files/directories that do not exist. -}
        forM_ (map fst $ filter (null . snd) $ zip params ll) $ \p ->
-               unlessM (isJust <$> (liftIO $ catchMaybeIO $ getSymbolicLinkStatus p)) $
+               unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $
                        fileNotFound p
        return $ concat ll
 
diff --git a/Test.hs b/Test.hs
index 599bc0eaaec3c9d6765c1ad32c768a75a3800a32..56c70573d467fdceb750494138a6f78923736cb2 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -72,7 +72,7 @@ main = do
        divider
        propigate rs qcok
   where
-       divider = putStrLn $ take 70 $ repeat '-'
+       divider = putStrLn $ replicate 70 '-'
 
 propigate :: [Counts] -> Bool -> IO ()
 propigate cs qcok
index 246c320d071ce20bb7d66a28ff3def589f3def38..ff7cd3c90e9a8a72724e7189c699ed0dbe5e7bad 100644 (file)
@@ -122,8 +122,8 @@ extractRemoteGitConfig r remotename = RemoteGitConfig
        getbool k def = fromMaybe def $ getmaybebool k
        getmaybebool k = Git.Config.isTrue =<< getmaybe k
        getmayberead k = readish =<< getmaybe k
-       getmaybe k = maybe (Git.Config.getMaybe (key k) r) Just $
-               Git.Config.getMaybe (remotekey k) r
+       getmaybe k = mplus (Git.Config.getMaybe (key k) r)
+               (Git.Config.getMaybe (remotekey k) r)
        getoptions k = fromMaybe [] $ words <$> getmaybe k
 
        key k = "annex." ++ k
index 2262c3bded0475f4e1437813626d4bf6b0e41794..434600f3f7cf4b65b20d8fd7781427169d90aaee 100644 (file)
@@ -57,17 +57,17 @@ descStandardGroup UnwantedGroup = "unwanted: remove content from this repository
 preferredContent :: StandardGroup -> String
 preferredContent ClientGroup = lastResort
        "exclude=*/archive/* and exclude=archive/*"
-preferredContent TransferGroup = lastResort $
+preferredContent TransferGroup = lastResort
        "not (inallgroup=client and copies=client:2) and " ++ preferredContent ClientGroup
 preferredContent BackupGroup = "include=*"
-preferredContent IncrementalBackupGroup = lastResort $
+preferredContent IncrementalBackupGroup = lastResort
        "include=* and (not copies=incrementalbackup:1)"
 preferredContent SmallArchiveGroup = lastResort $
        "(include=*/archive/* or include=archive/*) and " ++ preferredContent FullArchiveGroup
-preferredContent FullArchiveGroup = lastResort $
+preferredContent FullArchiveGroup = lastResort
        "not (copies=archive:1 or copies=smallarchive:1)"
 preferredContent SourceGroup = "not (copies=1)"
-preferredContent ManualGroup = lastResort $
+preferredContent ManualGroup = lastResort
        "present and exclude=*/archive/* and exclude=archive/*"
 preferredContent UnwantedGroup = "exclude=*"