piotrmurach/tty-option

View on GitHub

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

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

                  def next_keyword
                    kwarg, value = nil, nil
          
                    while !@argv.empty? && !keyword?(@argv.first)
                      @remaining << @argv.shift
          Severity: Major
          Found in lib/tty/option/parser/keywords.rb and 1 other location - About 2 hrs to fix
          lib/tty/option/parser/environments.rb on lines 96..126

          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 79.

          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

                  def next_envvar
                    env_var, value = nil, nil
          
                    while !@argv.empty? && !env_var?(@argv.first)
                      @remaining << @argv.shift
          Severity: Major
          Found in lib/tty/option/parser/environments.rb and 1 other location - About 2 hrs to fix
          lib/tty/option/parser/keywords.rb on lines 87..117

          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 79.

          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

                  def initialize(keywords, check_invalid_params: true,
                                 raise_on_parse_error: false)
                    @keywords = keywords
                    @check_invalid_params = check_invalid_params
                    @error_aggregator =
          Severity: Major
          Found in lib/tty/option/parser/keywords.rb and 1 other location - About 2 hrs to fix
          lib/tty/option/parser/environments.rb on lines 25..52

          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 78.

          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

                  def initialize(environments, check_invalid_params: true,
                                 raise_on_parse_error: false)
                    @environments = environments
                    @check_invalid_params = check_invalid_params
                    @error_aggregator =
          Severity: Major
          Found in lib/tty/option/parser/environments.rb and 1 other location - About 2 hrs to fix
          lib/tty/option/parser/keywords.rb on lines 25..52

          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 78.

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

          Similar blocks of code found in 2 locations. 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: Major
          Found in lib/tty/option/parser/keywords.rb and 1 other location - About 1 hr to fix
          lib/tty/option/parser/environments.rb on lines 145..163

          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 66.

          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

                  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: Major
          Found in lib/tty/option/parser/environments.rb and 1 other location - About 1 hr to fix
          lib/tty/option/parser/keywords.rb on lines 134..152

          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 66.

          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 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_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 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 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

            Severity
            Category
            Status
            Source
            Language