dry-rb/dry-cli

View on GitHub

Showing 8 of 9 total issues

Method get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def get(arguments)
        @_mutex.synchronize do
          node   = @root
          args   = []
          names  = []
Severity: Minor
Found in lib/dry/cli/command_registry.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 get has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def get(arguments)
        @_mutex.synchronize do
          node   = @root
          args   = []
          names  = []
Severity: Minor
Found in lib/dry/cli/command_registry.rb - About 1 hr to fix

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

          def self.extended_command_options(command)
            result = command.options.map do |option|
              name = Inflector.dasherize(option.name)
              name = if option.boolean?
                       "[no-]#{name}"
    Severity: Minor
    Found in lib/dry/cli/banner.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_required_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.parse_required_params(command, arguments, prog_name, parsed_options)
            parsed_params          = match_arguments(command.arguments, arguments)
            parsed_required_params = match_arguments(command.required_arguments, arguments)
            all_required_params_satisfied = command.required_arguments.all? { |param| !parsed_required_params[param.name].nil? } # rubocop:disable Metrics/LineLength
    
    
    Severity: Minor
    Found in lib/dry/cli/parser.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 commands_and_arguments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.commands_and_arguments(result)
            max_length = 0
            ret        = commands(result).each_with_object({}) do |(name, node), memo|
              args = if node.command && node.leaf? && node.children?
                       ROOT_COMMAND_WITH_SUBCOMMANDS_BANNER
    Severity: Minor
    Found in lib/dry/cli/usage.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 alias_names has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def alias_names
            aliases
              .map { |name| name.gsub(/^-{1,2}/, '') }
              .compact
              .uniq
    Severity: Minor
    Found in lib/dry/cli/option.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 arguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.arguments(command)
            return unless CLI.command?(command)
    
            required_arguments = command.required_arguments
            optional_arguments = command.optional_arguments
    Severity: Minor
    Found in lib/dry/cli/usage.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 parser_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def parser_options
            dasherized_name = Inflector.dasherize(name)
            parser_options  = []
    
            if boolean?
    Severity: Minor
    Found in lib/dry/cli/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