Showing 430 of 4,502 total issues
Method create
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
user = User.find_by(name: params[:user][:name].strip)
unless user
urlCreate = url_for controller: 'users', action: 'new'
flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please <a href=\"#{urlCreate}\">create</a> this user before continuing."
Method assignment_tagging_progress
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def assignment_tagging_progress
teams = Team.where(parent_id: assignment_id)
questions = Question.where(questionnaire_id: questionnaire.id, type: question_type)
questions_ids = questions.map(&:id)
user_answer_tagging = []
- 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 add_table_rows
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. 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) && (question.break_before == true)
- 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 submit_file
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def submit_file
participant = AssignmentParticipant.find(params[:id])
unless current_user_id?(participant.user_id)
flash[:error] = "Authentication Error"
redirect_to action: 'edit', id: participant.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
Method save_topic_deadlines
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_topic_deadlines
assignment = Assignment.find(params[:assignment_id])
@assignment_submission_due_dates = assignment.due_dates.select { |due_date| due_date.deadline_type_id == 1 }
@assignment_review_due_dates = assignment.due_dates.select { |due_date| due_date.deadline_type_id == 2 }
due_dates = params[:due_date]
Method submit_file
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submit_file
participant = AssignmentParticipant.find(params[:id])
unless current_user_id?(participant.user_id)
flash[:error] = "Authentication Error"
redirect_to action: 'edit', id: participant.id
Function showConfirmDialogSpecial
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.rails.showConfirmDialogSpecial = function(link) {
var message = link.attr('data-confirm');
var html1 = "<div class=\"modal\" id=\"dialog-confirm1\" title=\"Delete This User?\">\n <div class=\"modal-body\">\n <p>" + message + "</p>\n";
var html2 = "<div class=\"modal\" id=\"dialog-confirm2\" title=\"System Information\">\n <div class=\"modal-body\">\n <p>This user cannot be deleted. Do you want to rename the user account to <b>" + link.attr('data-username') + "_hidden</b>?</p>\n";
File response.rb
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'analytic/response_analytic'
require 'lingua/en/readability'
class Response < ApplicationRecord
# Added for E1973. A team review will have a lock on it so only one user at a time may edit it.
Function col_sort
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function col_sort(m) {
lesser = !lesser
// Swaps two columns of the table
jQuery.moveColumn = function (table, from, to) {
var rows = jQuery('tr', table);
Method add_reviews
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_reviews(participant, team, vary)
if @questionnaire_type == 'ReviewQuestionnaire'
reviews = if vary
ReviewResponseMap.get_responses_for_team_round(team, @round)
else
Function getShowHour
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function getShowHour()
{
var finalHour;
if (TimeMode==12)
{
- 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 teamed_students
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.teamed_students(user, ip_address = nil)
students_teamed = {}
user.teams.each do |team|
next unless team.is_a?(AssignmentTeam)
# Teammates in calibration assignment should not be counted in teaming requirement.
- 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 scale_criterion_question
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def scale_criterion_question(count, answer = nil, questionnaire_min, questionnaire_max)
if size.nil? || size.blank?
cols = '70'
rows = '1'
else
- 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 delete
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def delete
# delete records in team, teams_users, signed_up_teams table
@team = Team.find_by(id: params[:id])
unless @team.nil?
# Find all SignedUpTeam records associated with the found team.
- 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 update
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def update
@questionnaire = Questionnaire.find(params[:id])
if @questionnaire.nil?
redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]
return
- 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 create
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def create
@assignment_form = AssignmentForm.new(assignment_form_params)
if params[:button]
# E2138 issue #3
find_existing_assignment = Assignment.find_by(name: @assignment_form.assignment.name, course_id: @assignment_form.assignment.course_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
Method team_users_popup
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def team_users_popup
@ip = session[:ip]
@sum = 0
@team = Team.find(params[:id])
@assignment = Assignment.find(@team.parent_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
Method perform
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. 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
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 automatic_review_mapping
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def automatic_review_mapping
assignment_id = params[:id].to_i
assignment = Assignment.find(params[:id])
participants = AssignmentParticipant.where(parent_id: params[:id].to_i).to_a.select(&:can_review).shuffle!
teams = AssignmentTeam.where(parent_id: params[:id].to_i).to_a.shuffle!
Method assignment_questionnaire
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def assignment_questionnaire(questionnaire_type, round_number, topic_id, duty_id = nil)
round_number = nil if round_number.blank?
topic_id = nil if topic_id.blank?
# Default value of duty_id is nil, and when duty_id is not nil, then it means that the function call