Assignment Branch Condition size for teamed_students is too high. [29.85/15] Open
def self.teamed_students(user, ip_address = nil)
students_teamed = {}
user.teams.each do |team|
next unless team.is_a?(AssignmentTeam)
# Teammates in calibration assignment should not be counted in teaming requirement.
- 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
Class StudentTask
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class StudentTask
attr_accessor :assignment, :current_stage, :participant, :stage_deadline, :topic
def initialize(args)
@assignment = args[:assignment]
Method teamed_students
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.teamed_students(user, ip_address = nil)
students_teamed = {}
user.teams.each do |team|
next unless team.is_a?(AssignmentTeam)
# Teammates in calibration assignment should not be counted in teaming requirement.
- 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 get_peer_review_data is too high. [15.17/15] Open
def self.get_peer_review_data(participant_id, timeline_list)
ReviewResponseMap.where(reviewer_id: participant_id).find_each do |rm|
response = Response.where(map_id: rm.id).last
next if response.nil?
timeline = {
- 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
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.to_i
, Time.now.to_f
instead. Open
stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)
- Read upRead up
- Exclude checks
This cop checks for the use of Time methods without zone.
Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .
Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.
When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.
Example:
# always offense
Time.now
Time.parse('2015-03-02 19:05:37')
# no offense
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# no offense only if style is 'flexible'
Time.current
DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
Time.at(timestamp).in_time_zone
Do not use Time.parse
without zone. Use one of Time.zone.parse
, Time.current
, Time.parse.in_time_zone
, Time.parse.utc
, Time.parse.getlocal
, Time.parse.iso8601
, Time.parse.jisx0301
, Time.parse.rfc3339
, Time.parse.to_i
, Time.parse.to_f
instead. Open
stage_deadline: (Time.parse(participant.stage_deadline) rescue Time.now + 1.year)
- Read upRead up
- Exclude checks
This cop checks for the use of Time methods without zone.
Built on top of Ruby on Rails style guide (https://github.com/bbatsov/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/ .
Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.
When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.
Example:
# always offense
Time.now
Time.parse('2015-03-02 19:05:37')
# no offense
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# no offense only if style is 'flexible'
Time.current
DateTime.strptime(str, "%Y-%m-%d %H:%M %Z").in_time_zone
Time.at(timestamp).in_time_zone