Check for configuration errors

This commit is contained in:
Jeroen Engels 2021-03-10 00:29:52 +01:00
parent eafb0876f5
commit 8ceb7e5c06

View File

@ -492,7 +492,8 @@ to compare them or the model that holds them.
-}
reviewV2 : List Rule -> Maybe ProjectData -> Project -> { errors : List ReviewError, rules : List Rule, projectData : Maybe ProjectData }
reviewV2 rules maybeProjectData project =
checkForModulesThatFailedToParse project
checkForConfigurationErrors rules
|> Result.andThen (\() -> checkForModulesThatFailedToParse project)
|> Result.andThen (\() -> checkForDuplicateModules project)
|> Result.andThen (\() -> getModulesSortedByImport project)
|> Result.map (runReview project rules maybeProjectData)
@ -506,6 +507,37 @@ reviewV2 rules maybeProjectData project =
|> extractResultValue
checkForConfigurationErrors : List Rule -> Result (List ReviewError) ()
checkForConfigurationErrors rules =
let
errors : List ReviewError
errors =
List.filterMap
(\rule ->
Maybe.map
(\{ message, details } ->
SpecifiedError
{ filePath = "CONFIGURATION ERROR"
, ruleName = ruleName rule
, message = message
, details = details
, range = Range.emptyRange
, fixes = Nothing
, target = Review.Error.Global
}
|> errorToReviewError
)
(getConfigurationError rule)
)
rules
in
if List.isEmpty errors then
Ok ()
else
Err errors
checkForModulesThatFailedToParse : Project -> Result (List ReviewError) ()
checkForModulesThatFailedToParse project =
case Review.Project.modulesThatFailedToParse project of