From 17c9c0e30fdc3eb5a63db1a96c67d57e9cf02d3c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 8 Apr 2020 16:31:04 +0200 Subject: [PATCH] Do not fail with missing sources if there are modules added through the project --- src/Review/Test.elm | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Review/Test.elm b/src/Review/Test.elm index 5346acfd..a4bd53e9 100644 --- a/src/Review/Test.elm +++ b/src/Review/Test.elm @@ -322,39 +322,39 @@ interested in project related details, then you should use [`runOnModules`](#run -} runOnModulesWithProjectData : Project -> Rule -> List String -> ReviewResult runOnModulesWithProjectData project rule sources = - if List.isEmpty sources then - FailedRun ErrorMessage.missingSources - - else - let - projectWithModules : Project - projectWithModules = - sources - |> List.indexedMap - (\index source -> - { path = "TestContent_" ++ String.fromInt index ++ ".elm" - , source = source - } - ) - |> List.foldl Project.addModule project - in - case Project.modulesThatFailedToParse projectWithModules of - { source } :: _ -> - let - fileAndIndex : { source : String, index : Int } - fileAndIndex = - { source = source - , index = indexOf source sources |> Maybe.withDefault -1 + let + projectWithModules : Project + projectWithModules = + sources + |> List.indexedMap + (\index source -> + { path = "TestContent_" ++ String.fromInt index ++ ".elm" + , source = source } - in - FailedRun <| ErrorMessage.parsingFailure (List.length sources == 1) fileAndIndex + ) + |> List.foldl Project.addModule project + in + case Project.modulesThatFailedToParse projectWithModules of + { source } :: _ -> + let + fileAndIndex : { source : String, index : Int } + fileAndIndex = + { source = source + , index = indexOf source sources |> Maybe.withDefault -1 + } + in + FailedRun <| ErrorMessage.parsingFailure (List.length sources == 1) fileAndIndex - [] -> - let - modules : List ProjectModule - modules = - Project.modules projectWithModules - in + [] -> + let + modules : List ProjectModule + modules = + Project.modules projectWithModules + in + if List.isEmpty modules then + FailedRun ErrorMessage.missingSources + + else case findDuplicateModuleNames Set.empty modules of Just moduleName -> FailedRun <| ErrorMessage.duplicateModuleName moduleName