Class has too many lines. [199/100] Open
class ParticipantsController < ApplicationController
include AuthorizationHelper
include ParticipantsHelper
autocomplete :user, :name
- 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 add is too high. [48.44/15] Open
def add
curr_object = Object.const_get(params[:model]).find(params[:id]) if Participant::PARTICIPANT_TYPES.include? params[:model]
begin
permissions = participant_permissions(params[:authorization])
can_submit = permissions[:can_submit]
- 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 change_handle is too high. [36.18/15] Open
def change_handle
@participant = AssignmentParticipant.find(params[:id])
return unless current_user_id?(@participant.user_id)
unless params[:participant].nil?
- 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. [22/10] Open
def inherit
assignment = Assignment.find(params[:id])
course = assignment.course
@copied_participants = []
if 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.
Method has too many lines. [21/10] Open
def add
curr_object = Object.const_get(params[:model]).find(params[:id]) if Participant::PARTICIPANT_TYPES.include? params[:model]
begin
permissions = participant_permissions(params[:authorization])
can_submit = permissions[:can_submit]
- 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 view_copyright_grants is too high. [25.02/15] Open
def view_copyright_grants
assignment_id = params[:id]
assignment = Assignment.find(assignment_id)
@assignment_name = assignment.name
@has_topics = false
- 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. [18/10] Open
def view_copyright_grants
assignment_id = params[:id]
assignment = Assignment.find(assignment_id)
@assignment_name = assignment.name
@has_topics = false
- 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 inherit is too high. [22.83/15] Open
def inherit
assignment = Assignment.find(params[:id])
course = assignment.course
@copied_participants = []
if 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. [17/10] Open
def bequeath_all
@copied_participants = []
assignment = Assignment.find(params[:id])
if assignment.course
course = assignment.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 list is too high. [22.89/15] Open
def list
if Participant::PARTICIPANT_TYPES.include? params[:model]
@root_node = Object.const_get(params[:model] + 'Node').find_by(node_object_id: params[:id])
@parent = Object.const_get(params[:model]).find(params[:id])
end
- 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 update_authorizations is too high. [20.15/15] Open
def update_authorizations
participant = Participant.find(params[:id])
permissions = participant_permissions(params[:authorization])
can_submit = permissions[:can_submit]
can_review = permissions[:can_review]
- 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 bequeath_all is too high. [19.21/15] Open
def bequeath_all
@copied_participants = []
assignment = Assignment.find(params[:id])
if assignment.course
course = assignment.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. [14/10] Open
def update_authorizations
participant = Participant.find(params[:id])
permissions = participant_permissions(params[:authorization])
can_submit = permissions[:can_submit]
can_review = permissions[:can_review]
- 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. [13/10] Open
def get_signup_topics_for_assignment(assignment_id, team_info, team_id)
signup_topics = SignUpTopic.where('assignment_id = ?', assignment_id)
if signup_topics.any?
has_topics = true
signup_topics.each do |signup_topic|
- 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. [13/10] Open
def change_handle
@participant = AssignmentParticipant.find(params[:id])
return unless current_user_id?(@participant.user_id)
unless params[:participant].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.
Method has too many lines. [11/10] Open
def list
if Participant::PARTICIPANT_TYPES.include? params[:model]
@root_node = Object.const_get(params[:model] + 'Node').find_by(node_object_id: params[:id])
@parent = Object.const_get(params[:model]).find(params[:id])
end
- 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.
Perceived complexity for inherit is too high. [8/7] Open
def inherit
assignment = Assignment.find(params[:id])
course = assignment.course
@copied_participants = []
if course
- 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 inherit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def inherit
assignment = Assignment.find(params[:id])
course = assignment.course
@copied_participants = []
if 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 view_copyright_grants
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def view_copyright_grants
assignment_id = params[:id]
assignment = Assignment.find(assignment_id)
@assignment_name = assignment.name
@has_topics = false
- 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 bequeath_all
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def bequeath_all
@copied_participants = []
assignment = Assignment.find(params[:id])
if assignment.course
course = assignment.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
Missing space after #
. Open
#E2351 - add corresponding duty fill from permissions
- Read upRead up
- Exclude checks
This cop checks whether comments have a leading space after the
#
denoting the start of the comment. The leading space is not
required for some RDoc special syntax, like #++
, #--
,
#:nodoc
, =begin
- and =end
comments, "shebang" directives,
or rackup options.
Example:
# bad
#Some comment
# good
# Some comment
Use a guard clause instead of wrapping the code inside a conditional expression. Open
unless params[: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
Missing top-level class documentation comment. Open
class ParticipantsController < 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
1 trailing blank lines detected. Open
- Exclude checks
Use only ascii symbols in comments. Open
# A ‘copyright grant’ means the author has given permission to the instructor to use the work outside the course.
- Read upRead up
- Exclude checks
This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).
Example:
# bad
# Translates from English to 日本語。
# good
# Translates from English to Japanese
rescue
at 166, 4 is not aligned with end
at 168, 6. Open
rescue StandardError
- Read upRead up
- Exclude checks
This cop checks whether the rescue and ensure keywords are aligned properly.
Example:
# bad
begin
something
rescue
puts 'error'
end
# good
begin
something
rescue
puts 'error'
end