steveklabnik/abnf

View on GitHub

Showing 29 of 46 total issues

Method regexp_tree has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
Open

  def regexp_tree(name=nil)
    name ||= start_symbol
    env = {}
    each_strongly_connected_component_from(name) {|ns|
      rules = {}
Severity: Minor
Found in lib/abnf/regexp.rb - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File parser.rb has 653 lines of code (exceeds 250 allowed). Consider refactoring.
Open

unless $".index 'racc/parser.rb'
$".push 'racc/parser.rb'
self.class.module_eval(<<'...end racc/parser.rb/module_eval...', 'racc/parser.rb', 1)
#
# $Id: ad1fffef443194fdfa1052d2eee6850552f94313 $
Severity: Major
Found in lib/abnf/parser.rb - About 1 day to fix

    File regexptree.rb has 417 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'prettyprint'
    require 'natset'
    
    class RegexpTree
      @curr_prec = 1
    Severity: Minor
    Found in lib/regexptree.rb - About 6 hrs to fix

      Class RegexpTree has 39 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class RegexpTree
        @curr_prec = 1
        def RegexpTree.inherited(c)
          return if c.superclass != RegexpTree
          c.const_set(:Prec, @curr_prec)
      Severity: Minor
      Found in lib/regexptree.rb - About 5 hrs to fix

        Method regexp_tree has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def regexp_tree(name=nil)
            name ||= start_symbol
            env = {}
            each_strongly_connected_component_from(name) {|ns|
              rules = {}
        Severity: Major
        Found in lib/abnf/regexp.rb - About 4 hrs to fix

          File regexp.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'abnf/abnf'
          require 'regexptree'
          
          class ABNF
            class TooComplex < StandardError
          Severity: Minor
          Found in lib/abnf/regexp.rb - About 3 hrs to fix

            File natset.rb has 320 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class NatSet
              class << NatSet
                alias _new new
              end
            
            
            Severity: Minor
            Found in lib/natset.rb - About 3 hrs to fix

              Method delete_useless! has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def delete_useless!(starts=nil)
                  if starts
                    starts = [starts] if Symbol === starts
                    delete_unreachable!(starts)
                  end
              Severity: Minor
              Found in lib/abnf/abnf.rb - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method new has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def NatSet.new(*es)
                  r = self.empty
                  es.each {|e|
                    if String === e
                      e = e.ord
              Severity: Minor
              Found in lib/natset.rb - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method merge has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def merge(other)
                  es1 = @es.dup
                  es2 = other.es.dup
                  es0 = []
                  bool1 = bool2 = bool0 = false
              Severity: Minor
              Found in lib/natset.rb - About 2 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Class NatSet has 25 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class NatSet
                class << NatSet
                  alias _new new
                end
              
              
              Severity: Minor
              Found in lib/natset.rb - About 2 hrs to fix

                Method pretty_format has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def pretty_format(out)
                      case @natset
                      when None; out.text '(?!)'
                      when Any; out.text '[\s\S]'
                      when NL; out.text '\n'
                Severity: Minor
                Found in lib/regexptree.rb - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Method recursion has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    def recursion(syms, lhs)
                      case @elts.length
                      when 0
                        NonRecursion
                      when 1
                Severity: Minor
                Found in lib/abnf/regexp.rb - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Method merge has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def merge(other)
                    es1 = @es.dup
                    es2 = other.es.dup
                    es0 = []
                    bool1 = bool2 = bool0 = false
                Severity: Minor
                Found in lib/natset.rb - About 1 hr to fix

                  Method pretty_format has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def pretty_format(out)
                        case @natset
                        when None; out.text '(?!)'
                        when Any; out.text '[\s\S]'
                        when NL; out.text '\n'
                  Severity: Minor
                  Found in lib/regexptree.rb - About 1 hr to fix

                    Method delete_useless! has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def delete_useless!(starts=nil)
                        if starts
                          starts = [starts] if Symbol === starts
                          delete_unreachable!(starts)
                        end
                    Severity: Minor
                    Found in lib/abnf/abnf.rb - About 1 hr to fix

                      Method new has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def NatSet.new(*es)
                          r = self.empty
                          es.each {|e|
                            if String === e
                              e = e.ord
                      Severity: Minor
                      Found in lib/natset.rb - About 1 hr to fix

                        Method alt has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def RegexpTree.alt(*rs)
                            rs2 = []
                            rs.each {|r|
                              if r.empty_set?
                                next
                        Severity: Minor
                        Found in lib/regexptree.rb - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method new has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def Alt.new(*elts)
                              elts2 = []
                              elts.each {|e|
                            if e.empty_set?
                              next
                        Severity: Minor
                        Found in lib/abnf/grammar.rb - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method pretty_format has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def pretty_format(out)
                              @r.parenthesize(Elt).pretty_format(out)
                              case @m
                              when 0
                                case @n
                        Severity: Minor
                        Found in lib/regexptree.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language