irobayna/stupidedi

View on GitHub
lib/stupidedi/parser/navigation.rb

Summary

Maintainability
F
6 days
Test Coverage

Method __find has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

      def __find(invalid, id, elements, assert_repeatable = false)
        reachable   = false
        repeatable  = false
        matches     = []
        filter_tok  = nil
Severity: Minor
Found in lib/stupidedi/parser/navigation.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

Method element has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

      def element(m, n = nil, o = nil)
        if m <= 0 or (n || 1) <= 0 or (o || 1) <= 0
          raise ArgumentError,
            "all arguments must be positive"
        end
Severity: Minor
Found in lib/stupidedi/parser/navigation.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 navigation.rb has 449 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Stupidedi
  using Refinements

  module Parser
    module Navigation
Severity: Minor
Found in lib/stupidedi/parser/navigation.rb - About 6 hrs to fix

    Method __find has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def __find(invalid, id, elements, assert_repeatable = false)
            reachable   = false
            repeatable  = false
            matches     = []
            filter_tok  = nil
    Severity: Major
    Found in lib/stupidedi/parser/navigation.rb - About 3 hrs to fix

      Method element has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def element(m, n = nil, o = nil)
              if m <= 0 or (n || 1) <= 0 or (o || 1) <= 0
                raise ArgumentError,
                  "all arguments must be positive"
              end
      Severity: Major
      Found in lib/stupidedi/parser/navigation.rb - About 3 hrs to fix

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

              def filter?(filter_tok, segment_val)
                return true unless filter_tok.id == segment_val.id
        
                filter_tok.element_toks.zip(segment_val.children) do |f_tok, e_val|
                  if f_tok.simple?
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 __filter? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def __filter?(filter_tok, invalid_val)
                return true unless filter_tok.id == invalid_val.id
        
                children = invalid_val.segment_tok.element_toks
                filter_tok.element_toks.zip(children) do |f_tok, e_tok|
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 next has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def next(count = 1)
                unless count > 0
                  raise ArgumentError,
                    "count must be positive"
                end
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 prev has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def prev(count = 1)
                unless count > 0
                  raise ArgumentError,
                    "count must be positive"
                end
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 parent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def parent
                active = []
        
                @active.each do |zipper|
                  state = zipper
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.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 prev has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def prev(count = 1)
                unless count > 0
                  raise ArgumentError,
                    "count must be positive"
                end
        Severity: Minor
        Found in lib/stupidedi/parser/navigation.rb - About 1 hr to fix

          Method next has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def next(count = 1)
                  unless count > 0
                    raise ArgumentError,
                      "count must be positive"
                  end
          Severity: Minor
          Found in lib/stupidedi/parser/navigation.rb - About 1 hr to fix

            Method parent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def parent
                    active = []
            
                    @active.each do |zipper|
                      state = zipper
            Severity: Minor
            Found in lib/stupidedi/parser/navigation.rb - About 1 hr to fix

              Method first has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def first
                      active = roots.map do |zipper|
                        state = zipper
                        value = zipper.node.zipper
              
              
              Severity: Minor
              Found in lib/stupidedi/parser/navigation.rb - About 55 mins 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 last has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def last
                      active = roots.map do |zipper|
                        state = zipper
                        value = zipper.node.zipper
              
              
              Severity: Minor
              Found in lib/stupidedi/parser/navigation.rb - About 55 mins 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

              Avoid deeply nested control flow statements.
              Open

                            unless o <= components
                              raise ArgumentError,
                                "repeatable composite element #{descriptor} only has #{components} components"
                            end
              Severity: Major
              Found in lib/stupidedi/parser/navigation.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if element_zip.node.blank?
                                Either.failure("repeatable composite element #{descriptor} does not occur")
                              elsif occurs_count < n
                                Either.failure("repeatable composite element #{descriptor} only occurs #{occurs_count} times")
                              else
                Severity: Major
                Found in lib/stupidedi/parser/navigation.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      unless __value.eql?(__state.node.zipper)
                                        __state = __state.replace(__state.node.copy(:zipper => __value))
                                      end
                  Severity: Major
                  Found in lib/stupidedi/parser/navigation.rb - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status