From d1f87f4a5cfd1751eeae422a1450e68d69d6ec00 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 5 Jul 2019 01:39:52 +0200 Subject: [PATCH] Removed unused things and improved some patterns, hinted by elm-analyse --- elm.json | 1 - src/Lint/Rule.elm | 4 ++-- src/Lint/Rule/DefaultPatternPosition.elm | 2 -- src/Lint/Rule/NoUnusedTypeConstructors.elm | 18 ++---------------- src/Lint/Test.elm | 1 - 5 files changed, 4 insertions(+), 22 deletions(-) diff --git a/elm.json b/elm.json index cfb35af6..b8024be9 100644 --- a/elm.json +++ b/elm.json @@ -18,7 +18,6 @@ "elm-version": "0.19.0 <= v < 0.20.0", "dependencies": { "elm/core": "1.0.2 <= v < 2.0.0", - "elm/regex": "1.0.0 <= v < 2.0.0", "elm-community/list-extra": "8.2.0 <= v < 9.0.0", "elm-explorations/test": "1.2.2 <= v < 2.0.0", "mgold/elm-nonempty-list": "4.0.1 <= v < 5.0.0", diff --git a/src/Lint/Rule.elm b/src/Lint/Rule.elm index 9b14e0e9..cb83177f 100644 --- a/src/Lint/Rule.elm +++ b/src/Lint/Rule.elm @@ -1015,8 +1015,8 @@ expressionChildren node = ++ [ expression ] CaseExpression { expression, cases } -> - [ expression ] - ++ List.map (\( pattern, caseExpression ) -> caseExpression) cases + expression + :: List.map (\( pattern, caseExpression ) -> caseExpression) cases LambdaExpression { args, expression } -> [ expression ] diff --git a/src/Lint/Rule/DefaultPatternPosition.elm b/src/Lint/Rule/DefaultPatternPosition.elm index b0089356..b707f112 100644 --- a/src/Lint/Rule/DefaultPatternPosition.elm +++ b/src/Lint/Rule/DefaultPatternPosition.elm @@ -89,8 +89,6 @@ import Elm.Syntax.Expression exposing (Expression(..)) import Elm.Syntax.Node as Node exposing (Node) import Elm.Syntax.Pattern exposing (Pattern(..)) import Lint.Rule as Rule exposing (Error, Rule) -import List.Extra exposing (findIndex) -import Regex {-| Configures whether the default pattern should appear first or last. diff --git a/src/Lint/Rule/NoUnusedTypeConstructors.elm b/src/Lint/Rule/NoUnusedTypeConstructors.elm index 0f2e6521..ec8b573f 100644 --- a/src/Lint/Rule/NoUnusedTypeConstructors.elm +++ b/src/Lint/Rule/NoUnusedTypeConstructors.elm @@ -48,14 +48,11 @@ if it is not used anywhere in the project. import Dict exposing (Dict) import Elm.Syntax.Declaration exposing (Declaration(..)) import Elm.Syntax.Exposing exposing (Exposing(..), TopLevelExpose(..)) -import Elm.Syntax.Expression exposing (Expression(..), Function, FunctionImplementation, LetDeclaration(..)) -import Elm.Syntax.Import exposing (Import) +import Elm.Syntax.Expression exposing (Expression(..)) import Elm.Syntax.Module as Module exposing (Module(..)) import Elm.Syntax.Node as Node exposing (Node) -import Elm.Syntax.Range exposing (Range) import Elm.Syntax.TypeAnnotation exposing (TypeAnnotation(..)) import Lint.Rule as Rule exposing (Direction, Error, Rule) -import List.Nonempty as Nonempty exposing (Nonempty) import Set exposing (Set) @@ -194,17 +191,6 @@ finalEvaluation context = else context.declaredTypesWithConstructors - |> Dict.filter (\name node -> not <| Set.member name context.usedFunctionOrValues) + |> Dict.filter (\name _ -> not <| Set.member name context.usedFunctionOrValues) |> Dict.toList |> List.map (\( _, node ) -> error node) - - - --- if context.exposesEverything then --- [] --- --- else --- context.scopes --- |> Nonempty.head --- |> makeReport --- |> Tuple.first diff --git a/src/Lint/Test.elm b/src/Lint/Test.elm index 14a24e52..d56521da 100644 --- a/src/Lint/Test.elm +++ b/src/Lint/Test.elm @@ -59,7 +59,6 @@ import Elm.Syntax.Range exposing (Range) import Expect exposing (Expectation) import Lint exposing (Severity(..), lintSource) import Lint.Rule as Rule exposing (Error, Rule) -import List.Extra {-| The result of running a rule on a `String` containing source code.