modxcms/revolution

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

Summary

Maintainability
F
1 wk
Test Coverage

File modparser.class.php has 920 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/modparser.class.php - About 2 days to fix

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

        public function process($properties= null, $content= null) {
            parent :: process($properties, $content);
            if (!$this->_processed) {
                $this->_output= $this->_content;
                if (is_string($this->_output) && !empty ($this->_output)) {
    Severity: Minor
    Found in core/model/modx/modparser.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 parsePropertyString has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

        public function parsePropertyString($string, $valuesOnly = false) {
            $properties = array();
            $tagProps= xPDO :: escSplit("&", $string);
            foreach ($tagProps as $prop) {
                $property= xPDO :: escSplit('=', $prop);
    Severity: Minor
    Found in core/model/modx/modparser.class.php - About 7 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 processTag has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        public function processTag($tag, $processUncacheable = true) {
            $this->_processingTag = true;
            $element= null;
            $elementOutput= null;
    
    
    Severity: Minor
    Found in core/model/modx/modparser.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 processTag has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function processTag($tag, $processUncacheable = true) {
            $this->_processingTag = true;
            $element= null;
            $elementOutput= null;
    
    
    Severity: Major
    Found in core/model/modx/modparser.class.php - About 5 hrs to fix

      Function getElement has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getElement($class, $name) {
              $realname = $this->realname($name);
              if (array_key_exists($class, $this->modx->sourceCache) && array_key_exists($realname, $this->modx->sourceCache[$class])) {
                  /** @var modElement $element */
                  $element = $this->modx->newObject($class);
      Severity: Minor
      Found in core/model/modx/modparser.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 processElementTags has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function processElementTags($parentTag, & $content, $processUncacheable= false, $removeUnprocessed= false, $prefix= "[[", $suffix= "]]", $tokens= array (), $depth= 0) {
              if ($processUncacheable) {
                  $this->_startedProcessingUncacheable = true;
              }
              $_processingTag = $this->_processingTag;
      Severity: Minor
      Found in core/model/modx/modparser.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 collectElementTags has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function collectElementTags($origContent, array &$matches, $prefix= '[[', $suffix= ']]') {
              $matchCount= 0;
              if (!empty ($origContent) && is_string($origContent) && strpos($origContent, $prefix) !== false) {
                  $openCount= 0;
                  $offset= 0;
      Severity: Minor
      Found in core/model/modx/modparser.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

      Method process has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function process($properties= null, $content= null) {
              parent :: process($properties, $content);
              if (!$this->_processed) {
                  $this->_output= $this->_content;
                  if (is_string($this->_output) && !empty ($this->_output)) {
      Severity: Major
      Found in core/model/modx/modparser.class.php - About 3 hrs to fix

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

            public function getPropertySet($setName = null) {
                $propertySet= null;
                $name = $this->get('name');
                if (strpos($name, '@') !== false) {
                    $psName= '';
        Severity: Minor
        Found in core/model/modx/modparser.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 collectElementTags has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function collectElementTags($origContent, array &$matches, $prefix= '[[', $suffix= ']]') {
                $matchCount= 0;
                if (!empty ($origContent) && is_string($origContent) && strpos($origContent, $prefix) !== false) {
                    $openCount= 0;
                    $offset= 0;
        Severity: Major
        Found in core/model/modx/modparser.class.php - About 2 hrs to fix

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

              public function processElementTags($parentTag, & $content, $processUncacheable= false, $removeUnprocessed= false, $prefix= "[[", $suffix= "]]", $tokens= array (), $depth= 0) {
                  if ($processUncacheable) {
                      $this->_startedProcessingUncacheable = true;
                  }
                  $_processingTag = $this->_processingTag;
          Severity: Major
          Found in core/model/modx/modparser.class.php - About 2 hrs to fix

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

                public function parsePropertyString($string, $valuesOnly = false) {
                    $properties = array();
                    $tagProps= xPDO :: escSplit("&", $string);
                    foreach ($tagProps as $prop) {
                        $property= xPDO :: escSplit('=', $prop);
            Severity: Major
            Found in core/model/modx/modparser.class.php - About 2 hrs to fix

              Method getElement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getElement($class, $name) {
                      $realname = $this->realname($name);
                      if (array_key_exists($class, $this->modx->sourceCache) && array_key_exists($realname, $this->modx->sourceCache[$class])) {
                          /** @var modElement $element */
                          $element = $this->modx->newObject($class);
              Severity: Minor
              Found in core/model/modx/modparser.class.php - About 1 hr to fix

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

                    public function setProperties($properties, $merge = false) {
                        $set = false;
                        $propertyArray = array();
                        if (is_string($properties)) {
                            $properties = $this->modx->parser->parsePropertyString($properties);
                Severity: Minor
                Found in core/model/modx/modparser.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 setProperties has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setProperties($properties, $merge = false) {
                        $set = false;
                        $propertyArray = array();
                        if (is_string($properties)) {
                            $properties = $this->modx->parser->parsePropertyString($properties);
                Severity: Minor
                Found in core/model/modx/modparser.class.php - About 1 hr to fix

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

                      public function parseProperties($propSource) {
                          $properties= array ();
                          if (!empty ($propSource)) {
                              if (is_string($propSource)) {
                                  $properties = $this->parsePropertyString($propSource, true);
                  Severity: Minor
                  Found in core/model/modx/modparser.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 getTag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getTag() {
                          if (empty($this->_tag) && ($name = $this->get('name'))) {
                              $propTemp = array();
                              if (empty($this->_propertyString) && !empty($this->_properties)) {
                                  foreach ($this->_properties as $key => $value) {
                  Severity: Minor
                  Found in core/model/modx/modparser.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 getPropertySet has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getPropertySet($setName = null) {
                          $propertySet= null;
                          $name = $this->get('name');
                          if (strpos($name, '@') !== false) {
                              $psName= '';
                  Severity: Minor
                  Found in core/model/modx/modparser.class.php - About 1 hr to fix

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

                        public function getContent(array $options = array()) {
                            if (!$this->isCacheable() || !is_string($this->_content) || $this->_content === '') {
                                if (isset($options['content']) && !empty($options['content'])) {
                                    $this->_content = $options['content'];
                                } elseif ($this->modx->resource instanceof modResource) {
                    Severity: Minor
                    Found in core/model/modx/modparser.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 processElementTags has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function processElementTags($parentTag, & $content, $processUncacheable= false, $removeUnprocessed= false, $prefix= "[[", $suffix= "]]", $tokens= array (), $depth= 0) {
                    Severity: Major
                    Found in core/model/modx/modparser.class.php - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                                          if (($pvTmp[1]=='list' || $pvTmp[1]=='combo') && isset($pvTmp[3]) && $pvTmp[3]) {
                                              if (!$valuesOnly) {
                                                  $propType = modParser::_XType($pvTmp[1]);
                                                  $options = explode(',', $pvTmp[2]);
                                                  if ($options) {
                      Severity: Major
                      Found in core/model/modx/modparser.class.php - About 1 hr to fix

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

                            public function & getOutputFilter() {
                                if (!isset ($this->_filters['output']) || !($this->_filters['output'] instanceof modOutputFilter)) {
                                    if (!$outputFilterClass= $this->get('output_filter')) {
                                        $outputFilterClass = $this->modx->getOption('output_filter',null,'filters.modOutputFilter');
                                    }
                        Severity: Minor
                        Found in core/model/modx/modparser.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 getInputFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function & getInputFilter() {
                                if (!isset ($this->_filters['input']) || !($this->_filters['input'] instanceof modInputFilter)) {
                                    if (!$inputFilterClass= $this->get('input_filter')) {
                                        $inputFilterClass = $this->modx->getOption('input_filter',null,'filters.modInputFilter');
                                    }
                        Severity: Minor
                        Found in core/model/modx/modparser.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 getContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getContent(array $options = array()) {
                                if (!is_string($this->_content) || $this->_content === '') {
                                    if (isset($options['content'])) {
                                        $this->_content = $options['content'];
                                    } else {
                        Severity: Minor
                        Found in core/model/modx/modparser.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 (array_key_exists('use_weblink_target', $this->_properties)) {
                                                    $options['use_weblink_target'] = $this->_properties['use_weblink_target'];
                                                    unset($this->_properties['use_weblink_target']);
                                                }
                        Severity: Major
                        Found in core/model/modx/modparser.class.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (in_array($propertyKey, array('context', 'scheme', 'use_weblink_target'))) continue;
                          Severity: Major
                          Found in core/model/modx/modparser.class.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (array_key_exists('scheme', $this->_properties)) {
                                                        $scheme = $this->_properties['scheme'];
                                                        unset($this->_properties['scheme']);
                                                        if (is_numeric($scheme)) $scheme = (integer) $scheme;
                                                    }
                            Severity: Major
                            Found in core/model/modx/modparser.class.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if ($resource) {
                                                          $this->_output = $resource;
                                                      }
                              Severity: Major
                              Found in core/model/modx/modparser.class.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if ($qs= implode('&', $qs)) {
                                                            $qs= rawurlencode($qs);
                                                            $qs= str_replace(array('%26','%3D'),array('&amp;','='),$qs);
                                                        }
                                Severity: Major
                                Found in core/model/modx/modparser.class.php - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if (array_key_exists('context', $this->_properties)) {
                                                              $context = $this->_properties['context'];
                                                              unset($this->_properties['context']);
                                                          }
                                  Severity: Major
                                  Found in core/model/modx/modparser.class.php - About 45 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                            if (!empty ($origContent) && is_string($origContent) && strpos($origContent, $prefix) !== false) {
                                                $openCount= 0;
                                                $offset= 0;
                                                $openPos= 0;
                                                $closePos= 0;
                                    Severity: Major
                                    Found in core/model/modx/modparser.class.php - About 40 mins to fix

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

                                          public function process($properties= null, $content= null) {
                                              parent :: process($properties, $content);
                                              if (!$this->_processed) {
                                                  $this->_output= $this->_content;
                                                  if ($this->_output !== null && is_string($this->_output) && !empty($this->_output)) {
                                      Severity: Minor
                                      Found in core/model/modx/modparser.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 _XType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          protected function _XType($type) {
                                              $xtype = $type;
                                              switch ($type) {
                                                  case 'string':
                                                      $xtype = 'textfield';
                                      Severity: Minor
                                      Found in core/model/modx/modparser.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

                                              if (!$this->_processed) {
                                                  $this->_output= $this->_content;
                                                  if (is_string($this->_output) && !empty ($this->_output)) {
                                                      /* collect element tags in the content and process them */
                                                      $maxIterations= intval($this->modx->getOption('parser_max_iterations',null,10));
                                      Severity: Major
                                      Found in core/model/modx/modparser.class.php and 1 other location - About 3 hrs to fix
                                      core/model/modx/modparser.class.php on lines 1146..1165

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

                                      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

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

                                              if (!$this->_processed) {
                                                  $this->_output= $this->_content;
                                                  if (is_string($this->_output) && !empty ($this->_output)) {
                                                      /* collect element tags in the content and process them */
                                                      $maxIterations= intval($this->modx->getOption('parser_max_iterations',null,10));
                                      Severity: Major
                                      Found in core/model/modx/modparser.class.php and 1 other location - About 3 hrs to fix
                                      core/model/modx/modparser.class.php on lines 1407..1426

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

                                      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 4 locations. Consider refactoring.
                                      Open

                                          public function & getInputFilter() {
                                              if (!isset ($this->_filters['input']) || !($this->_filters['input'] instanceof modInputFilter)) {
                                                  if (!$inputFilterClass= $this->get('input_filter')) {
                                                      $inputFilterClass = $this->modx->getOption('input_filter',null,'filters.modInputFilter');
                                                  }
                                      Severity: Major
                                      Found in core/model/modx/modparser.class.php and 3 other locations - About 3 hrs to fix
                                      core/model/modx/modelement.class.php on lines 324..336
                                      core/model/modx/modelement.class.php on lines 343..355
                                      core/model/modx/modparser.class.php on lines 901..913

                                      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 4 locations. Consider refactoring.
                                      Open

                                          public function & getOutputFilter() {
                                              if (!isset ($this->_filters['output']) || !($this->_filters['output'] instanceof modOutputFilter)) {
                                                  if (!$outputFilterClass= $this->get('output_filter')) {
                                                      $outputFilterClass = $this->modx->getOption('output_filter',null,'filters.modOutputFilter');
                                                  }
                                      Severity: Major
                                      Found in core/model/modx/modparser.class.php and 3 other locations - About 3 hrs to fix
                                      core/model/modx/modelement.class.php on lines 324..336
                                      core/model/modx/modelement.class.php on lines 343..355
                                      core/model/modx/modparser.class.php on lines 882..894

                                      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

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

                                                  if ($split && isset($split[1])) {
                                                      $name= $split[0];
                                                      $psName= $split[1];
                                                      $filters= xPDO :: escSplit(':', $setName);
                                                      if ($filters && isset($filters[1]) && !empty($filters[1])) {
                                      Severity: Major
                                      Found in core/model/modx/modparser.class.php and 1 other location - About 1 hr to fix
                                      core/model/modx/modelement.class.php on lines 609..618

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

                                      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