steveklabnik/abnf

View on GitHub

Showing 46 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    ns.reverse_each {|n|
                      e = rules[n]
                      r = rs[n]
                      if r & LeftRecursion != 0 && r & ~(NonRecursion|JustRecursion|LeftRecursion|SelfRecursion) == 0
                        e = e.remove_left_recursion(n)
                Severity: Major
                Found in lib/abnf/regexp.rb and 1 other location - About 1 hr to fix
                lib/abnf/regexp.rb on lines 102..112

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    ns.reverse_each {|n|
                      e = rules[n]
                      r = rs[n]
                      if r & RightRecursion != 0 && r & ~(NonRecursion|JustRecursion|RightRecursion|SelfRecursion) == 0
                        e = e.remove_right_recursion(n)
                Severity: Major
                Found in lib/abnf/regexp.rb and 1 other location - About 1 hr to fix
                lib/abnf/regexp.rb on lines 85..95

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 64.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  racc_action_check = [
                      25,    25,    25,    25,    24,    25,     1,    25,     1,    12,
                       7,    24,    15,    15,    15,    15,    22,    15,     4,    15,
                       6,     6,     6,     6,     2,     6,    13,     6,    16,    16,
                      16,    16,   nil,    16,   nil,    16,     8,     8,     8,     8,
                  Severity: Major
                  Found in lib/abnf/parser.rb and 1 other location - About 1 hr to fix
                  lib/abnf/parser.rb on lines 576..582

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 62.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  racc_action_table = [
                      12,    13,    14,    15,    18,    16,     2,    17,     4,    21,
                      18,    28,    12,    13,    14,    15,    26,    16,     6,    17,
                      12,    13,    14,    15,     5,    16,    22,    17,    12,    13,
                      14,    15,   nil,    16,   nil,    17,    12,    13,    14,    15,
                  Severity: Major
                  Found in lib/abnf/parser.rb and 1 other location - About 1 hr to fix
                  lib/abnf/parser.rb on lines 584..590

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 62.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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
                      Severity
                      Category
                      Status
                      Source
                      Language