Showing 2,813 of 2,813 total issues
Function clearbrowseredge
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function clearbrowseredge(obj, whichedge){
if (whichedge=="rightedge"){
edgeoffsetx=0
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
- 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 two_node_cycles
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def two_node_cycles(assignment_participant)
collusion_cycles = []
assignment_participant.reviewers.each do |ap|
next unless ap.reviewers.include?(assignment_participant)
if assignment_participant.reviews_by_reviewer(ap).nil?
- 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 adjust_advice_size
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.adjust_advice_size(questionnaire, question)
# now we only support question advices for scored questions
if question.is_a?(ScoredQuestion)
max = questionnaire.max_question_score
- 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 run_intelligent_assignment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def run_intelligent_assignment
priority_info = []
assignment = Assignment.find_by(id: params[:id])
topics = assignment.sign_up_topics
teams = assignment.teams
- 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 display_directory_tree
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def display_directory_tree(participant, files, display_to_reviewer_flag)
index = 0
participant = @participant if @participant # TODO: Verify why this is needed
assignment = participant.assignment # participant is @map.contributor
topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) # participant is @map.reviewer
- 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 others_work
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def others_work
@participant = AssignmentParticipant.find(params[:id])
return unless current_user_id?(@participant.user_id)
@assignment = @participant.assignment
- 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 redirect
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def redirect
flash[:error] = params[:error_msg] unless params[:error_msg] and params[:error_msg].empty?
flash[:note] = params[:msg] unless params[:msg] and params[:msg].empty?
@map = Response.find_by(map_id: params[:id])
if params[:return] == "feedback"
- 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 calculate_all_penalties
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. 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
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. [38/25] Open
self.teams.each do |team|
scores[:teams][index.to_s.to_sym] = {}
scores[:teams][index.to_s.to_sym][:team] = team
if self.varying_rubrics_by_round?
grades_by_rounds = {}
- 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. [38/25] Open
describe 'Airbrake-1781551925379466692' do
let(:assignment) { build(:assignment, id: 1) }
let(:assignment_questionaire1) { build(:assignment_questionaire1, assignment_id: 1, used_in_round: 2) }
let(:assignment_due_date) do
build(:assignment_due_date, parent_id: 1, due_at: '2011-11-11 11:11:11 UTC', deadline_name: 'Review',
- 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. [38/25] Open
FactoryBot.define do
# Quiz Questionnaire is the main representation of a quiz
# in the Expertiza model. It shares a one-to-many relationship
# with QuizQuestion and QuizResponseMap, and foreign keys
# to an AssignmentTeam. It is important to note that
- 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. [38/25] Open
describe '#update' do
context 'when something is wrong during response updating' do
it 'raise an error and redirects to response#save page' do
allow(review_response).to receive(:update_attribute).with('additional_comment', 'some comments').and_raise('ERROR!')
params = {
- 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. [38/25] Open
before(:each) do
# assignment and topic
create(:assignment,
name: "Assignment1665",
directory_path: "Assignment1665",
- 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.
Method create_approved_user
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_approved_user
requested_user = RequestedUser.find_by(id: params[:id])
requested_user.status = params[:status]
if requested_user.status.nil?
flash[:error] = "Please Approve or Reject before submitting"
Method import
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import(row, _row_header, session, _id = nil)
if row.length != 5
raise ArgumentError, "Not enough items: expect 3 columns: your login name, your full name (first and last name, not seperated with the delimiter), and your email."
end
questionnaire = Questionnaire.find_by_id(_id)
Method submit_file
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submit_file
participant = AssignmentParticipant.find(params[:id])
return unless current_user_id?(participant.user_id)
file = params[:uploaded_file]
participant.team.set_student_directory_num
Method list
has 34 lines of code (exceeds 25 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)
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when the deadline type is team formation and current assignment is team-based assignment' do
it 'adds a delayed job and changes the # of DelayedJob by 2' do
allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'team_formation'))
Sidekiq::Testing.fake!
Sidekiq::RetrySet.new.clear
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
context 'when the deadline type is review' do
it 'adds two delayed jobs and changes the # of DelayedJob by 2' do
allow(DeadlineType).to receive(:find).with(1).and_return(double('DeadlineType', name: 'review'))
Sidekiq::Testing.fake!
Sidekiq::RetrySet.new.clear
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Block has too many lines. [37/25] Open
params[:question].keys.each do |qid|
@question = Question.find(qid)
@question.txt = params[:question][qid.to_sym][:txt]
@question.save
- 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.