app/assets/javascripts/shared.js
Function checkIfFileSelected
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function checkIfFileSelected(operation){
var tbl = document.getElementById("file_table");
var numChecks = 0;
var flag = 0;
for(i=0; i<document.forms[2].elements.length; i++){
- 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
Consider simplifying this complex logical expression. Open
Open
if(val1 == val2 || val1 == val3 || val1 == val4 || val2 == val3 || val2 == val4 || val3 == val4) {
alert("No two columns can have same value.")
} else {
column_form.submit();
}
Function checkTopicForDuplicatesAndRequiredColumns
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function checkTopicForDuplicatesAndRequiredColumns(optional_count) {
var sel1 = document.getElementById("select1");
var sel2 = document.getElementById("select2");
var sel3 = document.getElementById("select3");
- 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"