Skip to content

Commit

Permalink
Merge pull request #76 from exercism/jie-bandwagoner
Browse files Browse the repository at this point in the history
remove pattern matching rule from `bandwagoner`
  • Loading branch information
jiegillet authored Nov 20, 2023
2 parents d49a049 + 1b48840 commit 303b15c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
16 changes: 2 additions & 14 deletions src/Exercise/Bandwagoner.elm
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module Exercise.Bandwagoner exposing (replaceCoachUsesRecordUpdateSyntax, rootForTeamHasExtensibleRecordSignature, rootForTeamUsesPatternMatchingInArgument, ruleConfig)
module Exercise.Bandwagoner exposing (replaceCoachUsesRecordUpdateSyntax, rootForTeamHasExtensibleRecordSignature, ruleConfig)

import Analyzer exposing (CalledExpression(..), CalledFrom(..), Find(..), Pattern(..))
import Analyzer exposing (CalledExpression(..), CalledFrom(..), Find(..))
import Comment exposing (Comment, CommentType(..))
import Dict
import Elm.Syntax.Declaration as Declaration exposing (Declaration)
import Elm.Syntax.Node as Node exposing (Node(..))
import Elm.Syntax.Pattern exposing (Pattern(..))
import ElmSyntaxHelpers
import Review.Rule as Rule exposing (Error, Rule)
import RuleConfig exposing (AnalyzerRule(..), RuleConfig)
Expand All @@ -19,8 +18,6 @@ ruleConfig =
(Comment "elm.bandwagoner.use_record_update_syntax" Actionable Dict.empty)
, CustomRule rootForTeamHasExtensibleRecordSignature
(Comment "elm.bandwagoner.use_extensible_record_signature" Essential Dict.empty)
, CustomRule rootForTeamUsesPatternMatchingInArgument
(Comment "elm.bandwagoner.use_pattern_matching_in_argument" Essential Dict.empty)
]
}

Expand All @@ -34,15 +31,6 @@ replaceCoachUsesRecordUpdateSyntax =
}


rootForTeamUsesPatternMatchingInArgument : Comment -> Rule
rootForTeamUsesPatternMatchingInArgument =
Analyzer.functionCalls
{ calledFrom = TopFunction "rootForTeam"
, findExpressions = [ ArgumentWithPattern Record ]
, find = Some
}


rootForTeamHasExtensibleRecordSignature : Comment -> Rule
rootForTeamHasExtensibleRecordSignature comment =
Rule.newModuleRuleSchema comment.path []
Expand Down
40 changes: 0 additions & 40 deletions tests/Exercise/BandwagonerTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ tests =
[ exemplar
, noRecordUpdate
, noExtensibleRecord
, noRecordPatternMatching
]


Expand Down Expand Up @@ -163,42 +162,3 @@ rootForTeam { stats } =
|> Review.Test.atExactly { start = { row = 21, column = 1 }, end = { row = 21, column = 12 } }
]
]


noRecordPatternMatching : Test
noRecordPatternMatching =
let
comment =
Comment "elm.bandwagoner.use_pattern_matching_in_argument" Essential Dict.empty
in
test "rootForTeam doesn't pattern matching in the rootForTeam argument" <|
\() ->
"""
module Bandwagoner exposing (..)
type alias Coach =
{ name : String
, formerPlayer : Bool
}
type alias Stats =
{ wins : Int
, losses : Int
}
type alias Team =
{ name : String
, coach : Coach
, stats : Stats
}
rootForTeam : { a | stats : Stats } -> Bool
rootForTeam x =
x.stats.wins > x.stats.losses
"""
|> Review.Test.run (Bandwagoner.rootForTeamUsesPatternMatchingInArgument comment)
|> Review.Test.expectErrors
[ TestHelper.createExpectedErrorUnder comment "rootForTeam"
|> Review.Test.atExactly { start = { row = 21, column = 1 }, end = { row = 21, column = 12 } }
]

0 comments on commit 303b15c

Please sign in to comment.