lib/pry/slop.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Slop has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Slop
    require_relative 'slop/option'
    require_relative 'slop/commands'
    include Enumerable
    VERSION = '3.4.0'.freeze
Severity: Minor
Found in lib/pry/slop.rb - About 4 hrs to fix

    Method process_item has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_item(items, index, &block)
          return unless (item = items[index])
    
          option, argument = extract_option(item) if item.start_with?('-')
    
    
    Severity: Minor
    Found in lib/pry/slop.rb - About 4 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

    File slop.rb has 336 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Pry
      # rubocop:disable Metrics/ClassLength
      class Slop
        require_relative 'slop/option'
        require_relative 'slop/commands'
    Severity: Minor
    Found in lib/pry/slop.rb - About 4 hrs to fix

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

          def parse!(items = ARGV, &block)
            if items.empty? && @callbacks[:empty]
              @callbacks[:empty].each { |cb| cb.call(self) }
              return items
            end
      Severity: Minor
      Found in lib/pry/slop.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 to_s has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_s
            heads  = options.reject(&:tail?)
            tails  = (options - heads)
            opts = (heads + tails).select(&:help).map(&:to_s)
            optstr = opts.each_with_index.map do |o, i|
      Severity: Minor
      Found in lib/pry/slop.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 execute_option has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute_option(option, argument, index, item = nil)
            unless option
              if config[:multiple_switches] && strict?
                raise InvalidOptionError, "Unknown option -#{item}"
              end
      Severity: Minor
      Found in lib/pry/slop.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 extract_option has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_option(flag)
            option = fetch_option(flag)
            option ||= fetch_option(flag.downcase) if config[:ignore_case]
            option ||= fetch_option(flag.gsub(/([^-])-/, '\1_'))
      
      
      Severity: Minor
      Found in lib/pry/slop.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 process_item has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def process_item(items, index, &block)
            return unless (item = items[index])
      
            option, argument = extract_option(item) if item.start_with?('-')
      
      
      Severity: Minor
      Found in lib/pry/slop.rb - About 1 hr to fix

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

            def parse!(items = ARGV, &block)
              if items.empty? && @callbacks[:empty]
                @callbacks[:empty].each { |cb| cb.call(self) }
                return items
              end
        Severity: Minor
        Found in lib/pry/slop.rb - About 1 hr to fix

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

              def initialize(config = {}, &block)
                @config = DEFAULT_OPTIONS.merge(config)
                @options = []
                @commands = {}
                @trash = []
          Severity: Minor
          Found in lib/pry/slop.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