Showing 433 of 433 total issues
Avoid deeply nested control flow statements. Open
else if (isObject(o)) {
for (j in o) {
results[results.length] = o[j];
}
}
Avoid deeply nested control flow statements. Open
if(i in columnNumSortObj) {
columnNumSortObj[i]["thNode"] = workArr[c][i];
columnNumSortObj["active"] = true;
};
Avoid deeply nested control flow statements. Open
for(var cn = workArr[c][i].childNodes.length; cn--;) {
// Skip image nodes and links created by the filter script.
if(workArr[c][i].childNodes[cn].nodeType == 1 && (workArr[c][i].childNodes[cn].className == "fdFilterTrigger" || /img/i.test(workArr[c][i].childNodes[cn].nodeName))) {
continue;
};
Avoid deeply nested control flow statements. Open
if(( i == text_idx && j >= idx ) || i > text_idx ) {
var origSpell = this.wordWin.originalSpellings[i][j];
if( origSpell == preReplSpell ) {
this._setWordText ( i, j, origSpell, undefined );
}
Avoid deeply nested control flow statements. Open
if(( i == text_idx && j >= idx ) || i > text_idx ) {
var origSpell = this.wordWin.originalSpellings[i][j];
if( origSpell == preReplSpell ) {
this.wordFlags[i][j] = undefined;
}
Avoid deeply nested control flow statements. Open
if(!showOnly) {
fdTableSort.initSort(false, true);
} else {
fdTableSort.addThNode();
};
Avoid deeply nested control flow statements. Open
if(dt == todayD && tdm == todayM && tdy == todayY) {
cName.push("date-picker-today");
};
Avoid deeply nested control flow statements. Open
if(showArrow) {
span = fdTableSort.thNode.getElementsByTagName('span')[0];
if(span.firstChild) { span.removeChild(span.firstChild); };
span.appendChild(document.createTextNode(len == 1 ? " \u2193" : " \u2191"));
};
Function show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Popup.show = function(divObject, referenceObject, position, options, modal) {
var popup;
if (defined(divObject)) {
popup = new Popup(divObject);
}
- 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
Avoid deeply nested control flow statements. Open
if (i > 0) out += ', ';
Avoid deeply nested control flow statements. Open
} else if(txt != "") {
fdTableSort.removeClass(th, "sortable");
if(fdTableSort.dateFormat(txt) != 0) {
fdTableSort.addClass(th, "sortable-date");
txt = fdTableSort.dateFormat(txt);
Method generate_other_students
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_other_students(district,school,group)
grades= ['K', '1', '2', '3', '4', '5']
31.upto(60) do |i|
esl=rand(3) == 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 find_intervention
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_intervention
if current_student.blank?
# alternate entry point
intervention = Intervention.find(params[:id])
if intervention && intervention.student && intervention.student.belongs_to_user?(current_user)
- 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 flagged
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def flagged
# only include enrollments for students who have at least one of the intervention types.
scope =@enrollments.where("exists (select id from flags where flags.student_id = students.id)"
).joins(:student=>:flags)
- 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 change_password
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def change_password
@user = current_user
if request.put?
if params['user'] && params['user']['password'].present?
- 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 input_id_from_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def input_id_from_type(type, html_options_id = nil)
if html_options_id.blank?
prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
prefix += "_#{@options[:index]}" if @options.has_key?(:index)
prefix += "_#{@options[:field_name]}" if @options.has_key?(:field_name)
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def update
@team_consultation = TeamConsultation.find(params[:id])
params[:team_consultation][:draft] = false if params[:commit] == "Save" #the js in the view does not work in ff
respond_to do |format|
- 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 generate_intervention_definitions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def generate_intervention_definitions(clusterhash)
CSV.table("#{path}/intervention_definitions.csv").each do |ck|
next unless ckhash = prephash(ck)
ckhash[:intervention_cluster_id]= clusterhash[ck[:intervention_cluster_id]]
unless ckhash[:disabled] or ckhash[:custom]
- 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 new
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def new
#Users who are signed in, but go directly to the login page
#are prompted to log in, but stay as the previous user
sign_out && reset_session if user_signed_in?
#fix for above
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (typeof(obj)!="object" || obj==null || !defined(obj.className) || obj.className==null) { return false; }
- 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 50.
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