Noosfero/noosfero

View on GitHub
plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php

Summary

Maintainability
F
6 days
Test Coverage

File class.tree.php has 560 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
class _tree_struct {
    // Structure table and fields
    protected $table    = "";
    protected $fields    = array(

    Method _move has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _move($id, $ref_id, $position = 0, $is_copy = false) {
            if((int)$ref_id === 0 || (int)$id === 1) { return false; }
            $sql        = array();                        // Queries executed at the end
            $node        = $this->_get_node($id);        // Node data
            $nchildren    = $this->_get_children($id);    // Node children

      Method _reconstruct has 118 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _reconstruct() {
              $this->db->query("" . 
                  "CREATE TEMPORARY TABLE `temp_tree` (" . 
                      "`".$this->fields["id"]."` INTEGER NOT NULL, " . 
                      "`".$this->fields["parent_id"]."` INTEGER NOT NULL, " . 

        Function _move has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            function _move($id, $ref_id, $position = 0, $is_copy = false) {
                if((int)$ref_id === 0 || (int)$id === 1) { return false; }
                $sql        = array();                        // Queries executed at the end
                $node        = $this->_get_node($id);        // Node data
                $nchildren    = $this->_get_children($id);    // Node children

        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 _analyze has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function _analyze() {
                $report = array();
        
                $this->db->query("" . 
                    "SELECT " . 

          Function move_node has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              function move_node($data) { 
                  $id = parent::_move((int)$data["id"], (int)$data["ref"], (int)$data["position"], (int)$data["copy"]);
                  if(!$id) return "{ \"status\" : 0 }";
                  if((int)$data["copy"] && count($this->add_fields)) {
                      $ids    = array_keys($this->_get_children($id, true));

          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 _create_default has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _create_default() {
                  $this->_drop();
                  $this->create_node(array(
                      "id" => 1,
                      "position" => 0,

            Function _reconstruct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                function _reconstruct() {
                    $this->db->query("" . 
                        "CREATE TEMPORARY TABLE `temp_tree` (" . 
                            "`".$this->fields["id"]."` INTEGER NOT NULL, " . 
                            "`".$this->fields["parent_id"]."` INTEGER NOT NULL, " . 

            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 _remove has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _remove($id) {
                    if((int)$id === 1) { return false; }
                    $data = $this->_get_node($id);
                    $lft = (int)$data[$this->fields["left"]];
                    $rgt = (int)$data[$this->fields["right"]];

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

                  function __construct($table = "tree", $fields = array()) {
                      $this->table = $table;
                      if(!count($fields)) {
                          foreach($this->fields as $k => &$v) { $v = $k; }
                      }

              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 _fix_copy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  function _fix_copy($id, $position) {
                      $node = $this->_get_node($id);
                      $children = $this->_get_children($id, true);
              
                      $map = array();

              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

                      $this->db->query("" . 
                              "INSERT INTO `".$this->table."` (" . 
                                  "`".$this->fields["id"]."`, " . 
                                  "`".$this->fields["parent_id"]."`, " . 
                                  "`".$this->fields["position"]."`, " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 356..366

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

              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

                      $this->db->query("" . 
                          "INSERT INTO ".$this->table." (" . 
                                  "`".$this->fields["id"]."`, " . 
                                  "`".$this->fields["parent_id"]."`, " . 
                                  "`".$this->fields["position"]."`, " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 457..468

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

              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

                      $sql[] = "" . 
                          "UPDATE `".$this->table."` " . 
                              "SET `".$this->fields["left"]."` = `".$this->fields["left"]."` + ".$ndif." " . 
                          "WHERE " . 
                              "`".$this->fields["left"]."` >= ".$ref_ind." " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 171..176

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

              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

                      $sql[] = "" . 
                          "UPDATE `".$this->table."` " . 
                              "SET `".$this->fields["right"]."` = `".$this->fields["right"]."` + ".$ndif." " . 
                          "WHERE " . 
                              "`".$this->fields["right"]."` >= ".$ref_ind." " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 165..170

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

              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

                              $sql[] = "" . 
                                  "INSERT INTO `".$this->table."` (" . 
                                      "`".$this->fields["parent_id"]."`, " . 
                                      "`".$this->fields["position"]."`, " . 
                                      "`".$this->fields["left"]."`, " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 220..229

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

              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

                          $sql[] = "" . 
                              "INSERT INTO `".$this->table."` (" . 
                                  "`".$this->fields["parent_id"]."`, " . 
                                  "`".$this->fields["position"]."`, " . 
                                  "`".$this->fields["left"]."`, " . 
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 184..193

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

              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

                              foreach($this->add_fields as $k => $v) {
                                  if(isset($dv[$k]))    $s .= ", `".$this->fields[$v]."` = \"".$this->db->escape($dv[$k])."\" ";
                                  else                $s .= ", `".$this->fields[$v]."` = `".$this->fields[$v]."` ";
                              }
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 496..499

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

              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

                      foreach($this->add_fields as $k => $v) {
                          if(isset($data[$k]))    $s .= ", `".$this->fields[$v]."` = \"".$this->db->escape($data[$k])."\" ";
                          else                    $s .= ", `".$this->fields[$v]."` = `".$this->fields[$v]."` ";
                      }
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 516..519

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

              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

                      $this->db->query("SELECT `".implode("` , `", $this->fields)."` FROM `".$this->table."` WHERE `".$this->fields["left"]."` <= ".(int) $node[$this->fields["left"]]." AND `".$this->fields["right"]."` >= ".(int) $node[$this->fields["right"]]);
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 47..47

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

              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

                          $this->db->query("SELECT `".implode("` , `", $this->fields)."` FROM `".$this->table."` WHERE `".$this->fields["left"]."` >= ".(int) $node[$this->fields["left"]]." AND `".$this->fields["right"]."` <= ".(int) $node[$this->fields["right"]]." ORDER BY `".$this->fields["left"]."` ASC");
              plugins/display_content/public/javascripts/jstree-v.pre1.0/_demo/_inc/class.tree.php on lines 59..59

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

              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