Showing 2,813 of 2,813 total issues
Assignment Branch Condition size for author_feedback_popup is too high. [26.25/15] Open
def author_feedback_popup
@response_id = params[:response_id]
@reviewee_id = params[:reviewee_id]
unless @response_id.nil?
first_question_in_questionnaire = Answer.where(response_id: @response_id).first.question_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 calculate_all_penalties is too high. [26/15] Open
def calculate_all_penalties(assignment_id)
@all_penalties = {}
@assignment = Assignment.find(assignment_id)
calculate_for_participants = true unless @assignment.is_penalty_calculated
Participant.where(parent_id: assignment_id).each do |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
Assignment Branch Condition size for update_max_choosers is too high. [26.34/15] Open
def update_max_choosers(topic)
# While saving the max choosers you should be careful; if there are users who have signed up for this particular
# topic and are on waitlist, then they have to be converted to confirmed topic based on the availability. But if
# there are choosers already and if there is an attempt to decrease the max choosers, as of now I am not allowing
# it.
- 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 load_questionnaire is too high. [26/15] Open
def load_questionnaire
login_as('student2064')
expect(page).to have_content "User: student2064"
expect(page).to have_content "TestAssignment"
- 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 feedback_response_report
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.feedback_response_report(id, _type)
# Example query
# SELECT distinct reviewer_id FROM response_maps where type = 'FeedbackResponseMap' and
# reviewed_object_id in (select id from responses where
# map_id in (select id from response_maps where reviewed_object_id = 722 and type = 'ReviewResponseMap'))
- 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 scores
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def scores(questions)
scores = {}
scores[:participants] = {}
self.participants.each do |participant|
scores[:participants][participant.id.to_s.to_sym] = participant.scores(questions)
- 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
Block has too many lines. [56/25] Open
describe PopupController do
let(:team) { build(:assignment_team, id: 1, name: "team1", assignment: assignment) }
let(:student) { build(:student, id: 1, name: "student") }
let(:student2) { build(:student, id: 2, name: "student2") }
let(:participant) { build(:participant, id: 1, user: student, assignment: assignment) }
- 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.
File assignment_form.rb
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'active_support/time_with_zone'
class AssignmentForm
attr_accessor :assignment, :assignment_questionnaires, :due_dates, :tag_prompt_deployments
attr_accessor :errors
Function NewCal
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function NewCal(pCtrl,pFormat,pShowTime,pTimeMode)
{
Cal=new Calendar(dtToday);
if ((pShowTime!=null) && (pShowTime))
{
Assignment Branch Condition size for update is too high. [25.32/15] Open
def update(attributes, user)
@has_errors = false
has_late_policy = false
if attributes[:assignment][:late_policy_id].to_i > 0
has_late_policy = true
- 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 html_control is too high. [25.34/15] Open
def html_control(tag_prompt_deployment, answer, user_id)
html = ""
unless answer.nil?
stored_tags = AnswerTag.where(tag_prompt_deployment_id: tag_prompt_deployment.id, answer_id: answer.id, user_id: user_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 add_signup_topic is too high. [25.73/15] Open
def self.add_signup_topic(assignment_id)
@review_rounds = Assignment.find(assignment_id).num_review_rounds
@topics = SignUpTopic.where(assignment_id: assignment_id)
@duedates = {}
return @duedates if @topics.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
Perceived complexity for import is too high. [17/7] Open
def self.import(row_hash, id, options, teamtype)
raise ArgumentError, "Not enough fields on this line." if row_hash.empty? || (row_hash[:teammembers].length < 2 && (options[:has_teamname] == "true_first" || options[:has_teamname] == "true_last")) || (row_hash[:teammembers].empty? && (options[:has_teamname] == "true_first" || options[:has_teamname] == "true_last"))
if options[:has_teamname] == "true_first" || options[:has_teamname] == "true_last"
name = row_hash[:teamname].to_s
- 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
Assignment Branch Condition size for items_for_permissions is too high. [25.71/15] Open
def self.items_for_permissions(permission_ids = nil)
if permission_ids
perms = {}
permission_ids.each {|id| perms[id] = true }
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 export_details_fields is too high. [25.32/15] Open
def self.export_details_fields(detail_options)
fields = []
fields << 'Team ID / Author ID' if detail_options['team_id'] == 'true'
fields << 'Reviewee (Team / Student Name)' if detail_options['team_name'] == 'true'
fields << 'Reviewer' if detail_options['reviewer'] == 'true'
- 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 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
Assignment Branch Condition size for unsubmit_review is too high. [25.73/15] Open
def unsubmit_review
@response = Response.where(map_id: params[:id]).last
review_response_map = ReviewResponseMap.find_by(id: params[:id])
reviewer = review_response_map.reviewer.name
reviewee = review_response_map.reviewee.name
- 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 get_min_max_avg_value_for_review_report is too high. [25.34/15] Open
def get_min_max_avg_value_for_review_report(round, team_id)
%i[max min avg].each {|metric| instance_variable_set('@' + metric.to_s, '-----') }
if @avg_and_ranges[team_id] && @avg_and_ranges[team_id][round] && %i[max min avg].all? {|k| @avg_and_ranges[team_id][round].key? k }
%i[max min avg].each do |metric|
metric_value = @avg_and_ranges[team_id][round][metric].nil? ? '-----' : @avg_and_ranges[team_id][round][metric].round(0).to_s + '%'
- 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 get_each_round_score_awarded_for_review_report is too high. [25.32/15] Open
def get_each_round_score_awarded_for_review_report(reviewer_id, team_id)
(1..@assignment.num_review_rounds).each {|round| instance_variable_set("@score_awarded_round_" + round.to_s, '-----') }
(1..@assignment.num_review_rounds).each do |round|
if @review_scores[reviewer_id] && @review_scores[reviewer_id][round] && @review_scores[reviewer_id][round][team_id] && @review_scores[reviewer_id][round][team_id] != -1.0
instance_variable_set("@score_awarded_round_" + round.to_s, @review_scores[reviewer_id][round][team_id].inspect + '%')
- 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 approve is too high. [25.67/15] Open
def approve
@suggestion = Suggestion.find(params[:id])
@user_id = User.find_by(name: @suggestion.unityID).try(:id)
if @user_id
@team_id = TeamsUser.team_id(@suggestion.assignment_id, @user_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