mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-26 03:04:48 +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
|
lintWithVisitors : List (Visitor context) -> LintRule context -> List Error
|
||||||
lint statements rule =
|
lintWithVisitors visitors rule =
|
||||||
let
|
let
|
||||||
visitors =
|
|
||||||
List.concatMap statementToVisitors statements
|
|
||||||
|
|
||||||
( errors, _ ) =
|
( errors, _ ) =
|
||||||
List.foldl
|
List.foldl
|
||||||
(\visitor ( errors, ctx ) ->
|
(\visitor ( errors, ctx ) ->
|
||||||
@ -112,3 +109,8 @@ lint statements rule =
|
|||||||
visitors
|
visitors
|
||||||
in
|
in
|
||||||
errors
|
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.map (\( _, _, statements ) -> statements)
|
||||||
|> Result.withDefault []
|
|> Result.withDefault []
|
||||||
|
|
||||||
|
lint =
|
||||||
|
Lint.lint statements
|
||||||
|
|
||||||
errors =
|
errors =
|
||||||
List.concat
|
List.concat
|
||||||
[ Lint.lint statements FindNoAnnotatedFunction.rule
|
[ lint FindNoAnnotatedFunction.rule
|
||||||
, Lint.lint statements NoDebug.rule
|
, lint NoDebug.rule
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
div [] (List.map (\x -> p [] [ text x ]) errors)
|
div [] (List.map (\x -> p [] [ text x ]) errors)
|
||||||
|
Loading…
Reference in New Issue
Block a user