Remove unused code

This commit is contained in:
Jeroen Engels 2020-08-26 18:30:25 +02:00
parent 7e4d767923
commit 0ff71b2c84
4 changed files with 2 additions and 1611 deletions

View File

@ -51,7 +51,7 @@ import Elm.Syntax.Node as Node
import Review.Dependencies
import Review.Project.Dependency as Dependency exposing (Dependency)
import Review.Project.Internal as Internal exposing (Project)
import Vendor.Graph as Graph exposing (Graph)
import Vendor.Graph exposing (Graph)
@ -246,22 +246,8 @@ precomputeModuleGraph ((Internal.Project p) as project) =
moduleGraph : Graph ModuleName ()
moduleGraph =
Internal.buildModuleGraph <| Dict.values p.modules
projectWithGraph =
{ p | moduleGraph = Just moduleGraph }
nodeContexts : List (Graph.NodeContext ModuleName ())
nodeContexts =
moduleGraph
|> Graph.checkAcyclic
|> Result.map Graph.topologicalSort
|> Result.withDefault []
in
Internal.Project
{ projectWithGraph
| moduleNameLookupTables =
Just (Internal.computeModuleNameLookupTables (Internal.Project projectWithGraph) nodeContexts)
}
Internal.Project { p | moduleGraph = Just moduleGraph }

View File

@ -2,7 +2,6 @@ module Review.Project.Internal exposing
( Project(..)
, ProjectModule
, buildModuleGraph
, computeModuleNameLookupTables
, getModuleName
, moduleGraph
, moduleNameLookupTables
@ -20,7 +19,6 @@ import Elm.Syntax.Module
import Elm.Syntax.ModuleName exposing (ModuleName)
import Elm.Syntax.Node as Node
import Review.ModuleNameLookupTable exposing (ModuleNameLookupTable)
import Review.ModuleNameLookupTable.Internal as ModuleNameLookupTableInternal
import Review.Project.Dependency exposing (Dependency)
import Vendor.Graph as Graph exposing (Graph)
@ -150,15 +148,3 @@ getModuleName module_ =
module_.ast.moduleDefinition
|> Node.value
|> Elm.Syntax.Module.moduleName
computeModuleNameLookupTables : Project -> List (Graph.NodeContext ModuleName ()) -> Dict ModuleName ModuleNameLookupTable
computeModuleNameLookupTables project nodeContexts =
nodeContexts
|> List.map (\nodeContext -> ( nodeContext.node.label, computeModuleNameLookupTable project nodeContext ))
|> Dict.fromList
computeModuleNameLookupTable : Project -> Graph.NodeContext ModuleName () -> ModuleNameLookupTable
computeModuleNameLookupTable (Project project) { node, incoming } =
ModuleNameLookupTableInternal.empty

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +0,0 @@
module ScopeExample exposing (rule)
import Elm.Syntax.Expression as Expression exposing (Expression)
import Elm.Syntax.Node as Node exposing (Node)
import Review.ModuleNameLookupTable as ModuleNameLookupTable exposing (ModuleNameLookupTable)
import Review.Rule as Rule exposing (Direction, Error, Rule)
rule : Rule
rule =
Rule.newModuleRuleSchemaUsingContextCreator "NoHtmlButton" initialContext
|> Rule.withExpressionEnterVisitor expressionVisitor
|> Rule.fromModuleRuleSchema
|> Rule.ignoreErrorsForFiles [ "src/Button.elm" ]
type alias Context =
{ lookupTable : ModuleNameLookupTable
}
initialContext : Rule.ContextCreator () Context
initialContext =
Rule.initContextCreator
(\lookupTable () ->
{ lookupTable = lookupTable
}
)
|> Rule.withModuleNameLookupTable
expressionVisitor : Node Expression -> Context -> ( List (Error {}), Context )
expressionVisitor node context =
case Node.value node of
Expression.FunctionOrValue _ "button" ->
if ModuleNameLookupTable.moduleNameFor context.lookupTable node == Just [ "Html" ] then
( [ Rule.error
{ message = "Do not use `Html.button` directly"
, details = [ "At fruits.com, we've built a nice `Button` module that suits our needs better. Using this module instead of `Html.button` ensures we have a consistent button experience across the website." ]
}
(Node.range node)
]
, context
)
else
( [], context )
_ ->
( [], context )