Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-358

Support match statement with at least one conditional case

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5
    • Component/s: AST
    • Labels:
      None
    • Estimate:
      Hours

      Description

      Main affected language: Scala

       

      Match statement with at least one conditional case, as well as all its cases
      Affected rules: RSPEC-131RSPEC-134RSPEC-1479, but be cautious RSPEC-1862RSPEC-3923RSPEC-1871

       

      • Scala
        scala.meta.Term$Match$TermMatchImpl -> MatchTreeImpl70%, BlockTreeImpl 21%, NativeTreeImpl 9%
      "something" match {
         case "a" if(variable) => println("a")
         case "a" => println("a")
         case "b" if(variable) => println("b")
      }
      

      Scala grammar (https://www.scala-lang.org/files/archive/spec/2.12/13-syntax-summary.html) :

      
        Expr1             ::=  `if' `(' Expr `)' {nl} Expr [[semi] `else' Expr]
                            |  /* ... */
                            |  PostfixExpr `match' `{' CaseClauses `}'
      
        [...]
      
        CaseClauses       ::=  CaseClause { CaseClause }
        CaseClause        ::=  ‘case’ Pattern [Guard] ‘=>’ Block
        Guard             ::=  ‘if’ PostfixExpr
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: