From ba38c19e4ef41634446c63a57b21d196ab802ba5 Mon Sep 17 00:00:00 2001 From: "E. Rivas" <224161+erivas@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:09:19 -0300 Subject: [PATCH 1/2] refactor: nits to make hlint-3.6.1 happy --- lib/Echidna/Campaign.hs | 4 ++-- lib/Echidna/Events.hs | 4 ++-- lib/Echidna/Solidity.hs | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Echidna/Campaign.hs b/lib/Echidna/Campaign.hs index 61eb64c5c..3e8638c49 100644 --- a/lib/Echidna/Campaign.hs +++ b/lib/Echidna/Campaign.hs @@ -54,8 +54,8 @@ instance MonadThrow m => MonadThrow (RandT g m) where -- | Given a 'Campaign', check if the test results should be reported as a -- success or a failure. isSuccessful :: [EchidnaTest] -> Bool -isSuccessful tests = - all (\case { Passed -> True; Open -> True; _ -> False; }) ((.state) <$> tests) +isSuccessful = + all (\case { Passed -> True; Open -> True; _ -> False; } . (.state)) -- | Run all the transaction sequences from the corpus and accumulate campaign -- state. Can be used to minimize corpus as the final campaign state will diff --git a/lib/Echidna/Events.hs b/lib/Echidna/Events.hs index c9c93480a..82c474d05 100644 --- a/lib/Echidna/Events.hs +++ b/lib/Echidna/Events.hs @@ -7,7 +7,7 @@ import Data.ByteString qualified as BS import Data.ByteString.Lazy (fromStrict) import Data.Map (Map) import Data.Map qualified as Map -import Data.Maybe (fromJust, catMaybes, maybeToList) +import Data.Maybe (fromJust, catMaybes, mapMaybe, maybeToList) import Data.Text (pack, Text) import Data.Tree (flatten) import Data.Tree.Zipper (fromForest, TreePos, Empty) @@ -33,7 +33,7 @@ extractEvents :: Bool -> DappInfo -> VM -> Events extractEvents decodeErrors dappInfo vm = let forest = traceForest vm in maybeToList (decodeRevert decodeErrors vm) - ++ catMaybes (concatMap flatten (fmap (fmap showTrace) forest)) + ++ concatMap ((catMaybes . flatten) . fmap showTrace) forest where showTrace trace = let ?context = DappContext { info = dappInfo, env = vm.env.contracts } in diff --git a/lib/Echidna/Solidity.hs b/lib/Echidna/Solidity.hs index 3cb9af09d..1d3f70361 100644 --- a/lib/Echidna/Solidity.hs +++ b/lib/Echidna/Solidity.hs @@ -12,7 +12,7 @@ import Data.List.NonEmpty (NonEmpty((:|))) import Data.List.NonEmpty qualified as NE import Data.List.NonEmpty.Extra qualified as NEE import Data.Map qualified as Map -import Data.Maybe (isJust, isNothing, catMaybes, listToMaybe) +import Data.Maybe (isJust, isNothing, catMaybes, listToMaybe, mapMaybe) import Data.Set (Set) import Data.Set qualified as Set import Data.Text (Text, isPrefixOf, isSuffixOf, append) @@ -211,11 +211,12 @@ loadSpecified env name cs = do -- Construct ABI mapping for World abiMapping = if solConf.allContracts then - Map.fromList $ catMaybes $ cs <&> \contract -> - let filtered = filterMethods contract.contractName - solConf.methodFilter - (abiOf solConf.prefix contract) - in (getBytecodeMetadata contract.runtimeCode,) <$> NE.nonEmpty filtered + Map.fromList $ mapMaybe (\contract -> + let filtered = filterMethods contract.contractName + solConf.methodFilter + (abiOf solConf.prefix contract) + in (getBytecodeMetadata contract.runtimeCode,) <$> NE.nonEmpty filtered) + cs else case NE.nonEmpty fabiOfc of Just ne -> Map.singleton (getBytecodeMetadata mainContract.runtimeCode) ne From dd149d65053c3b361615599a5750308792051430 Mon Sep 17 00:00:00 2001 From: "E. Rivas" <224161+erivas@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:19:04 -0300 Subject: [PATCH 2/2] refactor: remove redundant import --- lib/Echidna/Events.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Echidna/Events.hs b/lib/Echidna/Events.hs index 82c474d05..ff1427459 100644 --- a/lib/Echidna/Events.hs +++ b/lib/Echidna/Events.hs @@ -7,7 +7,7 @@ import Data.ByteString qualified as BS import Data.ByteString.Lazy (fromStrict) import Data.Map (Map) import Data.Map qualified as Map -import Data.Maybe (fromJust, catMaybes, mapMaybe, maybeToList) +import Data.Maybe (fromJust, catMaybes, maybeToList) import Data.Text (pack, Text) import Data.Tree (flatten) import Data.Tree.Zipper (fromForest, TreePos, Empty)