modxcms/revolution

View on GitHub
core/model/modx/modx.class.php

Summary

Maintainability
F
3 wks
Test Coverage

File modx.class.php has 1725 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: Major
Found in core/model/modx/modx.class.php - About 4 days to fix

    modX has 88 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class modX extends xPDO {
        /**
         * The parameter for when a session state is not able to be accessed
         * @const SESSION_STATE_UNAVAILABLE
         */
    Severity: Major
    Found in core/model/modx/modx.class.php - About 1 day to fix

      Function _initSession has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function _initSession($options = null) {
              $contextKey= $this->context instanceof modContext ? $this->context->get('key') : null;
              if ($this->getOption('session_enabled', $options, true) || isset($_GET['preview'])) {
                  if (!in_array($this->getSessionState(), array(modX::SESSION_STATE_INITIALIZED, modX::SESSION_STATE_EXTERNAL, modX::SESSION_STATE_UNAVAILABLE), true)) {
                      $sh = false;
      Severity: Minor
      Found in core/model/modx/modx.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

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

          public function getUser($contextKey= '',$forceLoadSettings = false) {
              if ($contextKey == '') {
                  if ($this->context !== null) {
                      $contextKey= $this->context->get('key');
                  }
      Severity: Minor
      Found in core/model/modx/modx.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

      Function _initContext has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function _initContext($contextKey, $regenerate = false, $options = null) {
              $initialized= false;
              $oldContext = is_object($this->context) ? $this->context->get('key') : '';
              if (isset($this->contexts[$contextKey]) && $this->contexts[$contextKey] instanceof modContext) {
                  $this->context= & $this->contexts[$contextKey];
      Severity: Minor
      Found in core/model/modx/modx.class.php - About 6 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 getConfig has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getConfig() {
              if (!$this->_initialized || !is_array($this->config) || empty ($this->config)) {
                  if (!isset ($this->config['base_url']))
                      $this->config['base_url']= MODX_BASE_URL;
                  if (!isset ($this->config['base_path']))
      Severity: Minor
      Found in core/model/modx/modx.class.php - About 6 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 sanitize has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function sanitize(array &$target, array $patterns= array(), $depth= 99, $nesting= 10) {
              foreach ($target as $key => &$value) {
                  if (is_array($value) && $depth > 0) {
                      modX :: sanitize($value, $patterns, $depth-1);
                  } elseif (is_string($value)) {
      Severity: Minor
      Found in core/model/modx/modx.class.php - About 6 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 sendForward has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          public function sendForward($id, $options = null, $sendErrorPage = true) {
              if (!$this->getRequest()) {
                  $this->log(modX::LOG_LEVEL_FATAL, "Could not load request class.");
              }
              $idInt = intval($id);
      Severity: Minor
      Found in core/model/modx/modx.class.php - About 5 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 runProcessor has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public function runProcessor($action = '',$scriptProperties = array(),$options = array()) {
              if (!$this->loadClass('modProcessor','',false,true)) {
                  $this->log(modX::LOG_LEVEL_ERROR,'Could not load modProcessor class.');
                  return false;
              }
      Severity: Minor
      Found in core/model/modx/modx.class.php - About 5 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 invokeEvent has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          public function invokeEvent($eventName, array $params= array ()) {
              if (!$eventName)
                  return false;
              if ($this->eventMap === null && $this->context instanceof modContext)
                  $this->_initEventMap($this->context->get('key'));
      Severity: Minor
      Found in core/model/modx/modx.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 _log has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
              if (empty($target)) {
                  $target = $this->logTarget;
              }
              $targetOptions = array();
      Severity: Minor
      Found in core/model/modx/modx.class.php - 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

      Function makeUrl has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function makeUrl($id, $context= '', $args= '', $scheme= -1, array $options= array()) {
              $url= '';
              if ($validid = intval($id)) {
                  $id = $validid;
                  if ($context == '' || $this->context->get('key') == $context) {
      Severity: Minor
      Found in core/model/modx/modx.class.php - 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

      Method _initSession has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function _initSession($options = null) {
              $contextKey= $this->context instanceof modContext ? $this->context->get('key') : null;
              if ($this->getOption('session_enabled', $options, true) || isset($_GET['preview'])) {
                  if (!in_array($this->getSessionState(), array(modX::SESSION_STATE_INITIALIZED, modX::SESSION_STATE_EXTERNAL, modX::SESSION_STATE_UNAVAILABLE), true)) {
                      $sh = false;
      Severity: Major
      Found in core/model/modx/modx.class.php - About 3 hrs to fix

        Function findResource has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function findResource($uri, $context = '') {
                $resourceId = false;
                if (empty($context) && isset($this->context)) $context = $this->context->get('key');
                if (!empty($context) && (!empty($uri) || $uri === '0')) {
                    $useAliasMap = (boolean) $this->getOption('cache_alias_map', null, false);
        Severity: Minor
        Found in core/model/modx/modx.class.php - 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

        Function _loadExtensionPackagesDeprecated has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _loadExtensionPackagesDeprecated($options = null) {
                $extPackages = $this->getOption('extension_packages');
                $extPackages = $this->fromJSON($extPackages);
                if (!is_array($extPackages)) $extPackages = array();
                if (is_array($options) && array_key_exists('extension_packages', $options)) {
        Severity: Minor
        Found in core/model/modx/modx.class.php - 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

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

            protected function loadConfig($configPath = '', $data = array(), $driverOptions = array()) {
                if (!is_array($data)) $data = array();
                modX :: protect();
                if (!defined('MODX_CONFIG_KEY')) {
                    define('MODX_CONFIG_KEY', 'config');
        Severity: Minor
        Found in core/model/modx/modx.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

        Method _initContext has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _initContext($contextKey, $regenerate = false, $options = null) {
                $initialized= false;
                $oldContext = is_object($this->context) ? $this->context->get('key') : '';
                if (isset($this->contexts[$contextKey]) && $this->contexts[$contextKey] instanceof modContext) {
                    $this->context= & $this->contexts[$contextKey];
        Severity: Major
        Found in core/model/modx/modx.class.php - About 2 hrs to fix

          Method sendForward has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function sendForward($id, $options = null, $sendErrorPage = true) {
                  if (!$this->getRequest()) {
                      $this->log(modX::LOG_LEVEL_FATAL, "Could not load request class.");
                  }
                  $idInt = intval($id);
          Severity: Major
          Found in core/model/modx/modx.class.php - About 2 hrs to fix

            Function toPlaceholders has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                public function toPlaceholders($subject, $prefix= '', $separator= '.', $restore= false) {
                    $keys = array();
                    $restored = array();
                    if (is_object($subject)) {
                        if ($subject instanceof xPDOObject) {
            Severity: Minor
            Found in core/model/modx/modx.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 getChildIds has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getChildIds($id= null, $depth= 10,array $options = array()) {
                    $children= array ();
                    if ($id !== null && intval($depth) >= 1) {
                        $id= is_int($id) ? $id : intval($id);
            
            
            Severity: Minor
            Found in core/model/modx/modx.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 getTree has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getTree($id= null, $depth= 10, array $options = array()) {
                    $tree= array ();
                    if (!empty($options['context'])) {
                        $this->getContext($options['context']);
                    }
            Severity: Minor
            Found in core/model/modx/modx.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 reloadContext has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function reloadContext($key = null) {
                    $reloaded = false;
                    if ($this->context instanceof modContext) {
                        if (empty($key)) {
                            $key = $this->context->get('key');
            Severity: Minor
            Found in core/model/modx/modx.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

            Method runProcessor has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function runProcessor($action = '',$scriptProperties = array(),$options = array()) {
                    if (!$this->loadClass('modProcessor','',false,true)) {
                        $this->log(modX::LOG_LEVEL_ERROR,'Could not load modProcessor class.');
                        return false;
                    }
            Severity: Major
            Found in core/model/modx/modx.class.php - About 2 hrs to fix

              Function _initErrorHandler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function _initErrorHandler($options = null) {
                      if ($this->errorHandler == null || !is_object($this->errorHandler)) {
                          if ($ehClass = $this->getOption('error_handler_class', $options, 'modErrorHandler', true)) {
                              $ehPath = $this->getOption('error_handler_path', $options, '', true);
                              if ($ehClass = $this->loadClass($ehClass, $ehPath, false, true)) {
              Severity: Minor
              Found in core/model/modx/modx.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

              Method getUser has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getUser($contextKey= '',$forceLoadSettings = false) {
                      if ($contextKey == '') {
                          if ($this->context !== null) {
                              $contextKey= $this->context->get('key');
                          }
              Severity: Major
              Found in core/model/modx/modx.class.php - About 2 hrs to fix

                Method invokeEvent has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function invokeEvent($eventName, array $params= array ()) {
                        if (!$eventName)
                            return false;
                        if ($this->eventMap === null && $this->context instanceof modContext)
                            $this->_initEventMap($this->context->get('key'));
                Severity: Major
                Found in core/model/modx/modx.class.php - About 2 hrs to fix

                  Method loadConfig has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function loadConfig($configPath = '', $data = array(), $driverOptions = array()) {
                          if (!is_array($data)) $data = array();
                          modX :: protect();
                          if (!defined('MODX_CONFIG_KEY')) {
                              define('MODX_CONFIG_KEY', 'config');
                  Severity: Major
                  Found in core/model/modx/modx.class.php - About 2 hrs to fix

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

                        public function unsetPlaceholders($keys) {
                            if (is_array($keys)) {
                                foreach ($keys as $key) {
                                    if (is_string($key)) $this->unsetPlaceholder($key);
                                    if (is_array($key)) $this->unsetPlaceholders($key);
                    Severity: Minor
                    Found in core/model/modx/modx.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 getConfig has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getConfig() {
                            if (!$this->_initialized || !is_array($this->config) || empty ($this->config)) {
                                if (!isset ($this->config['base_url']))
                                    $this->config['base_url']= MODX_BASE_URL;
                                if (!isset ($this->config['base_path']))
                    Severity: Minor
                    Found in core/model/modx/modx.class.php - About 1 hr to fix

                      Function addExtensionPackage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function addExtensionPackage($name,$path,array $options = array()) {
                              $extPackages = $this->getOption('extension_packages');
                              $extPackages = !empty($extPackages) ? $extPackages : array();
                              $extPackages = is_array($extPackages) ? $extPackages : $this->fromJSON($extPackages);
                              $extPackages[$name] = $options;
                      Severity: Minor
                      Found in core/model/modx/modx.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 addExtensionPackage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function addExtensionPackage($name,$path,array $options = array()) {
                              $extPackages = $this->getOption('extension_packages');
                              $extPackages = !empty($extPackages) ? $extPackages : array();
                              $extPackages = is_array($extPackages) ? $extPackages : $this->fromJSON($extPackages);
                              $extPackages[$name] = $options;
                      Severity: Minor
                      Found in core/model/modx/modx.class.php - About 1 hr to fix

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

                            public function getParentIds($id= null, $height= 10,array $options = array()) {
                                $parentId= 0;
                                $parents= array ();
                                if ($id && $height > 0) {
                        
                        
                        Severity: Minor
                        Found in core/model/modx/modx.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 _loadExtensionPackagesDeprecated has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function _loadExtensionPackagesDeprecated($options = null) {
                                $extPackages = $this->getOption('extension_packages');
                                $extPackages = $this->fromJSON($extPackages);
                                if (!is_array($extPackages)) $extPackages = array();
                                if (is_array($options) && array_key_exists('extension_packages', $options)) {
                        Severity: Minor
                        Found in core/model/modx/modx.class.php - About 1 hr to fix

                          Method sanitize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function sanitize(array &$target, array $patterns= array(), $depth= 99, $nesting= 10) {
                                  foreach ($target as $key => &$value) {
                                      if (is_array($value) && $depth > 0) {
                                          modX :: sanitize($value, $patterns, $depth-1);
                                      } elseif (is_string($value)) {
                          Severity: Minor
                          Found in core/model/modx/modx.class.php - About 1 hr to fix

                            Method getEventMap has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function getEventMap($contextKey) {
                                    $eventElementMap= array ();
                                    if ($contextKey) {
                                        switch ($contextKey) {
                                            case 'mgr':
                            Severity: Minor
                            Found in core/model/modx/modx.class.php - About 1 hr to fix

                              Method _log has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
                                      if (empty($target)) {
                                          $target = $this->logTarget;
                                      }
                                      $targetOptions = array();
                              Severity: Minor
                              Found in core/model/modx/modx.class.php - About 1 hr to fix

                                Method __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function __construct($configPath= '', $options = null, $driverOptions = null) {
                                        try {
                                            $options = $this->loadConfig($configPath, $options, $driverOptions);
                                            parent :: __construct(
                                                null,
                                Severity: Minor
                                Found in core/model/modx/modx.class.php - About 1 hr to fix

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

                                      public function initialize($contextKey= 'web', $options = null) {
                                          if (!$this->_initialized) {
                                              if (!$this->startTime) {
                                                  $this->startTime= microtime(true);
                                              }
                                  Severity: Minor
                                  Found in core/model/modx/modx.class.php - About 1 hr to fix

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

                                        public function makeUrl($id, $context= '', $args= '', $scheme= -1, array $options= array()) {
                                            $url= '';
                                            if ($validid = intval($id)) {
                                                $id = $validid;
                                                if ($context == '' || $this->context->get('key') == $context) {
                                    Severity: Minor
                                    Found in core/model/modx/modx.class.php - About 1 hr to fix

                                      Function getCacheManager has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function getCacheManager($class= 'cache.xPDOCacheManager', $options = array('path' => XPDO_CORE_PATH, 'ignorePkg' => true)) {
                                              if ($this->cacheManager === null) {
                                                  if ($this->loadClass($class, $options['path'], $options['ignorePkg'], true)) {
                                                      $cacheManagerClass= $this->getOption('modCacheManager.class', null, 'modCacheManager');
                                                      if ($className= $this->loadClass($cacheManagerClass, '', false, true)) {
                                      Severity: Minor
                                      Found in core/model/modx/modx.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 findResource has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function findResource($uri, $context = '') {
                                              $resourceId = false;
                                              if (empty($context) && isset($this->context)) $context = $this->context->get('key');
                                              if (!empty($context) && (!empty($uri) || $uri === '0')) {
                                                  $useAliasMap = (boolean) $this->getOption('cache_alias_map', null, false);
                                      Severity: Minor
                                      Found in core/model/modx/modx.class.php - About 1 hr to fix

                                        Method messageQuit has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            public function messageQuit($msg='unspecified error', $query='', $is_error=true, $nr='', $file='', $source='', $text='', $line='') {
                                        Severity: Major
                                        Found in core/model/modx/modx.class.php - About 1 hr to fix

                                          Function getInstance has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public static function getInstance($id = null, $config = null, $forceNew = false) {
                                                  $class = __CLASS__;
                                                  if (is_null($id)) {
                                                      if (!is_null($config) || $forceNew || empty(self::$instances)) {
                                                          $id = uniqid($class);
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 55 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 toPlaceholder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function toPlaceholder($key, $value, $prefix= '', $separator= '.', $restore= false) {
                                                  $return = array('keys' => array());
                                                  if ($restore === true) $return['restore'] = array();
                                                  if (!empty($prefix) && !empty($separator)) {
                                                      $prefix .= $separator;
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 55 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 stripTags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function stripTags($html, $allowed= '', $patterns= array(), $depth= 10) {
                                                  $stripped= strip_tags($html, $allowed);
                                                  if (is_array($patterns)) {
                                                      if (empty($patterns)) {
                                                          $patterns = $this->sanitizePatterns;
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 55 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 setDebug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function setDebug($debug= true) {
                                                  $oldValue= $this->getDebug();
                                                  if (($debug === true) || ('true' === $debug) || ('-1' === $debug)) {
                                                      error_reporting(-1);
                                                      parent :: setDebug(true);
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 55 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 getEventMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function getEventMap($contextKey) {
                                                  $eventElementMap= array ();
                                                  if ($contextKey) {
                                                      switch ($contextKey) {
                                                          case 'mgr':
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 55 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

                                          Method _log has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
                                          Severity: Minor
                                          Found in core/model/modx/modx.class.php - About 45 mins to fix

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

                                                public function removeExtensionPackage($name) {
                                                    /** @var modSystemSetting $setting */
                                                    $setting = $this->getObject('modSystemSetting',array(
                                                        'key' => 'extension_packages',
                                                    ));
                                            Severity: Minor
                                            Found in core/model/modx/modx.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

                                            Method _logInRegister has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                protected function _logInRegister($register, $level, $msg, $def, $file, $line) {
                                            Severity: Minor
                                            Found in core/model/modx/modx.class.php - About 45 mins to fix

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

                                                  public function sendError($type = '', $options = array()) {
                                                      if (!is_string($type) || empty($type)) $type = $this->getOption('error_type', $options, 'unavailable');
                                                      while (ob_get_level() && @ob_end_clean()) {}
                                                      if (!XPDO_CLI_MODE) {
                                                          $errorPageTitle = $this->getOption('error_pagetitle', $options, 'Error 503: Service temporarily unavailable');
                                              Severity: Minor
                                              Found in core/model/modx/modx.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

                                              Avoid deeply nested control flow statements.
                                              Open

                                                                      if ($result === false) {
                                                                          $this->log(modX::LOG_LEVEL_ERROR, 'Could not set error handler.  Make sure your class has a function called handleError(). Result: ' . print_r($result, true));
                                                                      }
                                              Severity: Major
                                              Found in core/model/modx/modx.class.php - About 45 mins to fix

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

                                                    public function initialize($contextKey= 'web', $options = null) {
                                                        if (!$this->_initialized) {
                                                            if (!$this->startTime) {
                                                                $this->startTime= microtime(true);
                                                            }
                                                Severity: Minor
                                                Found in core/model/modx/modx.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

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                                while ($patternMatches > 0 && $patternIterator <= $nesting) {
                                                                                    $value= preg_replace($pattern, '', $value);
                                                                                    $patternMatches = preg_match($pattern, $value);
                                                                                }
                                                Severity: Major
                                                Found in core/model/modx/modx.class.php - About 45 mins to fix

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

                                                      public function regClientStartupScript($src, $plaintext= false) {
                                                          if (!empty ($src) && !array_key_exists($src, $this->loadedjscripts)) {
                                                              if (isset ($this->loadedjscripts[$src]))
                                                                  return;
                                                              $this->loadedjscripts[$src]= true;
                                                  Severity: Minor
                                                  Found in core/model/modx/modx.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

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                              if (is_scalar($fval) && $fval !== '') {
                                                                                  $currentResource[$fkey] = $fval;
                                                                              } elseif (is_array($fval) && count($fval) === 5 && $fval[1] !== '') {
                                                                                  $currentResource[$fkey] = $fval;
                                                                              }
                                                  Severity: Major
                                                  Found in core/model/modx/modx.class.php - About 45 mins to fix

                                                    Consider simplifying this complex logical expression.
                                                    Open

                                                                    if (isset($this->context) && $this->context->get('key') === $context && is_array($this->aliasMap) && array_key_exists($uri, $this->aliasMap)) {
                                                                        $resourceId = (integer) $this->aliasMap[$uri];
                                                                    } elseif ($ctx = $this->getContext($context)) {
                                                                        $useAliasMap = $ctx->getOption('cache_alias_map', false) && is_array($ctx->aliasMap) && array_key_exists($uri, $ctx->aliasMap);
                                                                        if ($useAliasMap && array_key_exists($uri, $ctx->aliasMap)) {
                                                    Severity: Major
                                                    Found in core/model/modx/modx.class.php - About 40 mins to fix

                                                      Method makeUrl has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                      Open

                                                          public function makeUrl($id, $context= '', $args= '', $scheme= -1, array $options= array()) {
                                                      Severity: Minor
                                                      Found in core/model/modx/modx.class.php - About 35 mins to fix

                                                        Method toPlaceholder has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                            public function toPlaceholder($key, $value, $prefix= '', $separator= '.', $restore= false) {
                                                        Severity: Minor
                                                        Found in core/model/modx/modx.class.php - About 35 mins to fix

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

                                                              public function getAuthenticatedUser($contextKey= '') {
                                                                  $user= null;
                                                                  if ($contextKey == '') {
                                                                      if ($this->context !== null) {
                                                                          $contextKey= $this->context->get('key');
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 regClientCSS has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function regClientCSS($src, $media = null) {
                                                                  if (isset ($this->loadedjscripts[$src]) && $this->loadedjscripts[$src]) {
                                                                      return;
                                                                  }
                                                                  $this->loadedjscripts[$src]= true;
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 getLoginUserName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function getLoginUserName($context= '') {
                                                                  $userName = '';
                                                                  if (empty($context) && $this->context instanceof modContext && $this->user instanceof modUser) {
                                                                      if ($this->user->hasSessionContext($this->context->get('key'))) {
                                                                          $userName = $this->user->get('username');
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 getRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function getRequest($class= 'modRequest', $path= '') {
                                                                  if ($this->request === null || !($this->request instanceof modRequest)) {
                                                                      $requestClass = $this->getOption('modRequest.class',$this->config,$class);
                                                                      if ($requestClass !== $class) {
                                                                          $this->loadClass('modRequest', '', false, true);
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 getLoginUserID has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function getLoginUserID($context= '') {
                                                                  $userId = 0;
                                                                  if (empty($context) && $this->context instanceof modContext && $this->user instanceof modUser) {
                                                                      if ($this->user->hasSessionContext($this->context->get('key'))) {
                                                                          $userId = $this->user->get('id');
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 _loadExtensionPackages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              protected function _loadExtensionPackages($options = null) {
                                                                  $cache = $this->call('modExtensionPackage','loadCache',array(&$this));
                                                                  if (!empty($cache)) {
                                                                      foreach ($cache as $package) {
                                                                          $package['table_prefix'] = isset($package['table_prefix']) ? $package['table_prefix'] : null;
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 parseChunk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function parseChunk($chunkName, $chunkArr, $prefix='[[+', $suffix=']]') {
                                                                  $chunk= $this->getChunk($chunkName);
                                                                  if (!empty($chunk) || $chunk === '0') {
                                                                      if(is_array($chunkArr)) {
                                                                          foreach ($chunkArr as $key => $value) {
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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 switchContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function switchContext($contextKey, $reload = false) {
                                                                  $switched= false;
                                                                  if ($this->context->key != $contextKey) {
                                                                      $switched= $this->_initContext($contextKey, $reload);
                                                                      if ($switched) {
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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

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

                                                              protected function _loadConfig() {
                                                                  $this->config = $this->_config;
                                                          
                                                                  $this->getCacheManager();
                                                                  $config = $this->cacheManager->get('config', array(
                                                          Severity: Minor
                                                          Found in core/model/modx/modx.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

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

                                                                  if (!empty ($src) && !array_key_exists($src, $this->loadedjscripts)) {
                                                                      if (isset ($this->loadedjscripts[$src]))
                                                                          return;
                                                                      $this->loadedjscripts[$src]= true;
                                                                      if ($plaintext == true) {
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 3 hrs to fix
                                                          core/model/modx/modx.class.php on lines 1565..1576

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

                                                          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

                                                              public function regClientScript($src, $plaintext= false) {
                                                                  if (isset ($this->loadedjscripts[$src]))
                                                                      return;
                                                                  $this->loadedjscripts[$src]= true;
                                                                  if ($plaintext == true) {
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 3 hrs to fix
                                                          core/model/modx/modx.class.php on lines 1542..1553

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

                                                          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

                                                                  $options= array_merge(
                                                                      array(
                                                                          'response_code' => $this->getOption('error_page_header', $options, $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found')
                                                                          ,'error_type' => '404'
                                                                          ,'error_header' => $this->getOption('error_page_header', $options, $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found')
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 1 hr to fix
                                                          core/model/modx/modx.class.php on lines 1258..1267

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

                                                          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

                                                                  $options= array_merge(
                                                                      array(
                                                                          'response_code' => $this->getOption('unauthorized_page_header' ,$options ,$_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized')
                                                                          ,'error_type' => '401'
                                                                          ,'error_header' => $this->getOption('unauthorized_page_header', $options,$_SERVER['SERVER_PROTOCOL'] . ' 401 Unauthorized')
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 1 hr to fix
                                                          core/model/modx/modx.class.php on lines 1234..1243

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

                                                          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

                                                                  if (empty($context) && $this->context instanceof modContext && $this->user instanceof modUser) {
                                                                      if ($this->user->hasSessionContext($this->context->get('key'))) {
                                                                          $userName = $this->user->get('username');
                                                                      }
                                                          
                                                          
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 1 hr to fix
                                                          core/model/modx/modx.class.php on lines 1786..1796

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

                                                          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

                                                                  if (empty($context) && $this->context instanceof modContext && $this->user instanceof modUser) {
                                                                      if ($this->user->hasSessionContext($this->context->get('key'))) {
                                                                          $userId = $this->user->get('id');
                                                                      }
                                                          
                                                          
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 1 hr to fix
                                                          core/model/modx/modx.class.php on lines 1809..1819

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

                                                          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

                                                                              $cacheManager->writeFile($filepath . $filename, '[' . strftime('%Y-%m-%d %H:%M:%S') . '] (' . $this->_getLogLevel($level) . $def . $file . $line . ') ' . $msg . "\n" . ($this->getDebug() === true ? '<pre>' . "\n" . print_r(debug_backtrace(), true) . "\n" . '</pre>' : ''), 'a');
                                                          Severity: Major
                                                          Found in core/model/modx/modx.class.php and 1 other location - About 1 hr to fix
                                                          core/xpdo/xpdo.class.php on lines 2058..2058

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

                                                          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