Assignment Branch Condition size for parse_rate is too high. [24.1/15] Open
def parse_rate(spec)
return QueryRateOptions.default if spec.size == 4
raise QueryErrors::InvalidRateOptionError, "invalid specification: #{spec}" if spec.size < 6
parts = split_for(spec[5..-1], ',')
if parts.empty? || parts.size > 3
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [17/10] Open
def split_for(string, token = ':')
result = []
index = start = pos = 0
is_in_bracket = false
string.each_char do |char|
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for parse_metric is too high. [19.34/15] Open
def parse_metric(metric)
start_index = metric.index('{')
return { metric: metric } unless start_index
{}.tap do |h|
h[:metric] = metric[0...start_index]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [14/10] Open
def parse(q_string)
parts = split_for(q_string, ':')
return nil if parts.size < 2 || parts.size > 3
metric_query = {}
metric_query[:aggregator] = parts[0]
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for parse is too high. [18.57/15] Open
def parse(q_string)
parts = split_for(q_string, ':')
return nil if parts.size < 2 || parts.size > 3
metric_query = {}
metric_query[:aggregator] = parts[0]
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for split_for is too high. [17.12/15] Open
def split_for(string, token = ':')
result = []
index = start = pos = 0
is_in_bracket = false
string.each_char do |char|
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [12/10] Open
def parse_metric(metric)
start_index = metric.index('{')
return { metric: metric } unless start_index
{}.tap do |h|
h[:metric] = metric[0...start_index]
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [11/10] Open
def parse_tags(tags)
return if tags.nil?
over_tags = Hash.new { |h, k| h[k] = [] }
excluding_tags = Hash.new { |h, k| h[k] = [] }
split_for(tags, ',').each do |tag|
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Cyclomatic complexity for parse_rate is too high. [7/6] Open
def parse_rate(spec)
return QueryRateOptions.default if spec.size == 4
raise QueryErrors::InvalidRateOptionError, "invalid specification: #{spec}" if spec.size < 6
parts = split_for(spec[5..-1], ',')
if parts.empty? || parts.size > 3
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method parse_rate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse_rate(spec)
return QueryRateOptions.default if spec.size == 4
raise QueryErrors::InvalidRateOptionError, "invalid specification: #{spec}" if spec.size < 6
parts = split_for(spec[5..-1], ',')
if parts.empty? || parts.size > 3
- 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parse(q_string)
parts = split_for(q_string, ':')
return nil if parts.size < 2 || parts.size > 3
metric_query = {}
metric_query[:aggregator] = parts[0]
- 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"