lib/pry/command.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Command has 48 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Command
    extend Helpers::DocumentationHelpers
    extend CodeObject::Helpers

    include Pry::Helpers::BaseHelpers
Severity: Minor
Found in lib/pry/command.rb - About 6 hrs to fix

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

    require 'delegate'
    require 'shellwords'
    
    class Pry
      # The super-class of all commands, new commands should be created by calling
    Severity: Minor
    Found in lib/pry/command.rb - About 3 hrs to fix

      Method tokenize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def tokenize(val)
            val = interpolate_string(val) if command_options[:interpolate]
      
            self.class.command_regex =~ val
      
      
      Severity: Minor
      Found in lib/pry/command.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 subclass has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def subclass(match, description, options, helpers, &block)
      Severity: Minor
      Found in lib/pry/command.rb - About 35 mins to fix

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

              def match(arg = nil)
                if arg
                  @command_options ||= default_options(arg)
                  @command_options[:listing] = arg.is_a?(String) ? arg : arg.inspect
                  @match = arg
        Severity: Minor
        Found in lib/pry/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

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

            def pass_block(arg_string)
              # Workaround for weird JRuby bug where rindex in this case can return nil
              # even when there's a match.
              arg_string.scan(/\| *(?:do|\{)/)
              block_index = $LAST_MATCH_INFO && $LAST_MATCH_INFO.offset(0)[0]
        Severity: Minor
        Found in lib/pry/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

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

            def check_for_command_collision(command_match, arg_string)
              collision_type = target.eval("defined?(#{command_match})")
              collision_type ||= 'local-variable' if arg_string =~ %r{\A\s*[-+*/%&|^]*=}
        
              if collision_type
        Severity: Minor
        Found in lib/pry/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