mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-27 02:19:27 +03:00
Add phantom type variable to Error in other files than Review.Rule
This commit is contained in:
parent
422400d929
commit
31cd0c6691
@ -66,7 +66,7 @@ type alias Context =
|
||||
}
|
||||
|
||||
|
||||
error : Node a -> Error
|
||||
error : Node a -> Error {}
|
||||
error node =
|
||||
Rule.error
|
||||
{ message = "Remove the use of `Debug.log` before shipping to production"
|
||||
@ -112,7 +112,7 @@ isLog node =
|
||||
False
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List Error, Context )
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor node direction context =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Expression.FunctionOrValue [ "Debug" ] "log" ) ->
|
||||
|
@ -107,7 +107,7 @@ init =
|
||||
}
|
||||
|
||||
|
||||
error : Node a -> String -> Error
|
||||
error : Node a -> String -> Error {}
|
||||
error node name =
|
||||
Rule.error
|
||||
{ message = "Remove the use of `Debug." ++ name ++ "` before shipping to production"
|
||||
@ -158,7 +158,7 @@ is name node =
|
||||
False
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List Error, Context )
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor node direction context =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Expression.FunctionOrValue [ "Debug" ] name ) ->
|
||||
|
@ -43,7 +43,7 @@ moduleDefinitionVisitor node context =
|
||||
( [], { context | allowed = HtmlButtonIsForbidden } )
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Direction -> Context -> ( List Error, Context )
|
||||
expressionVisitor : Node Expression -> Direction -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor node direction context =
|
||||
case ( direction, context.allowed ) of
|
||||
( Rule.OnEnter, HtmlButtonIsAllowed ) ->
|
||||
|
@ -121,7 +121,7 @@ initialProjectContext =
|
||||
-- FINAL EVALUATION
|
||||
|
||||
|
||||
finalEvaluationForProject : Configuration -> ProjectContext -> List Error
|
||||
finalEvaluationForProject : Configuration -> ProjectContext -> List (Error {})
|
||||
finalEvaluationForProject configuration projectContext =
|
||||
case projectContext.elmJsonKey of
|
||||
Just elmJsonKey ->
|
||||
|
@ -12,7 +12,7 @@ rule =
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
|
||||
commentsVisitor : List (Node String) -> List Error
|
||||
commentsVisitor : List (Node String) -> List (Error {})
|
||||
commentsVisitor comments =
|
||||
comments
|
||||
|> List.concatMap
|
||||
@ -22,7 +22,7 @@ commentsVisitor comments =
|
||||
)
|
||||
|
||||
|
||||
errorAtPosition : Node String -> Int -> Error
|
||||
errorAtPosition : Node String -> Int -> Error {}
|
||||
errorAtPosition node index =
|
||||
Rule.error
|
||||
{ message = "TODO needs to be handled"
|
||||
|
@ -451,7 +451,7 @@ isCapitalized name =
|
||||
-- FINAL PROJECT EVALUATION
|
||||
|
||||
|
||||
finalProjectEvaluation : ProjectContext -> List Error
|
||||
finalProjectEvaluation : ProjectContext -> List (Error {})
|
||||
finalProjectEvaluation projectContext =
|
||||
projectContext.exposedConstructors
|
||||
|> Dict.toList
|
||||
@ -490,7 +490,7 @@ errorInformation node =
|
||||
}
|
||||
|
||||
|
||||
errorForModule : Rule.ModuleKey -> Node String -> Error
|
||||
errorForModule : Rule.ModuleKey -> Node String -> Error scope
|
||||
errorForModule moduleKey node =
|
||||
Rule.errorForModule
|
||||
moduleKey
|
||||
|
@ -187,7 +187,7 @@ moduleNameForImport node =
|
||||
-- FINAL EVALUATION
|
||||
|
||||
|
||||
finalEvaluationForProject : ProjectContext -> List Error
|
||||
finalEvaluationForProject : ProjectContext -> List (Error {})
|
||||
finalEvaluationForProject projectContext =
|
||||
case projectContext.elmJsonKey of
|
||||
Just elmJsonKey ->
|
||||
@ -203,7 +203,7 @@ finalEvaluationForProject projectContext =
|
||||
[]
|
||||
|
||||
|
||||
error : Rule.ElmJsonKey -> String -> Error
|
||||
error : Rule.ElmJsonKey -> String -> Error {}
|
||||
error elmJsonKey packageName =
|
||||
Rule.errorForElmJson elmJsonKey
|
||||
(\elmJson ->
|
||||
|
@ -202,7 +202,7 @@ elmJsonVisitor maybeProject projectContext =
|
||||
-- PROJECT EVALUATION
|
||||
|
||||
|
||||
finalEvaluationForProject : ProjectContext -> List Error
|
||||
finalEvaluationForProject : ProjectContext -> List (Error {})
|
||||
finalEvaluationForProject projectContext =
|
||||
projectContext.modules
|
||||
|> removeExposedPackages projectContext
|
||||
@ -214,7 +214,7 @@ finalEvaluationForProject projectContext =
|
||||
|> removeReviewConfig moduleName
|
||||
|> Dict.filter (\name _ -> not <| Set.member ( moduleName, name ) projectContext.used)
|
||||
|> Dict.toList
|
||||
|> List.map
|
||||
|> List.concatMap
|
||||
(\( name, { range, exposedElement } ) ->
|
||||
let
|
||||
what : String
|
||||
@ -229,11 +229,17 @@ finalEvaluationForProject projectContext =
|
||||
ExposedType ->
|
||||
"Exposed type"
|
||||
in
|
||||
Rule.errorForModule moduleKey
|
||||
[ Rule.error
|
||||
{ message = what ++ " `" ++ name ++ "` is never used outside this module."
|
||||
, details = [ "This exposed element is never used. You may want to remove it to keep your project clean, and maybe detect some unused code in your project." ]
|
||||
}
|
||||
range
|
||||
, Rule.errorForModule moduleKey
|
||||
{ message = what ++ " `" ++ name ++ "` is never used outside this module."
|
||||
, details = [ "This exposed element is never used. You may want to remove it to keep your project clean, and maybe detect some unused code in your project." ]
|
||||
}
|
||||
range
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@ -495,7 +501,7 @@ collectTypesFromTypeAnnotation scope node =
|
||||
-- EXPRESSION VISITOR
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> ModuleContext -> ( List Error, ModuleContext )
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> ModuleContext -> ( List (Error scope), ModuleContext )
|
||||
expressionVisitor node direction moduleContext =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Expression.FunctionOrValue moduleName name ) ->
|
||||
|
@ -159,7 +159,7 @@ elmJsonVisitor maybeProject projectContext =
|
||||
)
|
||||
|
||||
|
||||
finalEvaluationForProject : ProjectContext -> List Error
|
||||
finalEvaluationForProject : ProjectContext -> List (Error scope)
|
||||
finalEvaluationForProject { modules, usedModules } =
|
||||
modules
|
||||
|> Dict.filter (\moduleName _ -> not <| Set.member moduleName usedModules)
|
||||
@ -167,7 +167,7 @@ finalEvaluationForProject { modules, usedModules } =
|
||||
|> List.map error
|
||||
|
||||
|
||||
error : ( ModuleName, { moduleKey : Rule.ModuleKey, moduleNameLocation : Range } ) -> Error
|
||||
error : ( ModuleName, { moduleKey : Rule.ModuleKey, moduleNameLocation : Range } ) -> Error scope
|
||||
error ( moduleName, { moduleKey, moduleNameLocation } ) =
|
||||
Rule.errorForModule moduleKey
|
||||
{ message = "Module `" ++ String.join "." moduleName ++ "` is never used."
|
||||
|
@ -43,7 +43,7 @@ elmJsonVisitor maybeProject projectContext =
|
||||
-- README VISITOR
|
||||
|
||||
|
||||
readmeVisitor : Maybe { readmeKey : Rule.ReadmeKey, content : String } -> ProjectContext -> ( List Error, ProjectContext )
|
||||
readmeVisitor : Maybe { readmeKey : Rule.ReadmeKey, content : String } -> ProjectContext -> ( List (Error scope), ProjectContext )
|
||||
readmeVisitor maybeReadme context =
|
||||
case ( maybeReadme, context.projectTitle ) of
|
||||
( Just { readmeKey, content }, Just projectName ) ->
|
||||
|
43
src/Review/Error.elm
Normal file
43
src/Review/Error.elm
Normal file
@ -0,0 +1,43 @@
|
||||
module Review.Error exposing (InternalError, ReviewError(..), error, withFixes)
|
||||
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Review.Fix exposing (Fix)
|
||||
|
||||
|
||||
type ReviewError
|
||||
= ReviewError InternalError
|
||||
|
||||
|
||||
type alias InternalError =
|
||||
{ message : String
|
||||
, ruleName : String
|
||||
, filePath : String
|
||||
, details : List String
|
||||
, range : Range
|
||||
, fixes : Maybe (List Fix)
|
||||
}
|
||||
|
||||
|
||||
error : { message : String, details : List String } -> Range -> ReviewError
|
||||
error { message, details } range =
|
||||
ReviewError
|
||||
{ message = message
|
||||
, ruleName = ""
|
||||
, filePath = ""
|
||||
, details = details
|
||||
, range = range
|
||||
, fixes = Nothing
|
||||
}
|
||||
|
||||
|
||||
withFixes : List Fix -> ReviewError -> ReviewError
|
||||
withFixes fixes (ReviewError error_) =
|
||||
ReviewError
|
||||
{ error_
|
||||
| fixes =
|
||||
if List.isEmpty fixes || String.endsWith ".json" error_.filePath then
|
||||
Nothing
|
||||
|
||||
else
|
||||
Just fixes
|
||||
}
|
@ -251,6 +251,7 @@ import Elm.Syntax.Module as Module exposing (Module)
|
||||
import Elm.Syntax.ModuleName exposing (ModuleName)
|
||||
import Elm.Syntax.Node as Node exposing (Node)
|
||||
import Elm.Syntax.Range as Range exposing (Range)
|
||||
import Review.Error exposing (InternalError)
|
||||
import Review.Exceptions as Exceptions exposing (Exceptions)
|
||||
import Review.Fix exposing (Fix)
|
||||
import Review.Project exposing (Project, ProjectModule)
|
||||
@ -366,7 +367,7 @@ review rules project =
|
||||
|> List.map (\s -> "\n - " ++ s)
|
||||
|> String.join ""
|
||||
in
|
||||
( [ ReviewError
|
||||
( [ Review.Error.ReviewError
|
||||
{ filePath = "GLOBAL ERROR"
|
||||
, ruleName = "Incorrect project"
|
||||
, message = "Found several modules named `" ++ String.join "." duplicate.moduleName ++ "`"
|
||||
@ -393,7 +394,7 @@ review rules project =
|
||||
in
|
||||
case sortedModules of
|
||||
Err _ ->
|
||||
( [ ReviewError
|
||||
( [ Review.Error.ReviewError
|
||||
{ filePath = "GLOBAL ERROR"
|
||||
, ruleName = "Incorrect project"
|
||||
, message = "Import cycle discovered"
|
||||
@ -2462,18 +2463,8 @@ be reported to the user.
|
||||
If you are building a [`Rule`](#Rule), you shouldn't have to use this.
|
||||
|
||||
-}
|
||||
type ReviewError
|
||||
= ReviewError InternalError
|
||||
|
||||
|
||||
type alias InternalError =
|
||||
{ message : String
|
||||
, ruleName : String
|
||||
, filePath : String
|
||||
, details : List String
|
||||
, range : Range
|
||||
, fixes : Maybe (List Fix)
|
||||
}
|
||||
type alias ReviewError =
|
||||
Review.Error.ReviewError
|
||||
|
||||
|
||||
{-| Create an [`Error`](#Error). Use it when you find a pattern that the rule should forbid.
|
||||
@ -2500,7 +2491,7 @@ In most cases, you can get it using [`Node.range`].
|
||||
[`Node.range`]: https://package.elm-lang.org/packages/stil4m/elm-syntax/7.1.0/Elm-Syntax-Node#range
|
||||
|
||||
-}
|
||||
error : { message : String, details : List String } -> Range -> Error { forCurrentModule : () }
|
||||
error : { message : String, details : List String } -> Range -> Error {}
|
||||
error { message, details } range =
|
||||
UnspecifiedError
|
||||
{ message = message
|
||||
@ -2623,7 +2614,7 @@ errorForReadme (ReadmeKey { path }) { message, details } range =
|
||||
|
||||
parsingError : { path : String, source : String } -> ReviewError
|
||||
parsingError rawFile =
|
||||
ReviewError
|
||||
Review.Error.ReviewError
|
||||
{ filePath = rawFile.path
|
||||
, ruleName = "ParsingError"
|
||||
, message = rawFile.path ++ " is not a correct Elm module"
|
||||
@ -2679,50 +2670,50 @@ withFixes fixes error_ =
|
||||
|
||||
errorToReviewError : Error scope -> ReviewError
|
||||
errorToReviewError error_ =
|
||||
ReviewError (accessInternalError error_)
|
||||
Review.Error.ReviewError (accessInternalError error_)
|
||||
|
||||
|
||||
{-| Get the name of the rule that triggered this [`Error`](#Error).
|
||||
-}
|
||||
errorRuleName : ReviewError -> String
|
||||
errorRuleName (ReviewError err) =
|
||||
errorRuleName : Review.Error.ReviewError -> String
|
||||
errorRuleName (Review.Error.ReviewError err) =
|
||||
err.ruleName
|
||||
|
||||
|
||||
{-| Get the error message of an [`Error`](#Error).
|
||||
-}
|
||||
errorMessage : ReviewError -> String
|
||||
errorMessage (ReviewError err) =
|
||||
errorMessage : Review.Error.ReviewError -> String
|
||||
errorMessage (Review.Error.ReviewError err) =
|
||||
err.message
|
||||
|
||||
|
||||
{-| Get the error details of an [`Error`](#Error).
|
||||
-}
|
||||
errorDetails : ReviewError -> List String
|
||||
errorDetails (ReviewError err) =
|
||||
errorDetails : Review.Error.ReviewError -> List String
|
||||
errorDetails (Review.Error.ReviewError err) =
|
||||
err.details
|
||||
|
||||
|
||||
{-| Get the [`Range`](https://package.elm-lang.org/packages/stil4m/elm-syntax/7.1.0/Elm-Syntax-Range)
|
||||
of an [`Error`](#Error).
|
||||
-}
|
||||
errorRange : ReviewError -> Range
|
||||
errorRange (ReviewError err) =
|
||||
errorRange : Review.Error.ReviewError -> Range
|
||||
errorRange (Review.Error.ReviewError err) =
|
||||
err.range
|
||||
|
||||
|
||||
{-| Get the automatic [`fixes`](./Review-Fix#Fix) of an [`Error`](#Error), if it
|
||||
defined any.
|
||||
-}
|
||||
errorFixes : ReviewError -> Maybe (List Fix)
|
||||
errorFixes (ReviewError err) =
|
||||
errorFixes : Review.Error.ReviewError -> Maybe (List Fix)
|
||||
errorFixes (Review.Error.ReviewError err) =
|
||||
err.fixes
|
||||
|
||||
|
||||
{-| Get the file path of an [`Error`](#Error).
|
||||
-}
|
||||
errorFilePath : ReviewError -> String
|
||||
errorFilePath (ReviewError err) =
|
||||
errorFilePath : Review.Error.ReviewError -> String
|
||||
errorFilePath (Review.Error.ReviewError err) =
|
||||
err.filePath
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ import Elm.Syntax.Range exposing (Range)
|
||||
import Expect exposing (Expectation)
|
||||
import Review.Fix as Fix
|
||||
import Review.Project as Project exposing (Project, ProjectModule)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Review.Rule as Rule exposing (ReviewError, Rule)
|
||||
import Review.Test.ErrorMessage as ErrorMessage
|
||||
import Set exposing (Set)
|
||||
import Vendor.ListExtra as ListExtra
|
||||
@ -129,14 +129,14 @@ type ReviewResult
|
||||
type alias SuccessfulRunResult =
|
||||
{ moduleName : String
|
||||
, inspector : CodeInspector
|
||||
, errors : List Error
|
||||
, errors : List ReviewError
|
||||
}
|
||||
|
||||
|
||||
type alias CodeInspector =
|
||||
{ source : String
|
||||
, getCodeAtLocation : Range -> Maybe String
|
||||
, checkIfLocationIsAmbiguous : Error -> String -> Expectation
|
||||
, checkIfLocationIsAmbiguous : ReviewError -> String -> Expectation
|
||||
}
|
||||
|
||||
|
||||
@ -359,7 +359,7 @@ runOnModulesWithProjectData project rule sources =
|
||||
|
||||
Nothing ->
|
||||
let
|
||||
errors : List Error
|
||||
errors : List ReviewError
|
||||
errors =
|
||||
projectWithModules
|
||||
|> Rule.review [ rule ]
|
||||
@ -378,7 +378,7 @@ runOnModulesWithProjectData project rule sources =
|
||||
|> SuccessfulRun
|
||||
|
||||
|
||||
moduleToRunResult : List Error -> ProjectModule -> SuccessfulRunResult
|
||||
moduleToRunResult : List ReviewError -> ProjectModule -> SuccessfulRunResult
|
||||
moduleToRunResult errors projectModule =
|
||||
{ moduleName =
|
||||
projectModule.ast.moduleDefinition
|
||||
@ -393,7 +393,7 @@ moduleToRunResult errors projectModule =
|
||||
}
|
||||
|
||||
|
||||
elmJsonRunResult : List Error -> Project -> List SuccessfulRunResult
|
||||
elmJsonRunResult : List ReviewError -> Project -> List SuccessfulRunResult
|
||||
elmJsonRunResult errors project =
|
||||
case Project.elmJson project of
|
||||
Just elmJsonData ->
|
||||
@ -412,7 +412,7 @@ elmJsonRunResult errors project =
|
||||
[]
|
||||
|
||||
|
||||
readmeRunResult : List Error -> Project -> List SuccessfulRunResult
|
||||
readmeRunResult : List ReviewError -> Project -> List SuccessfulRunResult
|
||||
readmeRunResult errors project =
|
||||
case Project.readme project of
|
||||
Just readme ->
|
||||
@ -475,7 +475,7 @@ findDuplicateModuleNames previousModuleNames modules =
|
||||
findDuplicateModuleNames (Set.insert moduleName previousModuleNames) restOfModules
|
||||
|
||||
|
||||
compareErrorPositions : Error -> Error -> Order
|
||||
compareErrorPositions : ReviewError -> ReviewError -> Order
|
||||
compareErrorPositions a b =
|
||||
compareRange (Rule.errorRange a) (Rule.errorRange b)
|
||||
|
||||
@ -923,7 +923,7 @@ getCodeAtLocationInSourceCode sourceCode =
|
||||
|> Just
|
||||
|
||||
|
||||
checkIfLocationIsAmbiguousInSourceCode : SourceCode -> Error -> String -> Expectation
|
||||
checkIfLocationIsAmbiguousInSourceCode : SourceCode -> ReviewError -> String -> Expectation
|
||||
checkIfLocationIsAmbiguousInSourceCode sourceCode error_ under =
|
||||
let
|
||||
occurrencesInSourceCode : List Int
|
||||
@ -945,7 +945,7 @@ checkAllErrorsMatch runResult expectedErrors =
|
||||
|> (\expectations -> Expect.all expectations ())
|
||||
|
||||
|
||||
checkErrorsMatch : SuccessfulRunResult -> List ExpectedError -> List Error -> List (() -> Expectation)
|
||||
checkErrorsMatch : SuccessfulRunResult -> List ExpectedError -> List ReviewError -> List (() -> Expectation)
|
||||
checkErrorsMatch runResult expectedErrors errors =
|
||||
case ( expectedErrors, errors ) of
|
||||
( [], [] ) ->
|
||||
@ -962,7 +962,7 @@ checkErrorsMatch runResult expectedErrors errors =
|
||||
[ always <| Expect.fail <| ErrorMessage.tooManyErrors runResult.moduleName (error_ :: restOfErrors) ]
|
||||
|
||||
|
||||
checkErrorMatch : CodeInspector -> ExpectedError -> Error -> (() -> Expectation)
|
||||
checkErrorMatch : CodeInspector -> ExpectedError -> ReviewError -> (() -> Expectation)
|
||||
checkErrorMatch codeInspector ((ExpectedError expectedError_) as expectedError) error_ =
|
||||
Expect.all
|
||||
[ \() ->
|
||||
@ -978,7 +978,7 @@ checkErrorMatch codeInspector ((ExpectedError expectedError_) as expectedError)
|
||||
]
|
||||
|
||||
|
||||
checkMessageAppearsUnder : CodeInspector -> Error -> ExpectedError -> (() -> Expectation)
|
||||
checkMessageAppearsUnder : CodeInspector -> ReviewError -> ExpectedError -> (() -> Expectation)
|
||||
checkMessageAppearsUnder codeInspector error_ (ExpectedError expectedError) =
|
||||
case codeInspector.getCodeAtLocation (Rule.errorRange error_) of
|
||||
Just codeAtLocation ->
|
||||
@ -1018,7 +1018,7 @@ checkMessageAppearsUnder codeInspector error_ (ExpectedError expectedError) =
|
||||
|> Expect.fail
|
||||
|
||||
|
||||
checkDetailsAreCorrect : Error -> ExpectedError -> (() -> Expectation)
|
||||
checkDetailsAreCorrect : ReviewError -> ExpectedError -> (() -> Expectation)
|
||||
checkDetailsAreCorrect error_ (ExpectedError expectedError) =
|
||||
Expect.all
|
||||
[ (not <| List.isEmpty <| Rule.errorDetails error_)
|
||||
@ -1030,7 +1030,7 @@ checkDetailsAreCorrect error_ (ExpectedError expectedError) =
|
||||
]
|
||||
|
||||
|
||||
checkFixesAreCorrect : CodeInspector -> Error -> ExpectedError -> Expectation
|
||||
checkFixesAreCorrect : CodeInspector -> ReviewError -> ExpectedError -> Expectation
|
||||
checkFixesAreCorrect codeInspector error_ ((ExpectedError expectedError_) as expectedError) =
|
||||
case ( expectedError_.fixedSource, Rule.errorFixes error_ ) of
|
||||
( Nothing, Nothing ) ->
|
||||
|
@ -6,10 +6,10 @@ module Review.Test.ErrorMessage exposing
|
||||
, missingFixes, unexpectedFixes, fixedCodeMismatch, unchangedSourceAfterFix, invalidSourceAfterFix, hasCollisionsInFixRanges
|
||||
)
|
||||
|
||||
{-| Error messages for the `Review.Test` module.
|
||||
{-| ReviewError messages for the `Review.Test` module.
|
||||
|
||||
|
||||
# Error messages
|
||||
# ReviewError messages
|
||||
|
||||
@docs ExpectedErrorData
|
||||
@docs parsingFailure, globalErrorInTest, messageMismatch, emptyDetails, unexpectedDetails, wrongLocation, didNotExpectErrors
|
||||
@ -20,7 +20,7 @@ module Review.Test.ErrorMessage exposing
|
||||
-}
|
||||
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Review.Rule as Rule exposing (Error)
|
||||
import Review.Rule as Rule exposing (ReviewError)
|
||||
import Vendor.ListExtra as ListExtra
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ type alias SourceCode =
|
||||
-- ERROR MESSAGES
|
||||
|
||||
|
||||
didNotExpectErrors : String -> List Error -> String
|
||||
didNotExpectErrors : String -> List ReviewError -> String
|
||||
didNotExpectErrors moduleName errors =
|
||||
"""DID NOT EXPECT ERRORS
|
||||
|
||||
@ -83,7 +83,7 @@ The source code in question is the one at index """
|
||||
title ++ "\n\n" ++ details ++ "\n\n" ++ hint
|
||||
|
||||
|
||||
globalErrorInTest : Error -> String
|
||||
globalErrorInTest : ReviewError -> String
|
||||
globalErrorInTest error =
|
||||
"""GLOBAL ERROR IN SOURCE CODE
|
||||
|
||||
@ -98,7 +98,7 @@ the same issue. Please fix this issue in your test.
|
||||
"""
|
||||
|
||||
|
||||
messageMismatch : ExpectedErrorData -> Error -> String
|
||||
messageMismatch : ExpectedErrorData -> ReviewError -> String
|
||||
messageMismatch expectedError error =
|
||||
"""UNEXPECTED ERROR MESSAGE
|
||||
|
||||
@ -111,7 +111,7 @@ but I found the following error message:
|
||||
""" ++ wrapInQuotes (Rule.errorMessage error)
|
||||
|
||||
|
||||
underMismatch : Error -> { under : String, codeAtLocation : String } -> String
|
||||
underMismatch : ReviewError -> { under : String, codeAtLocation : String } -> String
|
||||
underMismatch error { under, codeAtLocation } =
|
||||
"""UNEXPECTED ERROR LOCATION
|
||||
|
||||
@ -131,7 +131,7 @@ Hint: Maybe you're passing the `Range` of a wrong node when
|
||||
calling `Rule.error`."""
|
||||
|
||||
|
||||
unexpectedDetails : List String -> Error -> String
|
||||
unexpectedDetails : List String -> ReviewError -> String
|
||||
unexpectedDetails expectedDetails error =
|
||||
"""UNEXPECTED ERROR DETAILS
|
||||
|
||||
@ -148,7 +148,7 @@ when I was expecting them to be:
|
||||
""" ++ formatDetails expectedDetails
|
||||
|
||||
|
||||
emptyDetails : Error -> String
|
||||
emptyDetails : ReviewError -> String
|
||||
emptyDetails error =
|
||||
"""EMPTY ERROR DETAILS
|
||||
|
||||
@ -177,7 +177,7 @@ formatDetails details =
|
||||
|> (\str -> "```\n" ++ str ++ "\n ```")
|
||||
|
||||
|
||||
wrongLocation : Error -> Range -> String -> String
|
||||
wrongLocation : ReviewError -> Range -> String -> String
|
||||
wrongLocation error range under =
|
||||
"""UNEXPECTED ERROR LOCATION
|
||||
|
||||
@ -217,7 +217,7 @@ I expected to see """
|
||||
)
|
||||
|
||||
|
||||
tooManyErrors : String -> List Error -> String
|
||||
tooManyErrors : String -> List ReviewError -> String
|
||||
tooManyErrors moduleName extraErrors =
|
||||
let
|
||||
numberOfErrors : Int
|
||||
@ -231,7 +231,7 @@ I found """
|
||||
++ listErrorMessagesAndPositions extraErrors
|
||||
|
||||
|
||||
locationNotFound : Error -> String
|
||||
locationNotFound : ReviewError -> String
|
||||
locationNotFound error =
|
||||
"""COULD NOT FIND LOCATION FOR ERROR
|
||||
|
||||
@ -264,7 +264,7 @@ If this helps, this is where I found the error:
|
||||
""" ++ formatSourceCode codeAtLocation
|
||||
|
||||
|
||||
locationIsAmbiguousInSourceCode : SourceCode -> Error -> String -> List Int -> String
|
||||
locationIsAmbiguousInSourceCode : SourceCode -> ReviewError -> String -> List Int -> String
|
||||
locationIsAmbiguousInSourceCode sourceCode error under occurrencesInSourceCode =
|
||||
"""AMBIGUOUS ERROR LOCATION
|
||||
|
||||
@ -360,7 +360,7 @@ Hint: Maybe you forgot to call `Rule.withFixes` on the error that you
|
||||
created, or maybe the list of provided fixes was empty."""
|
||||
|
||||
|
||||
unexpectedFixes : Error -> String
|
||||
unexpectedFixes : ReviewError -> String
|
||||
unexpectedFixes error =
|
||||
"""UNEXPECTED FIXES
|
||||
|
||||
@ -384,7 +384,7 @@ To fix this, you can call `Review.Test.whenFixed` on your error:
|
||||
|> Review.Test.whenFixed "<source code>\""""
|
||||
|
||||
|
||||
fixedCodeMismatch : SourceCode -> SourceCode -> Error -> String
|
||||
fixedCodeMismatch : SourceCode -> SourceCode -> ReviewError -> String
|
||||
fixedCodeMismatch resultingSourceCode expectedSourceCode error =
|
||||
"""FIXED CODE MISMATCH
|
||||
|
||||
@ -402,7 +402,7 @@ but I was expecting:
|
||||
""" ++ formatSourceCode expectedSourceCode
|
||||
|
||||
|
||||
unchangedSourceAfterFix : Error -> String
|
||||
unchangedSourceAfterFix : ReviewError -> String
|
||||
unchangedSourceAfterFix error =
|
||||
"""UNCHANGED SOURCE AFTER FIX
|
||||
|
||||
@ -421,7 +421,7 @@ doesn't do anything.
|
||||
Hint: Maybe you inserted an empty string into the source code."""
|
||||
|
||||
|
||||
invalidSourceAfterFix : Error -> SourceCode -> String
|
||||
invalidSourceAfterFix : ReviewError -> SourceCode -> String
|
||||
invalidSourceAfterFix error resultingSourceCode =
|
||||
"""INVALID SOURCE AFTER FIX
|
||||
|
||||
@ -442,7 +442,7 @@ anymore. If a fix can not be applied fully, it should not be applied at
|
||||
all."""
|
||||
|
||||
|
||||
hasCollisionsInFixRanges : Error -> String
|
||||
hasCollisionsInFixRanges : ReviewError -> String
|
||||
hasCollisionsInFixRanges error =
|
||||
"""FOUND COLLISIONS IN FIX RANGES
|
||||
|
||||
@ -555,14 +555,14 @@ positionAsRange sourceCode under position =
|
||||
}
|
||||
|
||||
|
||||
listErrorMessagesAndPositions : List Error -> String
|
||||
listErrorMessagesAndPositions : List ReviewError -> String
|
||||
listErrorMessagesAndPositions errors =
|
||||
errors
|
||||
|> List.map errorMessageAndPosition
|
||||
|> String.join "\n"
|
||||
|
||||
|
||||
errorMessageAndPosition : Error -> String
|
||||
errorMessageAndPosition : ReviewError -> String
|
||||
errorMessageAndPosition error =
|
||||
" - " ++ wrapInQuotes (Rule.errorMessage error) ++ "\n at " ++ rangeAsString (Rule.errorRange error)
|
||||
|
||||
|
@ -2,8 +2,8 @@ module ErrorMessageTest exposing (all)
|
||||
|
||||
import Elm.Syntax.Range exposing (Range)
|
||||
import Expect exposing (Expectation)
|
||||
import Review.Error exposing (ReviewError)
|
||||
import Review.Fix as Fix
|
||||
import Review.Rule as Rule exposing (Error)
|
||||
import Review.Test.ErrorMessage as ErrorMessage exposing (ExpectedErrorData)
|
||||
import Test exposing (Test, describe, test)
|
||||
|
||||
@ -91,14 +91,14 @@ didNotExpectErrorsTest =
|
||||
test "didNotExpectErrors" <|
|
||||
\() ->
|
||||
let
|
||||
errors : List Error
|
||||
errors : List ReviewError
|
||||
errors =
|
||||
[ Rule.error
|
||||
[ Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
dummyRange
|
||||
, Rule.error
|
||||
, Review.Error.error
|
||||
{ message = "Some other error"
|
||||
, details = [ "Some other details" ]
|
||||
}
|
||||
@ -130,9 +130,9 @@ messageMismatchTest =
|
||||
, under = "Debug.log"
|
||||
}
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -157,9 +157,9 @@ underMismatchTest =
|
||||
[ test "with single-line extracts" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -190,9 +190,9 @@ calling `Rule.error`."""
|
||||
, test "with multi-line extracts" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some other error"
|
||||
, details = [ "Some other details" ]
|
||||
}
|
||||
@ -240,9 +240,9 @@ unexpectedDetailsTest =
|
||||
expectedDetails =
|
||||
[ "Some details" ]
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some other details" ]
|
||||
}
|
||||
@ -274,9 +274,9 @@ when I was expecting them to be:
|
||||
, "details"
|
||||
]
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some other error"
|
||||
, details =
|
||||
[ "Some"
|
||||
@ -323,9 +323,9 @@ emptyDetailsTest =
|
||||
[ test "with single-line details" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -355,9 +355,9 @@ wrongLocationTest =
|
||||
[ test "with single-line extracts" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -391,9 +391,9 @@ but I found it at:
|
||||
, test "with multi-line extracts" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some other error"
|
||||
, details = [ "Some other details" ]
|
||||
}
|
||||
@ -435,9 +435,9 @@ locationNotFoundTest =
|
||||
test "locationNotFound" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -519,9 +519,9 @@ tooManyErrorsTest =
|
||||
[ test "with one extra error" <|
|
||||
\() ->
|
||||
let
|
||||
extraErrors : List Rule.Error
|
||||
extraErrors : List ReviewError
|
||||
extraErrors =
|
||||
[ Rule.error
|
||||
[ Review.Error.error
|
||||
{ message = "Remove the use of `Debug` before shipping to production"
|
||||
, details = [ "Some details about Debug" ]
|
||||
}
|
||||
@ -540,14 +540,14 @@ I found 1 error too many for module `MyModule`:
|
||||
, test "with multiple extra errors" <|
|
||||
\() ->
|
||||
let
|
||||
extraErrors : List Rule.Error
|
||||
extraErrors : List ReviewError
|
||||
extraErrors =
|
||||
[ Rule.error
|
||||
[ Review.Error.error
|
||||
{ message = "Remove the use of `Debug` before shipping to production"
|
||||
, details = [ "Some details about Debug" ]
|
||||
}
|
||||
{ start = { row = 2, column = 1 }, end = { row = 2, column = 5 } }
|
||||
, Rule.error
|
||||
, Review.Error.error
|
||||
{ message = "Remove the use of `Debug` before shipping to production"
|
||||
, details = [ "Some details about Debug" ]
|
||||
}
|
||||
@ -582,9 +582,9 @@ locationIsAmbiguousInSourceCodeTest =
|
||||
under =
|
||||
"abcd"
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -626,9 +626,9 @@ Tip: I found them at:
|
||||
under =
|
||||
"abcd =\n 1"
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some other error"
|
||||
, details = [ "Some other details" ]
|
||||
}
|
||||
@ -781,14 +781,14 @@ unexpectedFixesTest =
|
||||
range =
|
||||
{ start = { row = 3, column = 1 }, end = { row = 4, column = 3 } }
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
range
|
||||
|> Rule.withFixes [ Fix.removeRange range ]
|
||||
|> Review.Error.withFixes [ Fix.removeRange range ]
|
||||
in
|
||||
ErrorMessage.unexpectedFixes error
|
||||
|> expectMessageEqual """
|
||||
@ -832,9 +832,9 @@ abcd =
|
||||
abcd =
|
||||
2"""
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -874,9 +874,9 @@ unchangedSourceAfterFixTest =
|
||||
test "unchangedSourceAfterFix" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -912,9 +912,9 @@ invalidSourceAfterFixTest =
|
||||
abcd =
|
||||
1"""
|
||||
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
@ -952,9 +952,9 @@ hasCollisionsInFixRangesTest =
|
||||
test "hasCollisionsInFixRanges" <|
|
||||
\() ->
|
||||
let
|
||||
error : Error
|
||||
error : ReviewError
|
||||
error =
|
||||
Rule.error
|
||||
Review.Error.error
|
||||
{ message = "Some error"
|
||||
, details = [ "Some details" ]
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ rule =
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
|
||||
error : Node a -> Error
|
||||
error : Node a -> Error {}
|
||||
error node =
|
||||
Rule.error
|
||||
{ message = "Remove the use of `Debug` before shipping to production"
|
||||
@ -76,7 +76,7 @@ error node =
|
||||
(Node.range node)
|
||||
|
||||
|
||||
importVisitor : Node Import -> List Error
|
||||
importVisitor : Node Import -> List (Error {})
|
||||
importVisitor node =
|
||||
let
|
||||
moduleNameNode : Node (List String)
|
||||
@ -90,7 +90,7 @@ importVisitor node =
|
||||
[]
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> List Error
|
||||
expressionVisitor : Node Expression -> List (Error {})
|
||||
expressionVisitor node =
|
||||
case Node.value node of
|
||||
FunctionOrValue moduleName fnName ->
|
||||
|
@ -67,7 +67,7 @@ rule =
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
|
||||
error : Node a -> String -> String -> Error
|
||||
error : Node a -> String -> String -> Error {}
|
||||
error node operator comparedValue =
|
||||
Rule.error
|
||||
{ message = "Unnecessary comparison with `" ++ comparedValue ++ "`"
|
||||
@ -76,7 +76,7 @@ error node operator comparedValue =
|
||||
(Node.range node)
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> List Error
|
||||
expressionVisitor : Node Expression -> List (Error {})
|
||||
expressionVisitor node =
|
||||
case Node.value node of
|
||||
Expression.OperatorApplication operator _ left right ->
|
||||
|
@ -67,7 +67,7 @@ rule config =
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
|
||||
error : Range -> String -> Error
|
||||
error : Range -> String -> Error {}
|
||||
error range name =
|
||||
Rule.error
|
||||
{ message = "Do not expose everything from " ++ name
|
||||
@ -79,7 +79,7 @@ error range name =
|
||||
range
|
||||
|
||||
|
||||
importVisitor : Configuration -> Node Import -> List Error
|
||||
importVisitor : Configuration -> Node Import -> List (Error {})
|
||||
importVisitor config node =
|
||||
let
|
||||
{ moduleName, exposingList } =
|
||||
|
@ -97,7 +97,7 @@ initialContext =
|
||||
}
|
||||
|
||||
|
||||
error : Node String -> Error
|
||||
error : Node String -> Error {}
|
||||
error node =
|
||||
Rule.error
|
||||
{ message = "Type constructor `" ++ Node.value node ++ "` is not used."
|
||||
@ -189,7 +189,7 @@ expressionVisitor node direction context =
|
||||
( [], context )
|
||||
|
||||
|
||||
finalEvaluation : Context -> List Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
if context.exposesEverything then
|
||||
[]
|
||||
|
@ -122,7 +122,7 @@ emptyScope =
|
||||
}
|
||||
|
||||
|
||||
error : VariableInfo -> String -> Error
|
||||
error : VariableInfo -> String -> Error {}
|
||||
error { variableType, under, rangeToRemove } name =
|
||||
Rule.error
|
||||
{ message = variableTypeToString variableType ++ " `" ++ name ++ "` is not used" ++ variableTypeWarning variableType
|
||||
@ -268,7 +268,7 @@ moduleAliasRange (Node _ { moduleName }) range =
|
||||
{ range | start = (Node.range moduleName).end }
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Direction -> Context -> ( List Error, Context )
|
||||
expressionVisitor : Node Expression -> Direction -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor (Node range value) direction context =
|
||||
case ( direction, value ) of
|
||||
( Rule.OnEnter, FunctionOrValue [] name ) ->
|
||||
@ -583,7 +583,7 @@ markUsedTypesAndModules { types, modules } context =
|
||||
|> markAllModulesAsUsed modules
|
||||
|
||||
|
||||
finalEvaluation : Context -> List Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
if context.exposesEverything then
|
||||
[]
|
||||
@ -605,7 +605,7 @@ finalEvaluation context =
|
||||
newRootScope =
|
||||
{ rootScope | used = Set.union namesOfCustomTypesUsedByCallingAConstructor rootScope.used }
|
||||
|
||||
moduleErrors : List Error
|
||||
moduleErrors : List (Error {})
|
||||
moduleErrors =
|
||||
context.declaredModules
|
||||
|> Dict.filter (\key _ -> not <| Set.member key context.usedModules)
|
||||
@ -896,7 +896,7 @@ getModuleName name =
|
||||
String.join "." name
|
||||
|
||||
|
||||
makeReport : Scope -> ( List Error, List String )
|
||||
makeReport : Scope -> ( List (Error {}), List String )
|
||||
makeReport { declared, used } =
|
||||
let
|
||||
nonUsedVars : List String
|
||||
@ -904,7 +904,7 @@ makeReport { declared, used } =
|
||||
Set.diff used (Set.fromList <| Dict.keys declared)
|
||||
|> Set.toList
|
||||
|
||||
errors : List Error
|
||||
errors : List (Error {})
|
||||
errors =
|
||||
Dict.filter (\key _ -> not <| Set.member key used) declared
|
||||
|> Dict.toList
|
||||
|
@ -4,7 +4,7 @@ import Elm.Package
|
||||
import Elm.Project
|
||||
import Elm.Version
|
||||
import Review.Project as Project exposing (Project)
|
||||
import Review.Rule as Rule exposing (Rule)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Review.Test
|
||||
import Test exposing (Test, test)
|
||||
|
||||
@ -26,7 +26,7 @@ initialProjectContext =
|
||||
Nothing
|
||||
|
||||
|
||||
finalEvaluationForProject : Context -> List Rule.Error
|
||||
finalEvaluationForProject : Context -> List (Error {})
|
||||
finalEvaluationForProject maybeElmJsonKey =
|
||||
case maybeElmJsonKey of
|
||||
Just elmJsonKey ->
|
||||
|
@ -3,7 +3,7 @@ module Review.RuleVisitorsOrderTest exposing (all)
|
||||
import Elm.Syntax.Declaration exposing (Declaration)
|
||||
import Elm.Syntax.Expression exposing (Expression)
|
||||
import Elm.Syntax.Node exposing (Node)
|
||||
import Review.Rule as Rule exposing (Rule)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Review.Test
|
||||
import Test exposing (Test, test)
|
||||
|
||||
@ -47,7 +47,7 @@ all =
|
||||
|> Rule.withFinalModuleEvaluation finalEvaluation
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
finalEvaluation : Context -> List Rule.Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
[ Rule.error { message = context, details = [ "details" ] }
|
||||
{ start = { row = 1, column = 1 }
|
||||
@ -89,7 +89,7 @@ a = 1
|
||||
|> Rule.withFinalModuleEvaluation finalEvaluation
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
declarationVisitor : String -> Node Expression -> Rule.Direction -> Context -> ( List Rule.Error, Context )
|
||||
declarationVisitor : String -> Node Expression -> Rule.Direction -> Context -> ( List (Error {}), Context )
|
||||
declarationVisitor text node direction context =
|
||||
case direction of
|
||||
Rule.OnEnter ->
|
||||
@ -98,7 +98,7 @@ a = 1
|
||||
Rule.OnExit ->
|
||||
( [], context ++ "\nExit " ++ text )
|
||||
|
||||
finalEvaluation : Context -> List Rule.Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
[ Rule.error { message = context, details = [ "details" ] }
|
||||
{ start = { row = 1, column = 1 }
|
||||
@ -134,7 +134,7 @@ Exit A"""
|
||||
|> Rule.withFinalModuleEvaluation finalEvaluation
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
declarationVisitor : String -> Node Declaration -> Rule.Direction -> Context -> ( List Rule.Error, Context )
|
||||
declarationVisitor : String -> Node Declaration -> Rule.Direction -> Context -> ( List (Error {}), Context )
|
||||
declarationVisitor text node direction context =
|
||||
case direction of
|
||||
Rule.OnEnter ->
|
||||
@ -143,7 +143,7 @@ Exit A"""
|
||||
Rule.OnExit ->
|
||||
( [], context ++ "\nExit " ++ text )
|
||||
|
||||
finalEvaluation : Context -> List Rule.Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
[ Rule.error { message = context, details = [ "details" ] }
|
||||
{ start = { row = 1, column = 1 }
|
||||
|
@ -6,7 +6,7 @@ import Elm.Syntax.Expression as Expression exposing (Expression)
|
||||
import Elm.Syntax.Node as Node exposing (Node(..))
|
||||
import Elm.Syntax.TypeAnnotation as TypeAnnotation exposing (TypeAnnotation)
|
||||
import Review.Project as Project exposing (Project)
|
||||
import Review.Rule as Rule exposing (Rule)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Review.Test
|
||||
import Scope2 as Scope
|
||||
import Test exposing (Test, test)
|
||||
@ -152,7 +152,7 @@ moduleVisitor schema =
|
||||
|> Rule.withFinalModuleEvaluation finalEvaluation
|
||||
|
||||
|
||||
declarationVisitor : Node Declaration -> Rule.Direction -> ModuleContext -> ( List Rule.Error, ModuleContext )
|
||||
declarationVisitor : Node Declaration -> Rule.Direction -> ModuleContext -> ( List (Error scope), ModuleContext )
|
||||
declarationVisitor node direction context =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Declaration.FunctionDeclaration function ) ->
|
||||
@ -212,7 +212,7 @@ typeAnnotationNames scope typeAnnotation =
|
||||
typeAnnotationNames scope arg ++ "\n" ++ typeAnnotationNames scope returnType
|
||||
|
||||
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> ModuleContext -> ( List Rule.Error, ModuleContext )
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> ModuleContext -> ( List (Error scope), ModuleContext )
|
||||
expressionVisitor node direction context =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Expression.FunctionOrValue moduleName name ) ->
|
||||
@ -241,7 +241,7 @@ expressionVisitor node direction context =
|
||||
( [], context )
|
||||
|
||||
|
||||
finalEvaluation : ModuleContext -> List Rule.Error
|
||||
finalEvaluation : ModuleContext -> List (Error {})
|
||||
finalEvaluation context =
|
||||
[ Rule.error { message = context.text, details = [ "details" ] }
|
||||
{ start = { row = 1, column = 1 }
|
||||
|
@ -4,7 +4,7 @@ import Dependencies
|
||||
import Elm.Syntax.Expression as Expression exposing (Expression)
|
||||
import Elm.Syntax.Node as Node exposing (Node)
|
||||
import Review.Project as Project exposing (Project)
|
||||
import Review.Rule as Rule exposing (Rule)
|
||||
import Review.Rule as Rule exposing (Error, Rule)
|
||||
import Review.Test exposing (ReviewResult)
|
||||
import Scope
|
||||
import Test exposing (Test, test)
|
||||
@ -62,7 +62,7 @@ all =
|
||||
|> Rule.withFinalModuleEvaluation finalEvaluation
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List Rule.Error, Context )
|
||||
expressionVisitor : Node Expression -> Rule.Direction -> Context -> ( List (Error {}), Context )
|
||||
expressionVisitor node direction context =
|
||||
case ( direction, Node.value node ) of
|
||||
( Rule.OnEnter, Expression.FunctionOrValue moduleName name ) ->
|
||||
@ -90,7 +90,7 @@ all =
|
||||
_ ->
|
||||
( [], context )
|
||||
|
||||
finalEvaluation : Context -> List Rule.Error
|
||||
finalEvaluation : Context -> List (Error {})
|
||||
finalEvaluation context =
|
||||
[ Rule.error { message = context.text, details = [ "details" ] }
|
||||
{ start = { row = 1, column = 1 }
|
||||
|
@ -55,10 +55,10 @@ rule =
|
||||
|> Rule.fromModuleRuleSchema
|
||||
|
||||
|
||||
declarationListVisitor : List (Node Declaration) -> () -> ( List Error, () )
|
||||
declarationListVisitor : List (Node Declaration) -> () -> ( List (Error {}), () )
|
||||
declarationListVisitor declarations context =
|
||||
let
|
||||
errors : List Error
|
||||
errors : List (Error {})
|
||||
errors =
|
||||
List.concatMap
|
||||
(\node ->
|
||||
@ -93,7 +93,7 @@ declarationListVisitor declarations context =
|
||||
( errors, context )
|
||||
|
||||
|
||||
errorFromNode : Node String -> Error
|
||||
errorFromNode : Node String -> Error {}
|
||||
errorFromNode nameNode =
|
||||
Rule.error
|
||||
{ message = Node.value nameNode
|
||||
|
Loading…
Reference in New Issue
Block a user