Showing 18 of 41 total issues
File librecat.js
has 711 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/**
*
* handling mark/unmark
*
*/
Function link_person
has 213 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function link_person(element){
var type = "";
type = $(element).attr('data-type');
var lineId = $(element).attr('id').replace(type + 'link_person_','');
Function init
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
init: function() {
$('.dz-default.dz-message').addClass('col-md-11');
this.on("uploadprogress", function(file,progress,bytesSent){
$('html').css({ cursor: "wait" });
if (file['accepted'] === true) {
Function add_field
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function add_field(name, placeholder){
var items = $('#' + name + ' div.row.multirow');
var index = items.index($('#' + name + ' div.row.multirow').last()) + 1;
var blueprint = $(items[0]).clone();
//var corrected_index = index;
Function link_person
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
function link_person(element){
var type = "";
type = $(element).attr('data-type');
var lineId = $(element).attr('id').replace(type + 'link_person_','');
- 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 edit_file
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function edit_file(fileId){
var json = jQuery.parseJSON($('#file_' + fileId).val());
if(json.file_id){
$('#id_file_id').val(json.file_id);
}
Consider simplifying this complex logical expression. Open
Open
else if( (old_name.find(o => o.first_name && o.first_name.toLowerCase() === firstname) && lastname == "") || (old_name.find(o => o.last_name && o.last_name.toLowerCase() === lastname) && firstname == "") || (old_name.find(o => o.last_name && o.last_name.toLowerCase() === lastname) && old_name.find(o => o.first_name && o.first_name.toLowerCase() === firstname)) ){
rows += '<tr data-id="' + personId + '" data-orcid="' + orcid + '"><td><a href="' + librecat.uri_base + '/staffdirectory/' + personId + '" target="_blank">' + personId + '</a></td><td class="name" data-firstname="' + first_name + '" data-lastname="' + last_name + '"><a href="#" class="person_link">' + first_name + " " + last_name + '</a></td></tr>';
if(old_name[0]){
for(var j=0;j<old_name.length;j++){
var old_firstname = first_name;
Function edit_file
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
function edit_file(fileId){
var json = jQuery.parseJSON($('#file_' + fileId).val());
if(json.file_id){
$('#id_file_id').val(json.file_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
Function init
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
init: function(){
$('.dz-default.dz-message').addClass('qae');
this.on("addedfile", function(file) {
var fileName = Dropzone.createElement("<div class=\"row\"><div class=\"progress progress-striped active\"><div class=\"progress-bar\" id=\"" + htmlEscape(file.name) + "_progress\" style=\"width:0;text-align:left;padding-left:10px;\">" + file.name + "</span></div></div></div>");
file.previewElement.appendChild(fileName);
Function remove_field
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function remove_field(object){
var container = $(object).closest('div.multirow');
var index = $(container).index();
var total = $(container).parent().children('div.multirow').size();
Function enable_autocomplete
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function enable_autocomplete(field, index) {
var type;
switch(field) {
case "pj":
type = "project"
Avoid deeply nested control flow statements. Open
Open
if(key == "last_name"){
last_name = value;
}
Avoid deeply nested control flow statements. Open
Open
if(key == "first_name"){
first_name = value;
}
Avoid deeply nested control flow statements. Open
Open
if(key == "orcid"){
orcid = value;
}
Avoid deeply nested control flow statements. Open
Open
if((firstname == first_name.toLowerCase() && lastname == "") || (lastname == last_name.toLowerCase() && firstname == "") || (lastname == last_name.toLowerCase() && firstname == first_name.toLowerCase())){
rows += '<tr data-id="' + personId + '" data-orcid="' + orcid + '"><td><a href="' + librecat.uri_base + '/staffdirectory/' + personId + '" target="_blank">' + personId + '</a></td><td class="name" data-firstname="' + first_name + '" data-lastname="' + last_name + '"><a href="#" class="person_link">' + first_name + " " + last_name + '</a></td></tr>';
if(old_name[0]){
for(var j=0;j<old_name.length;j++){
var old_firstname = first_name;
Avoid deeply nested control flow statements. Open
Open
if(key == "old_name"){
old_name = value;
}
Avoid deeply nested control flow statements. Open
Open
if(key == "_id"){
personId = value;
}
Consider simplifying this complex logical expression. Open
Open
if((firstname == first_name.toLowerCase() && lastname == "") || (lastname == last_name.toLowerCase() && firstname == "") || (lastname == last_name.toLowerCase() && firstname == first_name.toLowerCase())){
rows += '<tr data-id="' + personId + '" data-orcid="' + orcid + '"><td><a href="' + librecat.uri_base + '/staffdirectory/' + personId + '" target="_blank">' + personId + '</a></td><td class="name" data-firstname="' + first_name + '" data-lastname="' + last_name + '"><a href="#" class="person_link">' + first_name + " " + last_name + '</a></td></tr>';
if(old_name[0]){
for(var j=0;j<old_name.length;j++){
var old_firstname = first_name;