piotrmurach/tty-option

View on GitHub

Showing 50 of 50 total issues

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

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

Avoid deeply nested control flow statements.
Open

              elsif !@argv.empty?
                value = opt.multi_argument? ? consume_arguments : @argv.shift
Severity: Major
Found in lib/tty/option/parser/options.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                    if opt.multi_argument? &&
                       !(consumed = consume_arguments).empty?
                      value = [other_singles] + consumed
                    end
    Severity: Major
    Found in lib/tty/option/parser/options.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      value = opt.multi_argument? ? consume_arguments : @argv.shift
      Severity: Major
      Found in lib/tty/option/parser/options.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      elsif !@argv.empty?
                        value = opt.multi_argument? ? consume_arguments : @argv.shift
        Severity: Major
        Found in lib/tty/option/parser/options.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          value = opt.multi_argument? ? consume_arguments : @argv.shift
          Severity: Major
          Found in lib/tty/option/parser/options.rb - About 45 mins to fix

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

                  def initialize(param_or_message, arity = nil)
                    if param_or_message.is_a?(Parameter)
                      @param = param_or_message
                      prefix = param.arity < 0 ? "at least " : ""
                      expected_arity = param.arity < 0 ? param.arity.abs - 1 : param.arity
            Severity: Minor
            Found in lib/tty/option/errors.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
            Found in lib/tty/option/parser/environments.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 opt.multi_argument? &&
                               !(consumed = consume_arguments).empty?
                              value = [rest] + consumed
                            end
            Severity: Major
            Found in lib/tty/option/parser/options.rb - About 45 mins to fix

              Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
              Found in lib/tty/option/parser/keywords.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 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      def parse(argv)
                        @argv = argv.dup
              
                        loop do
                          kwarg, value = next_keyword
              Severity: Minor
              Found in lib/tty/option/parser/keywords.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

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

                        loop do
                          kwarg, value = next_keyword
                          if !kwarg.nil?
                            @required_check.delete(kwarg)
                            @arities[kwarg.key] += 1
              Severity: Minor
              Found in lib/tty/option/parser/keywords.rb and 1 other location - About 35 mins to fix
              lib/tty/option/parser/environments.rb on lines 66..77

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

              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

                        loop do
                          env_var, value = next_envvar
                          if !env_var.nil?
                            @required_check.delete(env_var)
                            @arities[env_var.key] += 1
              Severity: Minor
              Found in lib/tty/option/parser/environments.rb and 1 other location - About 35 mins to fix
              lib/tty/option/parser/keywords.rb on lines 62..73

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

              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 consume_arguments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def consume_arguments(values: [])
                        while (value = @argv.first) && !option?(value)
                          val = @argv.shift
                          parts = val.include?("&") ? val.split(/&/) : [val]
                          parts.each { |part| values << part }
              Severity: Minor
              Found in lib/tty/option/parser/options.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

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

                            if !rest.empty?
                              value = rest
                              if opt.multi_argument? &&
                                 !(consumed = consume_arguments).empty?
                                value = [rest] + consumed
              Severity: Minor
              Found in lib/tty/option/parser/options.rb and 1 other location - About 25 mins to fix
              lib/tty/option/parser/options.rb on lines 215..223

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

              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

              Severity
              Category
              Status
              Source
              Language