piotrmurach/tty-option

View on GitHub

Showing 36 of 50 total issues

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

              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

              Method format_parameter_usage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def format_parameter_usage(param, param_name)
                      args = []
                      if 0 < param.arity
                        args << "[" if param.optional?
                        args << param_name
              Severity: Minor
              Found in lib/tty/option/formatter.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def parse(argv, env)
                      argv = argv.dup
                      params = {}
                      errors = []
                      ignored = []
              Severity: Minor
              Found in lib/tty/option/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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def initialize(arguments, check_invalid_params: true,
                                     raise_on_parse_error: false)
                        @arguments = arguments
                        @error_aggregator =
                          ErrorAggregator.new(raise_on_parse_error: raise_on_parse_error)
              Severity: Minor
              Found in lib/tty/option/parser/arguments.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def call(param, value)
                      return Result.success(value) if !param.convert? || value.nil?
              
                      cast = param.convert
                      cast = cast.is_a?(Proc) ? cast : Conversions[cast]
              Severity: Minor
              Found in lib/tty/option/param_conversion.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 assign_argument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def assign_argument(arg, values)
                        val = case values.size
                              when 0
                                if arg.default?
                                  case arg.default
              Severity: Minor
              Found in lib/tty/option/parser/arguments.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