Method parse
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
def parse cmdline=ARGV
vals = {}
required = {}
opt :version, "Print version and exit" if @version unless @specs[:version] || @long["version"]
- 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 trollop.rb
has 490 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'date'
module Trollop
VERSION = "2.0"
Method each_arg
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def each_arg args
remains = []
i = 0
until i >= args.length
- 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 opt
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def opt name, desc="", opts={}
raise ArgumentError, "you already have an argument named '#{name}'" if @specs.member? name
## fill in :type
opts[:type] = # normalize
- 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 educate
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def educate stream=$stdout
width # hack: calculate it now; otherwise we have to be careful not to
# call this unless the cursor's at the beginning of a line.
left = {}
@specs.each do |name, spec|
- 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 parse
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse cmdline=ARGV
vals = {}
required = {}
opt :version, "Print version and exit" if @version unless @specs[:version] || @long["version"]
Method opt
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
def opt name, desc="", opts={}
raise ArgumentError, "you already have an argument named '#{name}'" if @specs.member? name
## fill in :type
opts[:type] = # normalize
Method each_arg
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def each_arg args
remains = []
i = 0
until i >= args.length
Class Parser
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Parser
## The set of values that indicate a flag option when passed as the
## +:type+ parameter of #opt.
FLAG_TYPES = [:flag, :bool, :boolean]
Method educate
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def educate stream=$stdout
width # hack: calculate it now; otherwise we have to be careful not to
# call this unless the cursor's at the beginning of a line.
left = {}
@specs.each do |name, spec|
Method wrap_line
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def wrap_line str, opts={}
prefix = opts[:prefix] || 0
width = opts[:width] || (self.width - 1)
start = 0
ret = []
- 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 resolve_default_short_options!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def resolve_default_short_options!
@order.each do |type, name|
next unless type == :opt
opts = @specs[name]
next if opts[:short]
- 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
Avoid deeply nested control flow statements. Open
unless num_params_taken
if @stop_on_unknown
remains += args[i + 1 .. -1]
return remains
else
Avoid too many return
statements within this method. Open
return remains