modxcms/revolution

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

Summary

Maintainability
D
2 days
Test Coverage

Function importFiles has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

    public function importFiles($allowedfiles, $parent, $filepath, $files, $context= 'web', $class= 'modStaticResource', $basefilepath= '', $elements = array()) {
        if (!is_array($files))
            return;
        if ($parent > 0) {
            if ($parentResource= $this->modx->getObject('modResource', $parent)) {
Severity: Minor
Found in core/model/modx/import/modstaticimport.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

Method importFiles has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function importFiles($allowedfiles, $parent, $filepath, $files, $context= 'web', $class= 'modStaticResource', $basefilepath= '', $elements = array()) {
        if (!is_array($files))
            return;
        if ($parent > 0) {
            if ($parentResource= $this->modx->getObject('modResource', $parent)) {
Severity: Major
Found in core/model/modx/import/modstaticimport.class.php - About 4 hrs to fix

    Method getResourceAlias has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getResourceAlias(& $resource, $alias, $parent, $context= 'web') {
            // auto assign alias
            if ($alias == '' && $this->modx->getOption('automatic_alias')) {
                $alias= strtolower(trim($resource->cleanAlias($resource->get('pagetitle'))));
            } else {
    Severity: Minor
    Found in core/model/modx/import/modstaticimport.class.php - About 1 hr to fix

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

          public function getResourceAlias(& $resource, $alias, $parent, $context= 'web') {
              // auto assign alias
              if ($alias == '' && $this->modx->getOption('automatic_alias')) {
                  $alias= strtolower(trim($resource->cleanAlias($resource->get('pagetitle'))));
              } else {
      Severity: Minor
      Found in core/model/modx/import/modstaticimport.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 parseElements has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parseElements(modResource &$resource, $file, $elements = array()) {
              if (empty($elements)) {
                  return false;
              }
      
      
      Severity: Minor
      Found in core/model/modx/import/modstaticimport.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 importFiles has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function importFiles($allowedfiles, $parent, $filepath, $files, $context= 'web', $class= 'modStaticResource', $basefilepath= '', $elements = array()) {
      Severity: Major
      Found in core/model/modx/import/modstaticimport.class.php - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status