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
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?('-')
- Read upRead up
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'
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
- Read upRead up
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|
- Read upRead up
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
- Read upRead up
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_'))
- Read upRead up
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?('-')
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
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 = []
- Read upRead up
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"