Avoid List.head

This commit is contained in:
Jeroen Engels 2024-05-07 18:48:00 +02:00
parent 1c072d4b92
commit 04102ce097

View File

@ -1038,20 +1038,19 @@ maybeCons mapper maybe list =
expectErrorsForModulesHelp : RuleCanProvideFixes -> List ( String, List ExpectedError ) -> List SuccessfulRunResult -> Expectation expectErrorsForModulesHelp : RuleCanProvideFixes -> List ( String, List ExpectedError ) -> List SuccessfulRunResult -> Expectation
expectErrorsForModulesHelp ruleCanProvideFixes expectedErrorsList runResults = expectErrorsForModulesHelp ruleCanProvideFixes expectedErrorsList runResults =
let let
maybeUnknownModule : Maybe String unknownModules : List String
maybeUnknownModule = unknownModules =
Set.diff Set.diff
(expectedErrorsList |> List.map Tuple.first |> Set.fromList) (expectedErrorsList |> List.map Tuple.first |> Set.fromList)
(Set.fromList (List.map .moduleName runResults)) (Set.fromList (List.map .moduleName runResults))
|> Set.toList |> Set.toList
|> List.head
in in
case maybeUnknownModule of case unknownModules of
Just unknownModule -> unknownModule :: _ ->
FailureMessage.unknownModulesInExpectedErrors unknownModule FailureMessage.unknownModulesInExpectedErrors unknownModule
|> Expect.fail |> Expect.fail
Nothing -> [] ->
Expect.all Expect.all
(expectErrorsForModuleFiles ruleCanProvideFixes expectedErrorsList runResults) (expectErrorsForModuleFiles ruleCanProvideFixes expectedErrorsList runResults)
() ()