mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-25 18:51:41 +03:00
Compute visitors only once for a given input
This commit is contained in:
parent
3c27a18207
commit
a491c97059
12
Lint.elm
12
Lint.elm
@ -93,12 +93,9 @@ statementToVisitors node =
|
||||
[]
|
||||
|
||||
|
||||
lint : List Statement -> LintRule context -> List Error
|
||||
lint statements rule =
|
||||
lintWithVisitors : List (Visitor context) -> LintRule context -> List Error
|
||||
lintWithVisitors visitors rule =
|
||||
let
|
||||
visitors =
|
||||
List.concatMap statementToVisitors statements
|
||||
|
||||
( errors, _ ) =
|
||||
List.foldl
|
||||
(\visitor ( errors, ctx ) ->
|
||||
@ -112,3 +109,8 @@ lint statements rule =
|
||||
visitors
|
||||
in
|
||||
errors
|
||||
|
||||
|
||||
lint : List Statement -> LintRule context -> List Error
|
||||
lint statements =
|
||||
lintWithVisitors (List.concatMap statementToVisitors statements)
|
||||
|
@ -100,10 +100,13 @@ lint ast =
|
||||
|> Result.map (\( _, _, statements ) -> statements)
|
||||
|> Result.withDefault []
|
||||
|
||||
lint =
|
||||
Lint.lint statements
|
||||
|
||||
errors =
|
||||
List.concat
|
||||
[ Lint.lint statements FindNoAnnotatedFunction.rule
|
||||
, Lint.lint statements NoDebug.rule
|
||||
[ lint FindNoAnnotatedFunction.rule
|
||||
, lint NoDebug.rule
|
||||
]
|
||||
in
|
||||
div [] (List.map (\x -> p [] [ text x ]) errors)
|
||||
|
Loading…
Reference in New Issue
Block a user