mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-23 14:55:35 +03:00
Use direct dependencies visitor in test rules
This commit is contained in:
parent
d746a21c9a
commit
2a211e9d22
@ -5555,7 +5555,7 @@ scopeRule : RunnableProjectVisitor ScopeProjectContext ScopeModuleContext
|
||||
scopeRule =
|
||||
newProjectRuleSchema "elm-review__SCOPE" scope_initialProjectContext
|
||||
|> withContextFromImportedModules
|
||||
|> withDependenciesProjectVisitor (scope_dependenciesVisitor |> scope_pairWithNoErrors)
|
||||
|> withDirectDependenciesProjectVisitor (scope_dependenciesVisitor |> scope_pairWithNoErrors)
|
||||
|> withModuleVisitor scope_moduleVisitor
|
||||
|> withModuleContext
|
||||
{ fromProjectToModule = scope_fromProjectToModule
|
||||
|
@ -105,7 +105,7 @@ rule configuration =
|
||||
userConfigurationToStableConfiguration configuration elementPredicate
|
||||
in
|
||||
Rule.newProjectRuleSchema "NoDeprecated" initialProjectContext
|
||||
|> Rule.withDependenciesProjectVisitor (dependenciesVisitor stableConfiguration)
|
||||
|> Rule.withDirectDependenciesProjectVisitor (dependenciesVisitor stableConfiguration)
|
||||
|> Rule.withModuleVisitor (moduleVisitor stableConfiguration)
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = fromProjectToModule stableConfiguration
|
||||
|
@ -89,7 +89,7 @@ rule : Rule
|
||||
rule =
|
||||
Rule.newProjectRuleSchema "NoMissingTypeExpose" initialProjectContext
|
||||
|> Rule.withElmJsonProjectVisitor elmJsonVisitor
|
||||
|> Rule.withDependenciesProjectVisitor dependencyDictVisitor
|
||||
|> Rule.withDirectDependenciesProjectVisitor dependencyDictVisitor
|
||||
|> Rule.withModuleVisitor moduleVisitor
|
||||
|> Rule.withContextFromImportedModules
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
|
@ -44,7 +44,7 @@ rule : Rule
|
||||
rule =
|
||||
Rule.newProjectRuleSchema "NoUnused.Dependencies" initialProjectContext
|
||||
|> Rule.withElmJsonProjectVisitor elmJsonVisitor
|
||||
|> Rule.withDependenciesProjectVisitor dependenciesVisitor
|
||||
|> Rule.withDirectDependenciesProjectVisitor dependenciesVisitor
|
||||
|> Rule.withModuleVisitor moduleVisitor
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = fromProjectToModule
|
||||
@ -66,18 +66,15 @@ dependenciesVisitor dependencies projectContext =
|
||||
let
|
||||
moduleNameToDependency : Dict String String
|
||||
moduleNameToDependency =
|
||||
dependencies
|
||||
|> Dict.filter
|
||||
(\packageName _ ->
|
||||
Set.member packageName projectContext.directProjectDependencies
|
||||
|| Set.member packageName projectContext.directTestDependencies
|
||||
)
|
||||
|> Dict.toList
|
||||
|> List.concatMap
|
||||
(\( packageName, dependency ) ->
|
||||
List.map (\{ name } -> ( name, packageName )) (Dependency.modules dependency)
|
||||
)
|
||||
|> Dict.fromList
|
||||
Dict.foldl
|
||||
(\packageName dependency dict ->
|
||||
List.foldl
|
||||
(\{ name } d -> Dict.insert name packageName d)
|
||||
dict
|
||||
(Dependency.modules dependency)
|
||||
)
|
||||
Dict.empty
|
||||
dependencies
|
||||
in
|
||||
( []
|
||||
, { projectContext
|
||||
|
@ -7,12 +7,13 @@ import NoUnused.Dependencies exposing (rule)
|
||||
import Review.Project as Project exposing (Project)
|
||||
import Review.Project.Dependency as Dependency exposing (Dependency)
|
||||
import Review.Test
|
||||
import Review.Test.Dependencies
|
||||
import Test exposing (Test, describe, test)
|
||||
|
||||
|
||||
createProject : Maybe String -> String -> Project
|
||||
createProject maybeTestModule rawElmJson =
|
||||
Project.new
|
||||
Review.Test.Dependencies.projectWithElmCore
|
||||
|> Project.addElmJson (createElmJson rawElmJson)
|
||||
|> Project.addDependency packageWithBar
|
||||
|> Project.addDependency packageWithFoo
|
||||
|
@ -102,7 +102,7 @@ rule : Rule
|
||||
rule =
|
||||
Rule.newProjectRuleSchema "NoUnused.Variables" initialContext
|
||||
|> Rule.withElmJsonProjectVisitor (\project context -> ( [], elmJsonVisitor project context ))
|
||||
|> Rule.withDependenciesProjectVisitor dependenciesVisitor
|
||||
|> Rule.withDirectDependenciesProjectVisitor dependenciesVisitor
|
||||
|> Rule.withModuleVisitor moduleVisitor
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = fromProjectToModule
|
||||
|
@ -2585,7 +2585,8 @@ rawPackageElmJson =
|
||||
],
|
||||
"elm-version": "0.19.0 <= v < 0.20.0",
|
||||
"dependencies": {
|
||||
"package/author": "1.0.0 <= v < 2.0.0"
|
||||
"package/author": "1.0.0 <= v < 2.0.0",
|
||||
"author/package-with-foo": "1.0.0 <= v < 2.0.0"
|
||||
},
|
||||
"test-dependencies": {}
|
||||
}"""
|
||||
|
@ -572,7 +572,7 @@ rule (Configuration config) =
|
||||
Set.fromList typeNamesList
|
||||
in
|
||||
Rule.newProjectRuleSchema "Simplify" initialContext
|
||||
|> Rule.withDependenciesProjectVisitor (dependenciesVisitor typeNames)
|
||||
|> Rule.withDirectDependenciesProjectVisitor (dependenciesVisitor typeNames)
|
||||
|> Rule.withModuleVisitor (moduleVisitor typeNames)
|
||||
|> Rule.withModuleContextUsingContextCreator
|
||||
{ fromProjectToModule = fromProjectToModule
|
||||
|
Loading…
Reference in New Issue
Block a user