DannyBen/docopt_ng

View on GitHub

Showing 19 of 19 total issues

Method parse_long has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_long(tokens, options)
    long, eq, value = tokens.move.partition('=')

    raise RuntimeError unless long.start_with?('--')

Severity: Minor
Found in lib/docopt_ng.rb - About 5 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 parse_shorts has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_shorts(tokens, options)
    token = tokens.move
    unless token.start_with?('-') && !token.start_with?('--')
      raise RuntimeError
    end
Severity: Minor
Found in lib/docopt_ng.rb - About 4 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 fix_repeating_arguments has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def fix_repeating_arguments
      either.children.map(&:children).each do |case_|
        case_.select { |c| case_.count(c) > 1 }.each do |e|
          if e.instance_of?(Argument) || (e.instance_of?(Option) && e.argcount.positive?)
            if e.value.nil?
Severity: Minor
Found in lib/docopt_ng/pattern.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 parse_atom has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_atom(tokens, options)
    token = tokens.current

    if ['(', '['].include? token
      tokens.move
Severity: Minor
Found in lib/docopt_ng.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 parse_shorts has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_shorts(tokens, options)
    token = tokens.move
    unless token.start_with?('-') && !token.start_with?('--')
      raise RuntimeError
    end
Severity: Minor
Found in lib/docopt_ng.rb - About 1 hr to fix

    Method parse_long has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_long(tokens, options)
        long, eq, value = tokens.move.partition('=')
    
        raise RuntimeError unless long.start_with?('--')
    
    
    Severity: Minor
    Found in lib/docopt_ng.rb - About 1 hr to fix

      Method either has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def either
            ret = []
            groups = [[self]]
            while groups.count.positive?
              children = groups.shift
      Severity: Minor
      Found in lib/docopt_ng/pattern.rb - About 1 hr to fix

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

            def match(left, collected = nil)
              raise RuntimeError if children.count != 1
        
              collected ||= []
              l = left
        Severity: Minor
        Found in lib/docopt_ng/one_or_more.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 match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def match(left, collected = nil)
              collected ||= []
              pos, match = single_match(left)
        
              return [false, left, collected] if match.nil?
        Severity: Minor
        Found in lib/docopt_ng/child_pattern.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 fix_identities has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def fix_identities(uniq = nil)
              unless instance_variable_defined?(:@children)
                return self
              end
        
        
        Severity: Minor
        Found in lib/docopt_ng/pattern.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 parse_atom has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def parse_atom(tokens, options)
            token = tokens.current
        
            if ['(', '['].include? token
              tokens.move
        Severity: Minor
        Found in lib/docopt_ng.rb - About 1 hr to fix

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

            def parse_expr(tokens, options)
              seq = parse_seq(tokens, options)
              if tokens.current != '|'
                return seq
              end
          Severity: Minor
          Found in lib/docopt_ng.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 parse_argv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_argv(tokens, options, options_first = false)
              parsed = []
              until tokens.current.nil?
                if tokens.current == '--' || options_first
                  return parsed + tokens.map { |v| Argument.new(nil, v) }
          Severity: Minor
          Found in lib/docopt_ng.rb - About 45 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 dump_patterns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def dump_patterns(pattern, indent = 0)
              ws = ' ' * 4 * indent
              out = ''
              if pattern.instance_of?(Array)
                if pattern.count.positive?
          Severity: Minor
          Found in lib/docopt_ng.rb - About 45 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 either has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def either
                ret = []
                groups = [[self]]
                while groups.count.positive?
                  children = groups.shift
          Severity: Minor
          Found in lib/docopt_ng/pattern.rb - About 45 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

                      if tokens.current.nil?
                        raise tokens.error, "#{short} requires argument"
                      end
          Severity: Major
          Found in lib/docopt_ng.rb - About 45 mins to fix

            Method match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def match(left, collected = nil)
                  collected ||= []
                  outcomes = []
                  children.each do |p|
                    matched, = found = p.match(left, collected)
            Severity: Minor
            Found in lib/docopt_ng/either.rb - About 45 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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.parse(option_description)
                  short = nil
                  long = nil
                  argcount = 0
                  value = false
            Severity: Minor
            Found in lib/docopt_ng/option.rb - About 35 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 single_match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def single_match(left)
                  left.each_with_index do |p, n|
                    next unless p.instance_of?(Argument)
                    return n, Command.new(name, true) if p.value == name
            
            
            Severity: Minor
            Found in lib/docopt_ng/command.rb - About 35 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

            Severity
            Category
            Status
            Source
            Language