diff options
author | Clint Adams <clint@debian.org> | 2018-03-28 22:48:44 -0400 |
---|---|---|
committer | Clint Adams <clint@debian.org> | 2018-03-28 22:48:44 -0400 |
commit | 8017336edbbfb4ab52ac3ab2309c286842e8f6a2 (patch) | |
tree | a32612a82b625d9d873f75e8d83c7b6279d62f26 | |
parent | 5fe2d10c984dcfcdff01c7d73ab8e8bf95d27b26 (diff) |
Clean up hlint warnings
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | 17 | ||||
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs | 10 | ||||
-rw-r--r-- | tests/suite.hs | 8 |
3 files changed, 18 insertions, 17 deletions
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs index b62ff6a..5d28e46 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Decode.hs | |||
@@ -25,6 +25,7 @@ import qualified Data.ByteString.Char8 as BC8 | |||
25 | import qualified Data.ByteString.Base64 as Base64 | 25 | import qualified Data.ByteString.Base64 as Base64 |
26 | import Data.Digest.CRC24 (crc24) | 26 | import Data.Digest.CRC24 (crc24) |
27 | import Data.Binary.Get (Get, runGetOrFail, getWord8) | 27 | import Data.Binary.Get (Get, runGetOrFail, getWord8) |
28 | import Data.Functor (($>)) | ||
28 | import Data.String (IsString, fromString) | 29 | import Data.String (IsString, fromString) |
29 | import Data.Word (Word32) | 30 | import Data.Word (Word32) |
30 | 31 | ||
@@ -75,10 +76,10 @@ beginLine = do | |||
75 | _ <- lineEnding <?> "line ending" | 76 | _ <- lineEnding <?> "line ending" |
76 | return atype | 77 | return atype |
77 | where | 78 | where |
78 | message = string "MESSAGE" *> return ArmorMessage | 79 | message = string "MESSAGE" $> ArmorMessage |
79 | pubkey = string "PUBLIC KEY BLOCK" *> return ArmorPublicKeyBlock | 80 | pubkey = string "PUBLIC KEY BLOCK" $> ArmorPublicKeyBlock |
80 | privkey = string "PRIVATE KEY BLOCK" *> return ArmorPrivateKeyBlock | 81 | privkey = string "PRIVATE KEY BLOCK" $> ArmorPrivateKeyBlock |
81 | signature = string "SIGNATURE" *> return ArmorSignature | 82 | signature = string "SIGNATURE" $> ArmorSignature |
82 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) | 83 | parts = string "MESSAGE, PART " *> (partsdef <|> partsindef) |
83 | partsdef = do | 84 | partsdef = do |
84 | firstnum <- num | 85 | firstnum <- num |
@@ -113,12 +114,12 @@ endLine atype = do | |||
113 | lineEnding | 114 | lineEnding |
114 | 115 | ||
115 | aType :: ArmorType -> B.ByteString | 116 | aType :: ArmorType -> B.ByteString |
116 | aType (ArmorMessage) = BC8.pack "MESSAGE" | 117 | aType ArmorMessage = BC8.pack "MESSAGE" |
117 | aType (ArmorPublicKeyBlock) = BC8.pack "PUBLIC KEY BLOCK" | 118 | aType ArmorPublicKeyBlock = BC8.pack "PUBLIC KEY BLOCK" |
118 | aType (ArmorPrivateKeyBlock) = BC8.pack "PRIVATE KEY BLOCK" | 119 | aType ArmorPrivateKeyBlock = BC8.pack "PRIVATE KEY BLOCK" |
119 | aType (ArmorSplitMessage x y) = BC8.pack "MESSAGE, PART " `B.append` l2s x `B.append` BC8.singleton '/' `B.append` l2s y | 120 | aType (ArmorSplitMessage x y) = BC8.pack "MESSAGE, PART " `B.append` l2s x `B.append` BC8.singleton '/' `B.append` l2s y |
120 | aType (ArmorSplitMessageIndefinite x) = BC8.pack "MESSAGE, PART " `B.append` l2s x | 121 | aType (ArmorSplitMessageIndefinite x) = BC8.pack "MESSAGE, PART " `B.append` l2s x |
121 | aType (ArmorSignature) = BC8.pack "SIGNATURE" | 122 | aType ArmorSignature = BC8.pack "SIGNATURE" |
122 | 123 | ||
123 | l2s :: BL.ByteString -> B.ByteString | 124 | l2s :: BL.ByteString -> B.ByteString |
124 | l2s = B.concat . BL.toChunks | 125 | l2s = B.concat . BL.toChunks |
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs index fdb9961..cb5b16d 100644 --- a/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Encode.hs | |||
@@ -37,15 +37,15 @@ endLine :: ArmorType -> ByteString | |||
37 | endLine atype = BLC8.pack "-----END PGP " `BL.append` aType atype `BL.append` BLC8.pack "-----\n" | 37 | endLine atype = BLC8.pack "-----END PGP " `BL.append` aType atype `BL.append` BLC8.pack "-----\n" |
38 | 38 | ||
39 | aType :: ArmorType -> ByteString | 39 | aType :: ArmorType -> ByteString |
40 | aType (ArmorMessage) = BLC8.pack "MESSAGE" | 40 | aType ArmorMessage = BLC8.pack "MESSAGE" |
41 | aType (ArmorPublicKeyBlock) = BLC8.pack "PUBLIC KEY BLOCK" | 41 | aType ArmorPublicKeyBlock = BLC8.pack "PUBLIC KEY BLOCK" |
42 | aType (ArmorPrivateKeyBlock) = BLC8.pack "PRIVATE KEY BLOCK" | 42 | aType ArmorPrivateKeyBlock = BLC8.pack "PRIVATE KEY BLOCK" |
43 | aType (ArmorSplitMessage x y) = BLC8.pack $ "MESSAGE, PART " ++ show x ++ "/" ++ show y | 43 | aType (ArmorSplitMessage x y) = BLC8.pack $ "MESSAGE, PART " ++ show x ++ "/" ++ show y |
44 | aType (ArmorSplitMessageIndefinite x) = BLC8.pack $ "MESSAGE, PART " ++ show x | 44 | aType (ArmorSplitMessageIndefinite x) = BLC8.pack $ "MESSAGE, PART " ++ show x |
45 | aType (ArmorSignature) = BLC8.pack "SIGNATURE" | 45 | aType ArmorSignature = BLC8.pack "SIGNATURE" |
46 | 46 | ||
47 | armorHeaders :: [(String, String)] -> ByteString | 47 | armorHeaders :: [(String, String)] -> ByteString |
48 | armorHeaders ahs = BLC8.unlines . map armorHeader $ ahs | 48 | armorHeaders = BLC8.unlines . map armorHeader |
49 | where | 49 | where |
50 | armorHeader :: (String, String) -> ByteString | 50 | armorHeader :: (String, String) -> ByteString |
51 | armorHeader (k, v) = BLC8.pack k `BL.append` BLC8.pack ": " `BL.append` BLC8.pack v | 51 | armorHeader (k, v) = BLC8.pack k `BL.append` BLC8.pack ": " `BL.append` BLC8.pack v |
diff --git a/tests/suite.hs b/tests/suite.hs index 3a7b7eb..a8b5a30 100644 --- a/tests/suite.hs +++ b/tests/suite.hs | |||
@@ -67,25 +67,25 @@ testArmorEncode :: [FilePath] -> FilePath -> Assertion | |||
67 | testArmorEncode fps target = do | 67 | testArmorEncode fps target = do |
68 | bss <- mapM (\fp -> BL.readFile $ "tests/data/" ++ fp) fps | 68 | bss <- mapM (\fp -> BL.readFile $ "tests/data/" ++ fp) fps |
69 | tbs <- BL.readFile $ "tests/data/" ++ target | 69 | tbs <- BL.readFile $ "tests/data/" ++ target |
70 | assertEqual ("literaldata") tbs (encodeLazy (map (\bs -> Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs) bss)) | 70 | assertEqual "literaldata" tbs (encodeLazy (map (Armor ArmorMessage [("Version","OpenPrivacy 0.99")]) bss)) |
71 | 71 | ||
72 | testClearsignedEncode :: FilePath -> FilePath -> FilePath -> Assertion | 72 | testClearsignedEncode :: FilePath -> FilePath -> FilePath -> Assertion |
73 | testClearsignedEncode ftxt fsig ftarget = do | 73 | testClearsignedEncode ftxt fsig ftarget = do |
74 | txt <- BL.readFile $ "tests/data/" ++ ftxt | 74 | txt <- BL.readFile $ "tests/data/" ++ ftxt |
75 | sig <- BL.readFile $ "tests/data/" ++ fsig | 75 | sig <- BL.readFile $ "tests/data/" ++ fsig |
76 | target <- BL.readFile $ "tests/data/" ++ ftarget | 76 | target <- BL.readFile $ "tests/data/" ++ ftarget |
77 | assertEqual ("clearsigned encode") target (encodeLazy [ClearSigned [("Hash","SHA1")] txt (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] sig)]) | 77 | assertEqual "clearsigned encode" target (encodeLazy [ClearSigned [("Hash","SHA1")] txt (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] sig)]) |
78 | 78 | ||
79 | testStrictDecode :: FilePath -> Assertion | 79 | testStrictDecode :: FilePath -> Assertion |
80 | testStrictDecode fp = do | 80 | testStrictDecode fp = do |
81 | bs <- BL.readFile $ "tests/data/" ++ fp | 81 | bs <- BL.readFile $ "tests/data/" ++ fp |
82 | assertEqual ("strict decode") (decodeLazy bs :: Either String [Armor]) (decode (B.concat . BL.toChunks $ bs) :: Either String [Armor]) | 82 | assertEqual "strict decode" (decodeLazy bs :: Either String [Armor]) (decode (B.concat . BL.toChunks $ bs) :: Either String [Armor]) |
83 | 83 | ||
84 | testStrictEncode :: FilePath -> Assertion | 84 | testStrictEncode :: FilePath -> Assertion |
85 | testStrictEncode fp = do | 85 | testStrictEncode fp = do |
86 | bs <- BL.readFile $ "tests/data/" ++ fp | 86 | bs <- BL.readFile $ "tests/data/" ++ fp |
87 | let fakearmors = [Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs, ClearSigned [("Hash","SHA1")] bs (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] bs)] | 87 | let fakearmors = [Armor ArmorMessage [("Version","OpenPrivacy 0.99")] bs, ClearSigned [("Hash","SHA1")] bs (Armor ArmorSignature [("Version","OpenPrivacy 0.99")] bs)] |
88 | assertEqual ("strict encode") (encodeLazy fakearmors) (BL.fromChunks [(encode fakearmors)]) | 88 | assertEqual "strict encode" (encodeLazy fakearmors) (BL.fromChunks [encode fakearmors]) |
89 | 89 | ||
90 | tests :: TestTree | 90 | tests :: TestTree |
91 | tests = testGroup "openpgp-asciiarmor" [ | 91 | tests = testGroup "openpgp-asciiarmor" [ |