modxcms/revolution

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

Summary

Maintainability
F
5 days
Test Coverage

File modmanagercontroller.class.php has 591 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/modmanagercontroller.class.php - About 1 day to fix

    modManagerController has 47 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class modManagerController {
        /** @var modX A reference to the modX object */
        public $modx;
        /** @var array A configuration array of options related to this controller's action object. */
        public $config = array();
    Severity: Minor
    Found in core/model/modx/modmanagercontroller.class.php - About 6 hrs to fix

      Function checkFormCustomizationRules has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          public function checkFormCustomizationRules(&$obj = null, $forParent = false) {
              $overridden = array();
      
              if ($this->modx->getOption('form_customization_use_all_groups',null,false)) {
                  $userGroups = $this->modx->user->getUserGroups();
      Severity: Minor
      Found in core/model/modx/modmanagercontroller.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

      Method checkFormCustomizationRules has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function checkFormCustomizationRules(&$obj = null, $forParent = false) {
              $overridden = array();
      
              if ($this->modx->getOption('form_customization_use_all_groups',null,false)) {
                  $userGroups = $this->modx->user->getUserGroups();
      Severity: Major
      Found in core/model/modx/modmanagercontroller.class.php - About 3 hrs to fix

        Method registerBaseScripts has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function registerBaseScripts() {
                $managerUrl = $this->modx->getOption('manager_url');
                $externals = array();
        
                if ($this->loadBaseJavascript) {
        Severity: Major
        Found in core/model/modx/modmanagercontroller.class.php - About 2 hrs to fix

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

              public function render() {
                  if (!$this->checkPermissions()) {
                      $this->failure($this->modx->lexicon('access_denied'));
                  }
          
          
          Severity: Major
          Found in core/model/modx/modmanagercontroller.class.php - About 2 hrs to fix

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

                public function registerCssJs() {
                    $this->_prepareHead();
                    $versionPostFix = $this->_prepareVersionPostfix();
            
                    $jsToCompress = array();
            Severity: Minor
            Found in core/model/modx/modmanagercontroller.class.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                public function registerBaseScripts() {
                    $managerUrl = $this->modx->getOption('manager_url');
                    $externals = array();
            
                    if ($this->loadBaseJavascript) {
            Severity: Minor
            Found in core/model/modx/modmanagercontroller.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 registerCssJs has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function registerCssJs() {
                    $this->_prepareHead();
                    $versionPostFix = $this->_prepareVersionPostfix();
            
                    $jsToCompress = array();
            Severity: Minor
            Found in core/model/modx/modmanagercontroller.class.php - About 1 hr to fix

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

                  public function render() {
                      if (!$this->checkPermissions()) {
                          $this->failure($this->modx->lexicon('access_denied'));
                      }
              
              
              Severity: Minor
              Found in core/model/modx/modmanagercontroller.class.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  public function fetchTemplate($tpl) {
                      $templatePath = '';
                      if (is_array($this->templatesPaths)) {
                          foreach ($this->templatesPaths as $path) {
                              if (file_exists($path.$tpl)) {
              Severity: Minor
              Found in core/model/modx/modmanagercontroller.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 setCssURLPlaceholders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function setCssURLPlaceholders()
                  {
                      $managerUrl = $this->modx->getOption('manager_url', null, MODX_MANAGER_URL);
                      $managerPath = $this->modx->getOption('manager_path',null,MODX_MANAGER_PATH);
              
              
              Severity: Minor
              Found in core/model/modx/modmanagercontroller.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

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

                  private function _postfixVersionToScript($str,$version) {
                      $pos = strpos($str,'.js');
                      $pos2 = strpos($str,'src="'); /* only apply to externals */
                      if ($pos && $pos2) {
                          $s = substr($str,0,strpos($str,'"></script>'));
              Severity: Major
              Found in core/model/modx/modmanagercontroller.class.php and 1 other location - About 3 hrs to fix
              core/model/modx/modmanagercontrollerdeprecated.class.php on lines 186..196

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

              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