Showing 2,813 of 2,813 total issues
Assignment Branch Condition size for export_advices is too high. [22.16/15] Open
def export_advices
@delim_type = params[:delim_type]
filename, delimiter = find_delim_filename(@delim_type, params[:other_char])
allowed_models = ['Question']
- 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 perform is too high. [22.93/15] Open
def perform(assignment_id, deadline_type, due_at)
self.assignment_id = assignment_id
self.deadline_type = deadline_type
self.due_at = 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
Perceived complexity for authorised? is too high. [14/7] Open
def self.authorised?(session, params)
authorised = false # default
check_controller = false
if params[:controller] == 'content_pages' and
- 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
File users_controller.rb
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'will_paginate/array'
class UsersController < ApplicationController
autocomplete :user, :name
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
File tree_display_controller.rb
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
class TreeDisplayController < ApplicationController
helper :application
include SecurityHelper
def action_allowed?
Method assign_reviewer_dynamically
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def assign_reviewer_dynamically
assignment = Assignment.find(params[:assignment_id])
reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first
if params[:i_dont_care].nil? && params[:topic_id].nil? && assignment.topics? && assignment.can_choose_topic_to_review?
- 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 a Cognitive Complexity of 18 (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
Method classify_controllers
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def classify_controllers
from_classes = SiteController.classes
from_db = SiteController.order(:name)
known = {}
- 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 list
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def list
@participant = AssignmentParticipant.find(params[:id].to_i)
@assignment = @participant.assignment
@slots_filled = SignUpTopic.find_slots_filled(@assignment.id)
@slots_waitlisted = SignUpTopic.find_slots_waitlisted(@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
Block has too many lines. [50/25] Open
describe '#assign_reviewer_dynamically' do
before(:each) do
allow(AssignmentParticipant).to receive_message_chain(:where, :first)
.with(user_id: '1', parent_id: 1).with(no_args).and_return(participant)
end
- 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.
Block has too many lines. [50/25] Open
describe "Edit review rubric" do
it "updates review questionnaire" do
within(:css, "tr#questionnaire_table_ReviewQuestionnaire") do
select "ReviewQuestionnaire2", from: 'assignment_form[assignment_questionnaire][][questionnaire_id]'
uncheck('dropdown')
- 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.
Assignment Branch Condition size for update_assignment_questionnaires is too high. [21.47/15] Open
def update_assignment_questionnaires(attributes)
return false unless attributes
validate_assignment_questionnaires_weights(attributes)
@errors = @assignment.errors
unless @has_errors
- 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_assessments_round_for is too high. [21/15] Open
def get_assessments_round_for(participant, round)
team = AssignmentTeam.team(participant)
return nil unless team
team_id = team.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
Perceived complexity for contributor_to_review is too high. [13/7] Open
def contributor_to_review(reviewer, topic)
raise 'Please select a topic' if topics? && topic.nil?
raise 'This assignment does not have topics' if !topics? && topic
# This condition might happen if the reviewer waited too much time in the
# select topic page and other students have already selected this topic.
- 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 initialize is too high. [21.59/15] Open
def initialize(my_score, type)
@my_max = my_score[type][:scores][:max] == -1 ? "N/A" : my_score[type][:scores][:max]
@my_min = my_score[type][:scores][:min] == -1 ? "N/A" : my_score[type][:scores][:min]
@my_avg = my_score[type][:scores][:avg] == -1 ? "N/A" : my_score[type][:scores][:avg]
@my_type = type
- 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 import is too high. [21.95/15] Open
def self.import(row_hash, _row_header = nil, session, id)
raise ArgumentError, "No user id has been specified." if row_hash.empty?
user = User.find_by(name: row_hash[:name])
if user.nil?
raise ArgumentError, "The record containing #{row_hash[:name]} does not have enough items." if row_hash.length < 4
- 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 is too high. [21.63/15] Open
def self.export_details(csv, parent_id, detail_options)
return csv unless detail_options.value?('true')
@assignment = Assignment.find(parent_id)
@answers = {} # Contains all answer objects for this assignment
# Find all unique response types
- 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 add_table_rows is too high. [12/6] Open
def add_table_rows questionnaire_max, questions, answers, code, tag_prompt_deployments = nil, current_user = nil
count = 0
# loop through questions so the the questions are displayed in order based on seq (sequence number)
questions.each do |question|
count += 1 if !question.is_a? QuestionnaireHeader and question.break_before == true
- 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 add_table_rows is too high. [13/7] Open
def add_table_rows questionnaire_max, questions, answers, code, tag_prompt_deployments = nil, current_user = nil
count = 0
# loop through questions so the the questions are displayed in order based on seq (sequence number)
questions.each do |question|
count += 1 if !question.is_a? QuestionnaireHeader and question.break_before == true
- 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 create_questionnaire_csv is too high. [21.75/15] Open
def self.create_questionnaire_csv(questionnaire, _user_name)
csv_data = CSV.generate do |csv|
for question in questionnaire.questions
# Each row is formatted as follows
# Question, question advice (from high score to low), type, weight
- 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