Class has too many lines. [147/100] Open
class Assessment360Controller < ApplicationController
include GradesHelper
include AuthorizationHelper
include Scoring
include PenaltyHelper
- 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.
Assignment Branch Condition size for course_student_grade_summary is too high. [47.55/15] Open
def course_student_grade_summary
@topics = {}
@assignment_grades = {}
@peer_review_scores = {}
@final_grades = {}
- 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. [41/10] Open
def all_students_all_reviews
course = Course.find(params[:course_id])
@assignments = course.assignments.reject(&:is_calibrated).reject { |a| a.participants.empty? }
@course_participants = course.get_participants
insure_existence_of(@course_participants, course)
- 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 all_students_all_reviews is too high. [43.12/15] Open
def all_students_all_reviews
course = Course.find(params[:course_id])
@assignments = course.assignments.reject(&:is_calibrated).reject { |a| a.participants.empty? }
@course_participants = course.get_participants
insure_existence_of(@course_participants, course)
- 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. [29/10] Open
def course_student_grade_summary
@topics = {}
@assignment_grades = {}
@peer_review_scores = {}
@final_grades = {}
- 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 course_student_grade_summary
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def course_student_grade_summary
@topics = {}
@assignment_grades = {}
@peer_review_scores = {}
@final_grades = {}
- 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
Assignment Branch Condition size for calc_overall_review_info is too high. [29.58/15] Open
def calc_overall_review_info(assignment,
course_participant,
reviews,
hash_per_stu,
overall_review_grade_hash,
- 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 assignment_grade_summary is too high. [24.12/15] Open
def assignment_grade_summary(cp, assignment_id, penalties)
user_id = cp.user_id
# topic exists if a team signed up for a topic, which can be found via the user and the assignment
topic_id = SignedUpTeam.topic_id(assignment_id, user_id)
@topics[cp.id][assignment_id] = SignUpTopic.find_by(id: topic_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
Method has too many lines. [14/10] Open
def calc_overall_review_info(assignment,
course_participant,
reviews,
hash_per_stu,
overall_review_grade_hash,
- 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 course_student_grade_summary is too high. [7/6] Open
def course_student_grade_summary
@topics = {}
@assignment_grades = {}
@peer_review_scores = {}
@final_grades = {}
- 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 all_students_all_reviews
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def all_students_all_reviews
course = Course.find(params[:course_id])
@assignments = course.assignments.reject(&:is_calibrated).reject { |a| a.participants.empty? }
@course_participants = course.get_participants
insure_existence_of(@course_participants, course)
Method all_students_all_reviews
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def all_students_all_reviews
course = Course.find(params[:course_id])
@assignments = course.assignments.reject(&:is_calibrated).reject { |a| a.participants.empty? }
@course_participants = course.get_participants
insure_existence_of(@course_participants, course)
- 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 course_student_grade_summary
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def course_student_grade_summary
@topics = {}
@assignment_grades = {}
@peer_review_scores = {}
@final_grades = {}
Method calc_overall_review_info
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def calc_overall_review_info(assignment,
course_participant,
reviews,
hash_per_stu,
overall_review_grade_hash,
Method calc_overall_review_info
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def calc_overall_review_info(assignment,
course_participant,
reviews,
hash_per_stu,
overall_review_grade_hash,
- 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 parameter lists longer than 5 parameters. [7/5] Open
def calc_overall_review_info(assignment,
course_participant,
reviews,
hash_per_stu,
overall_review_grade_hash,
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Block has too many lines. [27/25] Open
@course_participants.each do |cp|
# for each assignment
# [aggregrate_review_grades_per_stu, review_count_per_stu] --> [0, 0]
%w[teammate meta].each { |type| instance_variable_set("@#{type}_review_info_per_stu", [0, 0]) }
students_teamed = StudentTask.teamed_students(cp.user)
- 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.
Method overall_review_count
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def overall_review_count(assignments, overall_teammate_review_count, overall_meta_review_count)
assignments.each do |assignment|
temp_count = overall_teammate_review_count[assignment.id]
overall_teammate_review_count[assignment.id] = 1 if temp_count.nil? || temp_count.zero?
temp_count = overall_meta_review_count[assignment.id]
- 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
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if avg_grades && (grades >= 0)
- 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 review_info_per_stu[1] > 0
- 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 course_participants.empty?
- 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
Missing top-level class documentation comment. Open
class Assessment360Controller < ApplicationController
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
# good
# Description/Explanation of Person class
class Person
# ...
end