modxcms/revolution

View on GitHub
core/model/modx/processors/resource/getnodes.class.php

Summary

Maintainability
F
3 days
Test Coverage

Function prepareResourceNode has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public function prepareResourceNode(modResource $resource) {
        $qtipField = $this->getProperty('qtipField');
        $nodeField = $this->getProperty('nodeField');
        $nodeFieldFallback = $this->getProperty('nodeFieldFallback');
        $noHref = $this->getProperty('noHref',false);
Severity: Minor
Found in core/model/modx/processors/resource/getnodes.class.php - About 1 day 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 getnodes.class.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * This file is part of MODX Revolution.
 *
 * Copyright (c) MODX, LLC. All Rights Reserved.
Severity: Minor
Found in core/model/modx/processors/resource/getnodes.class.php - About 5 hrs to fix

    Method prepareResourceNode has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function prepareResourceNode(modResource $resource) {
            $qtipField = $this->getProperty('qtipField');
            $nodeField = $this->getProperty('nodeField');
            $nodeFieldFallback = $this->getProperty('nodeFieldFallback');
            $noHref = $this->getProperty('noHref',false);
    Severity: Major
    Found in core/model/modx/processors/resource/getnodes.class.php - About 4 hrs to fix

      Method search has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function search($query) {
              /* first check to see if search results */
              $searchNode = array(
                  'text' => $this->modx->lexicon('search_results'),
                  'id' => 'search_results',
      Severity: Major
      Found in core/model/modx/processors/resource/getnodes.class.php - About 2 hrs to fix

        Method prepareContextNode has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function prepareContextNode(modContext $context) {
                $class = array('tree-pseudoroot-node');
        
                $createRoot =  $this->modx->hasPermission('new_document_in_root');
        
        
        Severity: Minor
        Found in core/model/modx/processors/resource/getnodes.class.php - About 1 hr to fix

          Method getResourceQuery has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getResourceQuery() {
                  $resourceColumns = array(
                      'id'
                      ,'template'
                      ,'pagetitle'
          Severity: Minor
          Found in core/model/modx/processors/resource/getnodes.class.php - About 1 hr to fix

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

                public function iterate(array $collection = array()) {
                    /* now process actual tree nodes */
                    $item = reset($collection);
                    /** @var modContext|modResource $item */
                    while ($item) {
            Severity: Minor
            Found in core/model/modx/processors/resource/getnodes.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

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

                public function process() {
                    $this->getRootNode();
                    $this->prepare();
            
                    if (empty($this->contextKey) || $this->contextKey == 'root') {
            Severity: Minor
            Found in core/model/modx/processors/resource/getnodes.class.php - 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

            There are no issues that match your filters.

            Category
            Status