LibreCat/LibreCat

View on GitHub

Showing 41 of 41 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
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;
Severity: Major
Found in public/javascripts/librecat.js and 1 other location - About 1 day to fix
public/javascripts/librecat.js on lines 320..355

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 298.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
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;
Severity: Major
Found in public/javascripts/librecat.js and 1 other location - About 1 day to fix
public/javascripts/librecat.js on lines 332..355

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 298.

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

Further Reading

File librecat.js has 711 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 *
 * handling mark/unmark
 *
 */
Severity: Major
Found in public/javascripts/librecat.js - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

              $(cont).each(function(cindex){
                      var newindex = parseInt(cindex) + parseInt(index);
                      var current_container = $(this);
                      $(current_container).find('input, textarea, img, select, span').each(function(){
                              if($(this).attr('id')){
    Severity: Major
    Found in public/javascripts/librecat.js and 1 other location - About 1 day to fix
    public/javascripts/librecat.js on lines 682..701

    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 268.

    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

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

              $(cont).each(function(cindex){
                      var newindex = parseInt(cindex) + parseInt(index);
                      var current_container = $(this);
                      $(current_container).find('input, textarea, img, select, span').each(function(){
                              if($(this).attr('id')){
    Severity: Major
    Found in public/javascripts/librecat.js and 1 other location - About 1 day to fix
    public/javascripts/librecat.js on lines 730..749

    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 268.

    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

    Further Reading

    Function link_person has 213 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function link_person(element){
        var type = "";
        type = $(element).attr('data-type');
        var lineId = $(element).attr('id').replace(type + 'link_person_','');
    
    
    Severity: Major
    Found in public/javascripts/librecat.js - About 1 day to fix

      Function init has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      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) {
      Severity: Major
      Found in public/javascripts/librecat_dropzones.js - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if($(this).parent('div.sticky').hasClass('mandatory')){
                                $(this).parent('div.sticky').css("-webkit-box-shadow", "inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d3d3d3");
                                $(this).parent('div.sticky').css("box-shadow", "inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d3d3d3");
                                $(this).parent('div.sticky').css("border", "1px solid #666");
                                $(this).css("box-shadow", "inset 0 1px 1px -1px rgba(0, 0, 0, 0.075), 0 0 6px -6px #d3d3d3");
        Severity: Major
        Found in public/javascripts/librecat.js and 1 other location - About 2 hrs to fix
        public/javascripts/librecat.js on lines 818..823

        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 91.

        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

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        else {
                                $(this).parent('div.sticky').css("-webkit-box-shadow", "inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6)");
                                $(this).parent('div.sticky').css("box-shadow","inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6)");
                                $(this).parent('div.sticky').css("border", "1px solid #66afe9");
                                $(this).css("box-shadow", "inset 0 1px 1px -1px rgba(0, 0, 0, 0.075), 0 0 8px -8px rgba(102, 175, 233, 0.6)");
        Severity: Major
        Found in public/javascripts/librecat.js and 1 other location - About 2 hrs to fix
        public/javascripts/librecat.js on lines 812..817

        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 91.

        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

        Further Reading

        Function add_field has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        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;
        Severity: Major
        Found in public/javascripts/librecat.js - About 2 hrs to fix

          Function link_person has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          function link_person(element){
              var type = "";
              type = $(element).attr('data-type');
              var lineId = $(element).attr('id').replace(type + 'link_person_','');
          
          
          Severity: Minor
          Found in public/javascripts/librecat.js - About 2 hrs to fix

          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

                          success: function(res) {
                              $('.total-marked').text(res.total);
                              a.data('marked', 0);
                              a.children('span').removeClass('fa-check-square-o');
                              a.children('span').addClass('fa-square-o');
          Severity: Major
          Found in public/javascripts/librecat.js and 1 other location - About 2 hrs to fix
          public/javascripts/librecat.js on lines 17..22

          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 80.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          success: function(res) {
                              $('.total-marked').text(res.total);
                              a.data('marked', 1);
                              a.children('span').removeClass('fa-square-o');
                              a.children('span').addClass('fa-check-square-o');
          Severity: Major
          Found in public/javascripts/librecat.js and 1 other location - About 2 hrs to fix
          public/javascripts/librecat.js on lines 30..35

          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 80.

          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

          Further Reading

          Function edit_file has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function edit_file(fileId){
                  var json = jQuery.parseJSON($('#file_' + fileId).val());
                  if(json.file_id){
                          $('#id_file_id').val(json.file_id);
                  }
          Severity: Major
          Found in public/javascripts/librecat.js - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            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;
            Severity: Critical
            Found in public/javascripts/librecat.js - About 2 hrs to fix

              Function edit_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              function edit_file(fileId){
                      var json = jQuery.parseJSON($('#file_' + fileId).val());
                      if(json.file_id){
                              $('#id_file_id').val(json.file_id);
                      }
              Severity: Minor
              Found in public/javascripts/librecat.js - About 1 hr to fix

              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

                      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);
              Severity: Minor
              Found in public/javascripts/librecat_dropzones.js - About 1 hr to fix

                Function remove_field has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function remove_field(object){
                        var container = $(object).closest('div.multirow');
                        var index = $(container).index();
                        var total = $(container).parent().children('div.multirow').size();
                
                
                Severity: Minor
                Found in public/javascripts/librecat.js - About 1 hr to fix

                  Function enable_autocomplete has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function enable_autocomplete(field, index) {
                      var type;
                      switch(field) {
                          case "pj":
                              type = "project"
                  Severity: Minor
                  Found in public/javascripts/librecat.js - About 1 hr to fix

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                            if($(this).attr('id') && $(this).attr('id').match(/idm_extern/)){
                                                    $(this).prop('checked', true);
                                            }
                    Severity: Major
                    Found in public/javascripts/librecat.js and 1 other location - About 1 hr to fix
                    public/javascripts/librecat.js on lines 621..623

                    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 59.

                    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

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language