Showing 2,813 of 2,813 total issues
Method view_team
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def view_team
@participant = AssignmentParticipant.find(params[:id])
@assignment = @participant.assignment
@team = @participant.team
@team_id = @team.id
Block has too many lines. [35/25] Open
keys.each do |key|
questionnaire = Questionnaire.find(@review_final_versions[key][:questionnaire_id])
questions = Question.where(questionnaire_id: questionnaire.id)
# Loops by each question per review round
- 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. [35/25] Open
context 'when attributes are not nil and at least one assignment_questionnaire\'s id is nil or blank' do
let(:attributes) { [assignment_questionnaire, assignment_questionnaire2] }
before(:each) do
allow(assignment_questionnaire).to receive(:[]).with(:id).and_return(nil)
allow(assignment_questionnaire).to receive(:[]).with(:questionnaire_weight).and_return(0)
- 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. [35/25] Open
describe "POST #children_node_ng" do
before(:each) do
@treefolder = TreeFolder.new
@treefolder.parent_id = nil
@treefolder.name = "Courses"
- 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. [35/25] Open
context 'when current assignment is a team-based assignment with topics' do
context 'when a student access studet_task#list page of this assignment' do
it 'contains \'Your team\' link on the page'
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.
Function init
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
init:function(automodeperiod){
var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
var selectedtab=-1 //Currently selected tab index (-1 meaning none)
var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
this.automodeperiod=automodeperiod || 0
Method classify_controllers
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def classify_controllers
from_classes = SiteController.classes
from_db = SiteController.order(:name)
known = {}
Similar blocks of code found in 2 locations. Consider refactoring. Open
factory :topic_due_date, class: TopicDueDate do
due_at DateTime.now.in_time_zone + 1.day
deadline_type { DeadlineType.first || association(:deadline_type) }
topic { SignUpTopic.first || association(:topic) }
submission_allowed_id 3
- 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 52.
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
factory :assignment_due_date, class: AssignmentDueDate do
due_at DateTime.now.in_time_zone + 1.day
deadline_type { DeadlineType.first || association(:deadline_type) }
assignment { Assignment.first || association(:assignment) }
submission_allowed_id 3
- 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 52.
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
Method get
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get(sortvar = nil, sortorder = nil, user_id = nil, show = nil, parent_id = nil, _search = nil)
conditions = if show
if User.find(user_id).role.name != "Teaching Assistant"
'questionnaires.instructor_id = ?'
else
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
render: function() {
var renderContent = []
var formStyle = {
margin: 0,
padding: 0,
Function GenCell
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
{
var PValue;
var PCellStr;
var vColor;
Method find_team_participants
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.find_team_participants(assignment_id, ip_address = nil)
@participants = SignedUpTeam.joins('INNER JOIN sign_up_topics ON signed_up_teams.topic_id = sign_up_topics.id')
.select('signed_up_teams.id as id, sign_up_topics.id as topic_id, sign_up_topics.topic_name as name,
sign_up_topics.topic_name as team_name_placeholder, sign_up_topics.topic_name as user_name_placeholder,
signed_up_teams.is_waitlisted as is_waitlisted, signed_up_teams.team_id as team_id')
Method new_quiz
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_quiz
valid_request = true
@assignment_id = params[:aid] # creating an instance variable to hold the assignment id
@participant_id = params[:pid] # creating an instance variable to hold the participant id
assignment = Assignment.find(@assignment_id)
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@id = params[:id]
@model = params[:model]
@options = params[:options]
@delimiter = get_delimiter(params)
Function connect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ddajaxtabs.connect=function(pageurl, tabinstance){
var page_request = false
var bustcacheparameter=""
if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
try {
- 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 contributor_to_review
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. 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
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 10 (exceeds 5 allowed). Consider refactoring. Open
def update(attributes, user)
@has_errors = false
has_late_policy = false
if attributes[:assignment][:late_policy_id].to_i > 0
has_late_policy = 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
Function col_sort
has a Cognitive Complexity of 10 (exceeds 5 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);
- 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 export
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.export(csv, parent_id, options)
where(parent_id: parent_id).find_each do |part|
tcsv = []
user = part.user
tcsv.push(user.name, user.fullname, user.email) if options["personal_details"] == "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"