Remove module visitors for rules that didn't need them

This commit is contained in:
Jeroen Engels 2020-03-19 19:35:45 +01:00
parent 3077047e63
commit 160cea7323
3 changed files with 0 additions and 91 deletions

View File

@ -13,8 +13,6 @@ import Dict exposing (Dict)
import Elm.License
import Elm.Package
import Elm.Project
import Elm.Syntax.ModuleName exposing (ModuleName)
import Elm.Syntax.Node exposing (Node)
import Elm.Syntax.Range exposing (Range)
import Review.Project.Dependency as Dependency exposing (Dependency)
import Review.Rule as Rule exposing (Error, Rule)
@ -34,12 +32,6 @@ import Set exposing (Set)
rule : Configuration -> Rule
rule configuration =
Rule.newProjectRuleSchema "NoInvalidLicense" initialProjectContext
|> Rule.withModuleVisitor moduleVisitor
|> Rule.withModuleContext
{ fromProjectToModule = fromProjectToModule
, fromModuleToProject = fromModuleToProject
, foldProjectContexts = foldProjectContexts
}
|> Rule.withElmJsonProjectVisitor elmJsonVisitor
|> Rule.withDependenciesProjectVisitor dependenciesVisitor
|> Rule.withFinalProjectEvaluation (finalEvaluationForProject configuration)
@ -52,12 +44,6 @@ type alias Configuration =
}
moduleVisitor : Rule.ModuleRuleSchema {} ModuleContext -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ModuleContext
moduleVisitor schema =
schema
|> Rule.withModuleDefinitionVisitor (\_ context -> ( [], context ))
dependenciesVisitor : Dict String Dependency -> ProjectContext -> ( List nothing, ProjectContext )
dependenciesVisitor dependencies projectContext =
let
@ -123,10 +109,6 @@ type alias ProjectContext =
}
type alias ModuleContext =
ProjectContext
initialProjectContext : ProjectContext
initialProjectContext =
{ elmJsonKey = Nothing
@ -135,21 +117,6 @@ initialProjectContext =
}
fromProjectToModule : Rule.ModuleKey -> Node ModuleName -> ProjectContext -> ModuleContext
fromProjectToModule _ _ projectContext =
projectContext
fromModuleToProject : Rule.ModuleKey -> Node ModuleName -> ModuleContext -> ProjectContext
fromModuleToProject _ _ moduleContext =
moduleContext
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
foldProjectContexts _ previousContext =
previousContext
-- FINAL EVALUATION

View File

@ -9,23 +9,11 @@ import Review.Rule as Rule exposing (Error, Rule)
rule : Rule
rule =
Rule.newProjectRuleSchema "ReadmeStartsWithProjectTitle" initialProjectContext
|> Rule.withModuleVisitor moduleVisitor
|> Rule.withModuleContext
{ fromProjectToModule = fromProjectToModule
, fromModuleToProject = fromModuleToProject
, foldProjectContexts = foldProjectContexts
}
|> Rule.withElmJsonProjectVisitor elmJsonVisitor
|> Rule.withReadmeProjectVisitor readmeVisitor
|> Rule.fromProjectRuleSchema
moduleVisitor : Rule.ModuleRuleSchema {} ModuleContext -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } ModuleContext
moduleVisitor schema =
schema
|> Rule.withModuleDefinitionVisitor (\_ context -> ( [], context ))
type alias ProjectContext =
{ projectTitle : Maybe String
}
@ -37,25 +25,6 @@ initialProjectContext =
}
type alias ModuleContext =
ProjectContext
fromProjectToModule : Rule.ModuleKey -> a -> ProjectContext -> ModuleContext
fromProjectToModule _ _ projectContext =
projectContext
fromModuleToProject : Rule.ModuleKey -> a -> ModuleContext -> ProjectContext
fromModuleToProject _ _ moduleContext =
moduleContext
foldProjectContexts : ProjectContext -> ProjectContext -> ProjectContext
foldProjectContexts _ previousContext =
previousContext
-- elm.json VISITOR

View File

@ -16,43 +16,16 @@ type alias Context =
rule : Rule
rule =
Rule.newProjectRuleSchema "TestRule" initialProjectContext
|> Rule.withModuleVisitor moduleVisitor
|> Rule.withModuleContext
{ fromProjectToModule = fromProjectToModule
, fromModuleToProject = fromModuleToProject
, foldProjectContexts = foldProjectContexts
}
|> Rule.withElmJsonProjectVisitor (\elmJson _ -> ( [], elmJson |> Maybe.map .elmJsonKey ))
|> Rule.withFinalProjectEvaluation finalEvaluationForProject
|> Rule.fromProjectRuleSchema
moduleVisitor : Rule.ModuleRuleSchema {} Context -> Rule.ModuleRuleSchema { hasAtLeastOneVisitor : () } Context
moduleVisitor schema =
schema
|> Rule.withModuleDefinitionVisitor (\moduleNode context -> ( [], context ))
initialProjectContext : Context
initialProjectContext =
Nothing
fromProjectToModule : a -> b -> Context -> Context
fromProjectToModule _ _ projectContext =
projectContext
fromModuleToProject : a -> b -> Context -> Context
fromModuleToProject _ _ moduleContext =
moduleContext
foldProjectContexts : Context -> Context -> Context
foldProjectContexts newContext previousContext =
previousContext
finalEvaluationForProject : Context -> List Rule.Error
finalEvaluationForProject maybeElmJsonKey =
case maybeElmJsonKey of