Showing 2,813 of 2,813 total issues
Function RenderCal
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
function RenderCal()
{
var vCalHeader;
var vCalData;
var vCalTime;
Method save_choices
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def save_choices(questionnaire_id)
return unless params[:new_question] or params[:new_choices]
questions = Question.where(questionnaire_id: questionnaire_id)
question_num = 1
- 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 27 (exceeds 5 allowed). Consider refactoring. Open
def list
@automated_metareview = AutomatedMetareview.new
# pass in the response id as a parameter
@response = Response.find_by(map_id: params[:id])
@automated_metareview.calculate_metareview_metrics(@response, params[: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
Assignment Branch Condition size for run is too high. [34.31/15] Open
def self.run(assignment_id)
assignment = Assignment.find(assignment_id)
teams = Team.where(parent_id: assignment_id)
code_assignment_submission_id = self.create_new_assignment_submission(assignment.name + " (Code)")
- 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 folder_action is too high. [34.94/15] Open
def folder_action
@participant = AssignmentParticipant.find(params[:id])
return unless current_user_id?(@participant.user_id)
@current_folder = DisplayOption.new
@current_folder.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 update is too high. [34.1/15] Open
def update
# Flash an error if neither an action nor a page has been selected
if params[:menu_item][:controller_action_id].blank? and
params[:menu_item][:content_page_id].blank?
flash[:error] = "You must specify either an action or a page!"
- 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 is too high. [34.37/15] Open
def update
params.permit!
@user = session[:user]
unless params[:assignment_questionnaire].nil? or params[:assignment_questionnaire][:notification_limit].blank?
- 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 import_from_hash is too high. [25/6] Open
def import_from_hash(session, params)
contents_hash = eval(params[:contents_hash])
if params[:model] == "AssignmentTeam" or params[:model] == "CourseTeam"
# contents_hash = eval(params[:contents_hash])
@header_integrated_body = hash_rows_with_headers(contents_hash[:header], contents_hash[:body])
- 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 assignment_form_key_nonexist_case_handler is too high. [34.25/15] Open
def assignment_form_key_nonexist_case_handler
@assignment = Assignment.find(params[:id])
@assignment.course_id = params[:course_id]
if @assignment.save
- 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
File collusion_cycle_spec.rb
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
describe CollusionCycle do
#
# assignment participant -----
# ^ |
# | V
Class AssignmentTeam
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class AssignmentTeam < Team
require File.dirname(__FILE__) + '/analytic/assignment_team_analytic'
include AssignmentTeamAnalytic
belongs_to :assignment, class_name: 'Assignment', foreign_key: 'parent_id'
Class User
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
acts_as_authentic do |config|
config.validates_uniqueness_of_email_field_options = {if: -> { false }} # Don't validate email uniqueness
config.crypto_provider = Authlogic::CryptoProviders::Sha1
Authlogic::CryptoProviders::Sha1.join_token = ''
Block has too many lines. [67/25] Open
describe '#three_node_cycles' do
context 'when the reviewers of current reviewer (ap2) does not include current assignment participant' do
it 'skips this reviewer (ap2) and returns corresponding collusion cycles' do
# Sets up stubs for test
allow(ReviewResponseMap).to receive(:where).with('reviewee_id = ?', team1.id).and_return([response_map_team_1_2])
- 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 assignments_controller.rb
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
class AssignmentsController < ApplicationController
include AssignmentHelper
autocomplete :user, :name
before_action :authorize
Assignment Branch Condition size for update_due_dates is too high. [33.32/15] Open
def update_due_dates(attributes, user)
return false unless attributes
attributes.each do |due_date|
next if due_date[:due_at].blank?
# parse the dd and convert it to utc before saving it to db
- 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 path is too high. [33.48/15] Open
def path
if self.course_id.nil? && self.instructor_id.nil?
raise 'The path cannot be created. The assignment must be associated with either a course or an instructor.'
end
path_text = ""
- 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. [24/6] 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 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 notify_instructor_on_difference is too high. [33.96/15] Open
def notify_instructor_on_difference
response_map = self.map
reviewer_participant_id = response_map.reviewer_id
reviewer_participant = AssignmentParticipant.find(reviewer_participant_id)
reviewer_name = User.find(reviewer_participant.user_id).fullname
- 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_pie_chart_url is too high. [33.62/15] Open
def self.get_pie_chart_url(labels, values)
return "" if labels.length != values.length
address = "http://chart.apis.google.com/chart?cht=p3&chs=300x125"
max = 100.0
- 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_topic_bg_color is too high. [33.06/15] Open
def get_topic_bg_color(topic, max_team_size)
red = (400 * (1 - (Math.tanh(2 * [max_team_size.to_f / Bid.where(topic_id: topic.id).count, 1].min - 1) + 1) / 2)).to_i.to_s
green = (400 * (Math.tanh(2 * [max_team_size.to_f / Bid.where(topic_id: topic.id).count, 1].min - 1) + 1) / 2).to_i.to_s
'rgb(' + red + ',' + green + ',0)'
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