Showing 2,813 of 2,813 total issues
File import_file_controller.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ImportFileController < ApplicationController
def action_allowed?
['Instructor',
'Teaching Assistant',
'Administrator',
Assignment Branch Condition size for export is too high. [19.1/15] Open
def self.export(csv, parent_id, _options)
mappings = Assignment.find(parent_id).metareview_mappings
mappings = mappings.sort_by {|a| [a.review_mapping.reviewee.name, a.reviewee.name, a.reviewer.name] }
mappings.each do |map|
csv << [
- 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 is too high. [19.39/15] Open
def get(url, limit = 5)
return "" if limit <= 0
uri = URI.parse(url)
req = Net::HTTP::Get.new(uri.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 add_member is too high. [19.52/15] Open
def add_member(user, _assignment_id = nil)
raise "The user #{user.name} is already a member of the team #{self.name}" if user?(user)
can_add_member = false
unless full?
can_add_member = 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
Cyclomatic complexity for complete is too high. [10/6] Open
def complete(count, answer = nil, questionnaire_min, questionnaire_max)
html = '<div><label for="responses_' + count.to_s + '">' + self.txt + '</label></div>'
html += '<input id="responses_' + count.to_s + '_score" name="responses[' + count.to_s + '][score]" type="hidden"'
html += 'value="' + answer.answer.to_s + '"' unless answer.nil?
html += '>'
- 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.
Perceived complexity for items_for_permissions is too high. [11/7] 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 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
Cyclomatic complexity for get_authorization is too high. [10/6] Open
def self.get_authorization(can_submit, can_review, can_take_quiz)
authorization = 'participant'
authorization = 'reader' if can_submit == false and can_review == true and can_take_quiz == true
authorization = 'submitter' if can_submit == true and can_review == false and can_take_quiz == false
authorization = 'reviewer' if can_submit == false and can_review == true and can_take_quiz == false
- 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.
Cyclomatic complexity for csv_row is too high. [10/6] Open
def self.csv_row(detail_options, answer)
tcsv = []
@response = Response.find(answer.response_id)
map = ResponseMap.find(@response.map_id)
@reviewee = Team.find_by id: map.reviewee_id
- 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.
Assignment Branch Condition size for get_user_list is too high. [19.21/15] Open
def self.get_user_list(user)
participants = []
user_list = []
Course.where(instructor_id: user.id).find_each do |course|
participants << course.get_participants
- 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 construct_instructor_html is too high. [19.42/15] Open
def construct_instructor_html identifier, self_id, count
identifier += '<h4><B>Review ' + count.to_s + '</B></h4>'
identifier += '<B>Reviewer: </B>' + self.map.reviewer.fullname + ' (' + self.map.reviewer.name + ')'
identifier + ' <a href="#" name= "review_' + self_id + 'Link" onClick="toggleElement(' \
"'review_" + self_id + "','review'" + ');return false;">show review</a><BR/>'
- 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 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
Method has too many lines. [104/100] Open
def complete(count, answer = nil, questionnaire_min, questionnaire_max, dropdown_or_scale)
if self.size.nil?
cols = '70'
rows = '1'
else
- 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 merge_scores is too high. [11/7] Open
def merge_scores(scores)
review_sym = "review".to_sym
scores[review_sym] = {}
scores[review_sym][:assessments] = []
scores[review_sym][:scores] = {max: -999_999_999, min: 999_999_999, avg: 0}
- 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
Cyclomatic complexity for contributor_for_quiz is too high. [10/6] Open
def contributor_for_quiz(reviewer, topic)
raise "Please select a topic." if topics? and topic.nil?
raise "This assignment does not have topics." if !topics? and topic
# This condition might happen if the reviewer/quiz taker waited too much time in the
- 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.
Assignment Branch Condition size for due_date is too high. [19.08/15] Open
def due_date(assignment, type, round = 0)
due_dates = assignment.find_due_dates(type)
due_dates.delete_if {|due_date| due_date.due_at.nil? }
due_dates.sort! {|x, y| x.due_at <=> y.due_at }
- 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 define_attributes is too high. [19.54/15] Open
def self.define_attributes(row_hash)
attributes = {}
attributes["topic_identifier"] = row_hash[:topic_identifier].strip
attributes["topic_name"] = row_hash[:topic_name].strip
attributes["max_choosers"] = row_hash[:max_choosers].strip
- 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 has_team_and_metareview? is too high. [19/15] Open
def has_team_and_metareview?
if params[:action] == "view"
@assignment = Assignment.find(params[:id])
@assignment_id = @assignment.id
elsif %w[view_my_scores view_review].include? params[:action]
- 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 create_teams is too high. [19.03/15] Open
def create_teams
parent = Object.const_get(session[:team_type]).find(params[:id])
Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)
undo_link("Random teams have been successfully created.")
ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)
- 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
Cyclomatic complexity for associated_courses is too high. [10/6] Open
def associated_courses(user)
# NOTE: testing for roles in general is a bad practice but since the data base does not provide clear
# way to get this association we have no other choice
case user.role_id
# admin and super admin should be able to see all courses
- 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.
Assignment Branch Condition size for get_each_round_review_and_feedback_response_map_for_feedback_report is too high. [19.67/15] Open
def get_each_round_review_and_feedback_response_map_for_feedback_report(author)
@team_id = TeamsUser.team_id(@id.to_i, author.user_id)
# Calculate how many responses one team received from each round
# It is the feedback number each team member should make
@review_response_map_ids = ReviewResponseMap.where(["reviewed_object_id = ? and reviewee_id = ?", @id, @team_id]).pluck("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