postmodern/command_mapper.rb

View on GitHub
lib/command_mapper/command.rb

Summary

Maintainability
D
2 days
Test Coverage

Method sudo_command has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def sudo_command(askpass: nil,
                     background: nil,
                     bell: nil,
                     close_from: nil,
                     chdir: nil,
Severity: Minor
Found in lib/command_mapper/command.rb - About 7 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 Command has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Command

    include Types

    # The command name.
Severity: Minor
Found in lib/command_mapper/command.rb - About 3 hrs to fix

    File command.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'types'
    require_relative 'argument'
    require_relative 'option'
    
    require 'shellwords'
    Severity: Minor
    Found in lib/command_mapper/command.rb - About 2 hrs to fix

      Method command_argv has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def command_argv
            argv = [@command_path || @command_name]
      
            self.class.options.each do |name,option|
              unless (value = self[name]).nil?
      Severity: Minor
      Found in lib/command_mapper/command.rb - About 2 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

      Method subcommand has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.subcommand(name,&block)
            name            = name.to_s
            method_name     = name.tr('-','_')
            class_name      = name.split(/[_-]+/).map(&:capitalize).join
            subcommand_name = method_name.to_sym
      Severity: Minor
      Found in lib/command_mapper/command.rb - About 1 hr to fix

        Method command_argv has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def command_argv
              argv = [@command_path || @command_name]
        
              self.class.options.each do |name,option|
                unless (value = self[name]).nil?
        Severity: Minor
        Found in lib/command_mapper/command.rb - About 1 hr to fix

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

              def self.subcommand(name,&block)
                name            = name.to_s
                method_name     = name.tr('-','_')
                class_name      = name.split(/[_-]+/).map(&:capitalize).join
                subcommand_name = method_name.to_sym
          Severity: Minor
          Found in lib/command_mapper/command.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 option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.option(flag, name: nil, value: nil, repeats: false,
                                    # formatting options
                                    equals:        nil,
                                    value_in_flag: nil,
                                    &block)
          Severity: Minor
          Found in lib/command_mapper/command.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

          There are no issues that match your filters.

          Category
          Status