piotrmurach/tty-option

View on GitHub

Showing 36 of 50 total issues

Method process_double_option has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

        def process_double_option(long, sep, rest)
          opt, value = nil, nil

          if (opt = @longs[long])
            if opt.argument_required?
Severity: Minor
Found in lib/tty/option/parser/options.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 process_single_option has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

        def process_single_option(short, other_singles)
          opt, value = nil, nil

          if (opt = @shorts[short])
            if opt.argument_required?
Severity: Minor
Found in lib/tty/option/parser/options.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

Class Formatter has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Formatter
      include UsageWrapper

      BOOLEANS = [true, false].freeze
      DEFAULT_WIDTH = 80
Severity: Minor
Found in lib/tty/option/formatter.rb - About 4 hrs to fix

    Class Parameter has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Parameter
          include Comparable
          include DSL::Arity
          include DSL::Conversion
    
    
    Severity: Minor
    Found in lib/tty/option/parameter.rb - About 4 hrs to fix

      File formatter.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative "sections"
      require_relative "usage_wrapper"
      
      module TTY
        module Option
      Severity: Minor
      Found in lib/tty/option/formatter.rb - About 3 hrs to fix

        Method process_double_option has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def process_double_option(long, sep, rest)
                  opt, value = nil, nil
        
                  if (opt = @longs[long])
                    if opt.argument_required?
        Severity: Major
        Found in lib/tty/option/parser/options.rb - About 2 hrs to fix

          Method next_envvar has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                  def next_envvar
                    env_var, value = nil, nil
          
                    while !@argv.empty? && !env_var?(@argv.first)
                      @remaining << @argv.shift
          Severity: Minor
          Found in lib/tty/option/parser/environments.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 next_keyword has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                  def next_keyword
                    kwarg, value = nil, nil
          
                    while !@argv.empty? && !keyword?(@argv.first)
                      @remaining << @argv.shift
          Severity: Minor
          Found in lib/tty/option/parser/keywords.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 process_single_option has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def process_single_option(short, other_singles)
                    opt, value = nil, nil
          
                    if (opt = @shorts[short])
                      if opt.argument_required?
          Severity: Minor
          Found in lib/tty/option/parser/options.rb - About 1 hr to fix

            Method process_infinite_arity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    def process_infinite_arity(arg)
                      values = []
                      arity = arg.arity.abs - 1
            
                      arity.times do
            Severity: Minor
            Found in lib/tty/option/parser/arguments.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 assign_envvar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def assign_envvar(env_arg, val)
                      value = @pipeline.(env_arg, val)
            
                      if env_arg.multiple?
                        allowed = env_arg.arity < 0 || @arities[env_arg.key] <= env_arg.arity
            Severity: Minor
            Found in lib/tty/option/parser/environments.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 assign_keyword has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def assign_keyword(kwarg, val)
                      value = @pipeline.(kwarg, val)
            
                      if kwarg.multiple?
                        allowed = kwarg.arity < 0 || @arities[kwarg.key] <= kwarg.arity
            Severity: Minor
            Found in lib/tty/option/parser/keywords.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 help has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                  def help
                    sections = Sections.new
            
                    sections.add(:header, help_header) if @usage.header?
                    sections.add(:banner, help_banner)
            Severity: Minor
            Found in lib/tty/option/formatter.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 assign_option has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                    def assign_option(opt, val)
                      value = @pipeline.(opt, val)
            
                      if opt.multiple?
                        allowed = opt.arity < 0 || @arities[opt.key] <= opt.arity
            Severity: Minor
            Found in lib/tty/option/parser/options.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def initialize(parameters, remaining: [], errors: [])
                    @parameters = parameters
                    @parameters.default_proc = ->(hash, key) do
                      return hash[key] if hash.key?(key)
            
            
            Severity: Minor
            Found in lib/tty/option/params.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 setup_opts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def setup_opts
                      @options.each do |opt|
                        @shorts[opt.short_name] = opt
                        @longs[opt.long_name] = opt
                        @arity_check << opt if opt.multiple?
            Severity: Minor
            Found in lib/tty/option/parser/options.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def parse(argv, env)
                      @argv = argv.dup
                      @env = env
            
                      loop do
            Severity: Minor
            Found in lib/tty/option/parser/environments.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 process_exact_arity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def process_exact_arity(arg)
                      values = []
                      arity = arg.arity
            
                      while arity > 0
            Severity: Minor
            Found in lib/tty/option/parser/arguments.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def parse(argv)
                      @argv = argv.dup
            
                      loop do
                        opt, value = next_option
            Severity: Minor
            Found in lib/tty/option/parser/options.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 format_parameter_description has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def format_parameter_description(param)
                    desc = []
            
                    desc << "  #{param.desc}" if param.desc?
            
            
            Severity: Minor
            Found in lib/tty/option/formatter.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

            Severity
            Category
            Status
            Source
            Language