modxcms/revolution

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

Summary

Maintainability
F
1 wk
Test Coverage

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

    modElement has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class modElement extends modAccessibleSimpleObject {
        /**
         * The property value array for the element.
         * @var array
         */
    Severity: Minor
    Found in core/model/modx/modelement.class.php - About 4 hrs to fix

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

          public function get($k, $format= null, $formatTemplate= null) {
              $value = parent :: get($k, $format, $formatTemplate);
              if ($k === 'properties' && $this->xpdo instanceof modX && $this->xpdo->getParser() && empty($value)) {
                  $value = !empty($this->properties) && is_string($this->properties)
                      ? $this->xpdo->parser->parsePropertyString($this->properties)
      Severity: Minor
      Found in core/model/modx/modelement.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 setProperties has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setProperties($properties, $merge = false) {
              $set = false;
              $propertiesArray = array();
              if (is_string($properties)) {
                  $properties = $this->xpdo->parser->parsePropertyString($properties);
      Severity: Minor
      Found in core/model/modx/modelement.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 isStaticSourceMutable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          public function isStaticSourceMutable() {
              $isMutable = false;
              $sourceFile = $this->getSourceFile();
              if ($sourceFile) {
                  if (file_exists($sourceFile)) {
      Severity: Minor
      Found in core/model/modx/modelement.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 save has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function save($cacheFlag = null) {
              if (!$this->getOption(xPDO::OPT_SETUP)) {
                  if ($this->staticSourceChanged()) {
                      $staticContent = $this->getFileContent();
                      if ($staticContent !== $this->get('content')) {
      Severity: Minor
      Found in core/model/modx/modelement.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 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/modelement.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 setProperties has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function setProperties($properties, $merge = false) {
              $set = false;
              $propertiesArray = array();
              if (is_string($properties)) {
                  $properties = $this->xpdo->parser->parsePropertyString($properties);
      Severity: Major
      Found in core/model/modx/modelement.class.php - About 2 hrs to fix

        Function getTag has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTag() {
                if (empty($this->_tag)) {
                    $propTemp = array();
                    if (empty($this->_propertyString) && !empty($this->_properties)) {
                        foreach ($this->_properties as $key => $value) {
        Severity: Minor
        Found in core/model/modx/modelement.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 getSourceFile has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSourceFile(array $options = array()) {
                if ($this->isStatic() && (empty($this->_sourceFile) || $this->getOption('recalculate_source_file', $options, $this->staticSourceChanged()))) {
                    $filename = $this->get('static_file');
                    if (!empty($filename)) {
                        $array = array();
        Severity: Minor
        Found in core/model/modx/modelement.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 findPolicy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function findPolicy($context = '') {
                $policy = array();
                $enabled = true;
                $context = !empty($context) ? $context : $this->xpdo->context->get('key');
                if ($context === $this->xpdo->context->get('key')) {
        Severity: Minor
        Found in core/model/modx/modelement.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 addPropertySet has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function addPropertySet($propertySet) {
                $added= false;
                if (!empty($propertySet)) {
                    if (is_string($propertySet)) {
                        $propertySet = $this->xpdo->getObject('modPropertySet', array('name' => $propertySet));
        Severity: Minor
        Found in core/model/modx/modelement.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 41 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/modelement.class.php - About 1 hr to fix

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

              public function findPolicy($context = '') {
                  $policy = array();
                  $enabled = true;
                  $context = !empty($context) ? $context : $this->xpdo->context->get('key');
                  if ($context === $this->xpdo->context->get('key')) {
          Severity: Minor
          Found in core/model/modx/modelement.class.php - About 1 hr to fix

            Function getContent has a Cognitive Complexity of 13 (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'];
                        } elseif ($this->isStatic()) {
            Severity: Minor
            Found in core/model/modx/modelement.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 getOldStaticFilePath has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getOldStaticFilePath() {
                    $oldFilePath = '';
                    $sourceId    = 0;
            
                    $result = $this->xpdo->getObject($this->_class, array('id' => $this->_fields['id']));
            Severity: Minor
            Found in core/model/modx/modelement.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 get has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get($k, $format= null, $formatTemplate= null) {
                    $value = parent :: get($k, $format, $formatTemplate);
                    if ($k === 'properties' && $this->xpdo instanceof modX && $this->xpdo->getParser() && empty($value)) {
                        $value = !empty($this->properties) && is_string($this->properties)
                            ? $this->xpdo->parser->parsePropertyString($this->properties)
            Severity: Minor
            Found in core/model/modx/modelement.class.php - About 1 hr to fix

              Method save has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function save($cacheFlag = null) {
                      if (!$this->getOption(xPDO::OPT_SETUP)) {
                          if ($this->staticSourceChanged()) {
                              $staticContent = $this->getFileContent();
                              if ($staticContent !== $this->get('content')) {
              Severity: Minor
              Found in core/model/modx/modelement.class.php - About 1 hr to fix

                Method getTag has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getTag() {
                        if (empty($this->_tag)) {
                            $propTemp = array();
                            if (empty($this->_propertyString) && !empty($this->_properties)) {
                                foreach ($this->_properties as $key => $value) {
                Severity: Minor
                Found in core/model/modx/modelement.class.php - About 1 hr to fix

                  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->xpdo->getOption('input_filter',null,'filters.modInputFilter');
                              }
                  Severity: Minor
                  Found in core/model/modx/modelement.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 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->xpdo->getOption('output_filter',null,'filters.modOutputFilter');
                              }
                  Severity: Minor
                  Found in core/model/modx/modelement.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 getProperties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getProperties($properties = null) {
                          $this->xpdo->getParser();
                          $this->_properties= $this->xpdo->parser->parseProperties($this->get('properties'));
                          $set= $this->getPropertySet();
                          if (!empty($set)) {
                  Severity: Minor
                  Found in core/model/modx/modelement.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

                  Consider simplifying this complex logical expression.
                  Open

                          if ($k == 'properties' && !empty($value) && is_array($value)
                                 && is_object($this->xpdo) && $this->xpdo instanceof modX && $this->xpdo->lexicon) {
                              foreach ($value as &$property) {
                                  if (!empty($property['lexicon'])) {
                                      if (strpos($property['lexicon'],':') !== false) {
                  Severity: Major
                  Found in core/model/modx/modelement.class.php - About 40 mins to fix

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

                        public function removePropertySet($propertySet) {
                            $removed = false;
                            if (!empty($propertySet)) {
                                if (is_string($propertySet)) {
                                    $propertySet = $this->xpdo->getObject('modPropertySet', array('name' => $propertySet));
                    Severity: Minor
                    Found in core/model/modx/modelement.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 cleanupStaticFileDirectories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function cleanupStaticFileDirectories($dirname) {
                            $contents = array_diff(scandir($dirname), array('..', '.', '.DS_Store'));
                    
                            @unlink($dirname .'/.DS_Store');
                            if (count($contents) === 0) {
                    Severity: Minor
                    Found in core/model/modx/modelement.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

                        public function findPolicy($context = '') {
                            $policy = array();
                            $enabled = true;
                            $context = !empty($context) ? $context : $this->xpdo->context->get('key');
                            if ($context === $this->xpdo->context->get('key')) {
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 1 other location - About 2 days to fix
                    core/model/modx/modresource.class.php on lines 864..905

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

                    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 (is_array($property) && isset($property[5])) {
                                        $key = $property[0];
                                        $propertyArray = array(
                                            'name' => $property[0],
                                            'desc' => $property[1],
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 1 other location - About 1 day to fix
                    core/model/modx/modpropertyset.class.php on lines 124..157

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

                    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->xpdo->getOption('input_filter',null,'filters.modInputFilter');
                                }
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 3 other locations - About 3 hrs to fix
                    core/model/modx/modelement.class.php on lines 343..355
                    core/model/modx/modparser.class.php on lines 882..894
                    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->xpdo->getOption('output_filter',null,'filters.modOutputFilter');
                                }
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 3 other locations - About 3 hrs to fix
                    core/model/modx/modelement.class.php on lines 324..336
                    core/model/modx/modparser.class.php on lines 882..894
                    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

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

                                    if (!empty($property['options'])) {
                                        foreach ($property['options'] as &$option) {
                                            if (empty($option['text']) && !empty($option['name'])) {
                                                $option['text'] = $option['name'];
                                                unset($option['name']);
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 2 other locations - About 2 hrs to fix
                    core/model/modx/modpropertyset.class.php on lines 72..84
                    core/model/modx/sources/modmediasource.class.php on lines 489..501

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

                    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/modelement.class.php and 1 other location - About 1 hr to fix
                    core/model/modx/modparser.class.php on lines 1090..1099

                    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

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

                        public function cleanupStaticFileDirectories($dirname) {
                            $contents = array_diff(scandir($dirname), array('..', '.', '.DS_Store'));
                    
                            @unlink($dirname .'/.DS_Store');
                            if (count($contents) === 0) {
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 1 other location - About 1 hr to fix
                    core/model/modx/processors/element/remove.class.php on lines 68..80

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

                    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 (!empty($property['lexicon'])) {
                                        if (strpos($property['lexicon'],':') !== false) {
                                            $this->xpdo->lexicon->load('en:'.$property['lexicon']);
                                        } else {
                                            $this->xpdo->lexicon->load('en:core:'.$property['lexicon']);
                    Severity: Major
                    Found in core/model/modx/modelement.class.php and 1 other location - About 1 hr to fix
                    core/model/modx/modpropertyset.class.php on lines 61..68

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

                    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

                        protected function isStaticFilesAutomated()
                        {
                            $elements = array(
                                'modTemplate'    => 'templates',
                                'modTemplateVar' => 'tvs',
                    Severity: Minor
                    Found in core/model/modx/modelement.class.php and 1 other location - About 50 mins to fix
                    core/model/modx/processors/element/remove.class.php on lines 51..66

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

                    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