modxcms/revolution

View on GitHub
core/model/modx/processors/element/sort.class.php

Summary

Maintainability
D
1 day
Test Coverage

Function handleCategoryDrop has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleCategoryDrop(array $data) {
        /* if dropping an element onto a category, do that here */
        foreach ($data as $key => $elements) {
            if (!is_array($elements) || empty($elements)) continue;

Severity: Minor
Found in core/model/modx/processors/element/sort.class.php - About 4 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

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

    public function sortNodesHelper($objs,$xname,$currentCategoryId = 0) {
        foreach ($objs as $objar => $kids) {
            $oar = explode('_',$objar);
            $nodeArray = $this->processID($oar);

Severity: Minor
Found in core/model/modx/processors/element/sort.class.php - 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

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

    public function handleSubCategoryDrop(array $data) {
        $cdata = array();
        foreach ($data as $typeKey => $type) {
            if (!empty($type)) {
                $this->getCategoryNodeDrop($cdata,$type);
Severity: Minor
Found in core/model/modx/processors/element/sort.class.php - 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

Method sortNodesHelper has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sortNodesHelper($objs,$xname,$currentCategoryId = 0) {
        foreach ($objs as $objar => $kids) {
            $oar = explode('_',$objar);
            $nodeArray = $this->processID($oar);

Severity: Minor
Found in core/model/modx/processors/element/sort.class.php - About 1 hr to fix

    Method handleCategoryDrop has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handleCategoryDrop(array $data) {
            /* if dropping an element onto a category, do that here */
            foreach ($data as $key => $elements) {
                if (!is_array($elements) || empty($elements)) continue;
    
    
    Severity: Minor
    Found in core/model/modx/processors/element/sort.class.php - About 1 hr to fix

      Function process has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process() {
              $data = $this->getData();
              if (empty($data)) return $this->failure();
      
              $error = false;
      Severity: Minor
      Found in core/model/modx/processors/element/sort.class.php - About 35 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

      Function includeCategoryChildren has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function includeCategoryChildren(&$list, $nestedId, $nestedName){
              $children = $this->modx->getIterator('modCategory', array('parent' => $nestedId));
              if ($children) {
                  /** @var modCategory $child */
                  foreach ($children as $child) {
      Severity: Minor
      Found in core/model/modx/processors/element/sort.class.php - About 35 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

      Function setNewStaticElementFilename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setNewStaticElementFilename($type, $element, $currentCategoryId) {
              $categoryArray = $this->getCategoryUltimateParent($currentCategoryId);
              $list          = array();
              $list[]        = $categoryArray;
      
      
      Severity: Minor
      Found in core/model/modx/processors/element/sort.class.php - About 25 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

      There are no issues that match your filters.

      Category
      Status