sinm/argparser

View on GitHub

Showing 9 of 9 total issues

Method parse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def parse(argv = ARGV)
    all.each(&:reset)
    _check_manifest

    OPTS_RESERVED.each do |res|
Severity: Minor
Found in lib/argparser/arg_parser.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 printed_help has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def printed_help
    str = StringIO.new
    str.puts(printed_synopsis)
    str.puts(info) if info
    if help
Severity: Minor
Found in lib/argparser/arg_parser.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(manifest)
    hash2vars(ArgParser.manifest.merge(manifest))
    @arguments ||= []
    @options ||= []
    @options = @options.map do |o|
Severity: Minor
Found in lib/argparser/arg_parser.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 _set_short_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def _set_short_options(a, tail)
    a.chars.each_with_index do |char, index|
      terminate(2, TRM_UNKNOWN % char) unless (option = get_option(char))
      if !option.param
        option.add_value(true)
Severity: Minor
Found in lib/argparser/arg_parser.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 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse(argv = ARGV)
    all.each(&:reset)
    _check_manifest

    OPTS_RESERVED.each do |res|
Severity: Minor
Found in lib/argparser/arg_parser.rb - About 1 hr to fix

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

        def hash2vars(hash)
          if hash.kind_of?(Hash) || (hash.respond_to?(:to_h) && (hash = hash.to_h))
            hash.each do |k, v|
              next unless self.respond_to?(k)
              instance_variable_set("@#{k}", v)
    Severity: Minor
    Found in lib/argparser/tools.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 _check_manifest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def _check_manifest
        {:program => program, :version => version}.each do |k, v|
          raise ManifestError, (ERR_MANIFEST_EXPECTED % k) if v.to_s.strip.empty?
        end
    
    
    Severity: Minor
    Found in lib/argparser/arg_parser.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 _set_long_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def _set_long_option(a, tail)
        terminate(2, TRM_UNKNOWN % a) unless a.size > 1 && (o = get_option(a))
        terminate(2, TRM_OPTION_ARGUMENT_EXPECTED % a) if o.param && tail.empty?
        o.add_value(o.param ? tail.shift : true)
      end
    Severity: Minor
    Found in lib/argparser/arg_parser.rb - About 25 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 synopsis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def synopsis
          s = names.map{|n| n.size == 1 ? "-#{n}" : "--#{n}"}.join(', ')
          s << " #{param}" if param
          s = "[#{s}]" if !required
          s << '...' if multiple
    Severity: Minor
    Found in lib/argparser/option.rb - About 25 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