fisharebest/webtrees

View on GitHub
resources/js/treeview.js

Summary

Maintainability
D
2 days
Test Coverage

Function TreeViewHandler has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function TreeViewHandler (treeview_instance, ged) {
  var tv = this; // Store "this" for usage within jQuery functions where "this" is not this ;-)

  this.treeview = $('#' + treeview_instance + '_in');
  this.loadingImage = $('#' + treeview_instance + '_loading');
Severity: Major
Found in resources/js/treeview.js - About 3 hrs to fix

    Function updateTree has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    TreeViewHandler.prototype.updateTree = function (center, button) {
      var tv = this; // Store "this" for usage within jQuery functions where "this" is not this ;-)
      var to_load = [];
      var elts = [];
      this.getSize();
    Severity: Minor
    Found in resources/js/treeview.js - About 3 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

    File treeview.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * webtrees: online genealogy
     * Copyright (C) 2023 webtrees development team
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
    Severity: Minor
    Found in resources/js/treeview.js - About 2 hrs to fix

      Function updateTree has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      TreeViewHandler.prototype.updateTree = function (center, button) {
        var tv = this; // Store "this" for usage within jQuery functions where "this" is not this ;-)
        var to_load = [];
        var elts = [];
        this.getSize();
      Severity: Major
      Found in resources/js/treeview.js - About 2 hrs to fix

        Function expandBox has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        TreeViewHandler.prototype.expandBox = function (box, event) {
          var t = $(event.target);
          if (t.hasClass('tv_link')) {
            return false;
          }
        Severity: Minor
        Found in resources/js/treeview.js - About 1 hr to fix

          Function compact has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          TreeViewHandler.prototype.compact = function () {
            var tv = this;
            var b = $('#tvbCompact', tv.toolbox);
            tv.setLoading();
            if (tv.auto_box_width) {
          Severity: Minor
          Found in resources/js/treeview.js - About 1 hr to fix

            Function compact has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            TreeViewHandler.prototype.compact = function () {
              var tv = this;
              var b = $('#tvbCompact', tv.toolbox);
              tv.setLoading();
              if (tv.auto_box_width) {
            Severity: Minor
            Found in resources/js/treeview.js - About 45 mins 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

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

                    if (pos.left >= tv.leftMin && pos.left <= tv.leftMax && pos.top >= tv.topMin && pos.top <= tv.topMax) {
                      tv.expandBox(box, e);
                    }
            Severity: Major
            Found in resources/js/treeview.js and 1 other location - About 1 hr to fix
            resources/js/treeview.js on lines 175..178

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

            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 (pos.left >= tv.leftMin && pos.left <= tv.leftMax && pos.top >= tv.topMin && pos.top <= tv.topMax) {
                  to_load.push(el.attr('abbr'));
                  elts.push(el);
                }
            Severity: Major
            Found in resources/js/treeview.js and 1 other location - About 1 hr to fix
            resources/js/treeview.js on lines 102..104

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

            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

            TreeViewHandler.prototype.setLoading = function () {
              this.treeview.css('cursor', 'wait');
              this.loadingImage.css('display', 'block');
            };
            Severity: Major
            Found in resources/js/treeview.js and 1 other location - About 1 hr to fix
            resources/js/treeview.js on lines 135..138

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

            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

            TreeViewHandler.prototype.setComplete = function () {
              this.treeview.css('cursor', 'move');
              this.loadingImage.css('display', 'none');
            };
            Severity: Major
            Found in resources/js/treeview.js and 1 other location - About 1 hr to fix
            resources/js/treeview.js on lines 128..131

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

            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

            There are no issues that match your filters.

            Category
            Status