Class has too many lines. [101/100] Open
class CollusionCycle
# Cycle data structure
# Each edge of the cycle stores a participant and the score given by to the participant by the reviewer.
# Consider a 3 node cycle: A --> B --> C --> A (A reviewed B; B reviewed C and C reviewed A)
# For the above cycle, the data structure would be: [[A, SCA], [B, SAB], [C, SCB]], where SCA is the score given by C to A.
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method four_node_cycles
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def four_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
- 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 has too many lines. [30/10] Open
def four_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
- 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. [23/10] Open
def three_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
next unless ap2.reviewers.include?(assignment_participant)
- 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 four_node_cycles is too high. [25.98/15] Open
def four_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
- 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 three_node_cycles
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def three_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
next unless ap2.reviewers.include?(assignment_participant)
- 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 has too many lines. [16/10] Open
def two_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap|
next unless ap.reviewers.include?(assignment_participant)
if assignment_participant.reviews_by_reviewer(ap).nil?
- 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 three_node_cycles is too high. [19.82/15] Open
def three_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
next unless ap2.reviewers.include?(assignment_participant)
- 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
Perceived complexity for four_node_cycles is too high. [10/7] Open
def four_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Perceived complexity for three_node_cycles is too high. [8/7] Open
def three_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
next unless ap2.reviewers.include?(assignment_participant)
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method has too many lines. [11/10] Open
def cycle_similarity_score(cycle)
similarity_score = 0.0
count = 0.0
(0...cycle.size - 1).each do |pivot|
pivot_score = cycle[pivot][1]
- 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 cycle_deviation_score is too high. [15.65/15] Open
def cycle_deviation_score(cycle)
deviation_score = 0.0
count = 0.0
(0...cycle.size).each do |member|
participant = AssignmentParticipant.find(cycle[member][0].id)
- 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 cycle_similarity_score is too high. [15.84/15] Open
def cycle_similarity_score(cycle)
similarity_score = 0.0
count = 0.0
(0...cycle.size - 1).each do |pivot|
pivot_score = cycle[pivot][1]
- 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 two_node_cycles
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def two_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap|
next unless ap.reviewers.include?(assignment_participant)
if assignment_participant.reviews_by_reviewer(ap).nil?
- 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 four_node_cycles
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def four_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
Block has too many lines. [26/25] Open
assignment_participant.reviewers.each do |ap1|
ap1.reviewers.each do |ap2|
ap2.reviewers.each do |ap3|
next unless ap3.reviewers.include?(assignment_participant)
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap2.reviews_by_reviewer(ap3).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if assignment_participant.reviews_by_reviewer(ap).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap1.reviews_by_reviewer(ap2).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if assignment_participant.reviews_by_reviewer(ap1).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap.reviews_by_reviewer(assignment_participant).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if assignment_participant.reviews_by_reviewer(ap1).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap1.reviews_by_reviewer(ap2).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap2.reviews_by_reviewer(assignment_participant).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if ap3.reviews_by_reviewer(assignment_participant).nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok