modxcms/revolution

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

Summary

Maintainability
F
2 wks
Test Coverage

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

    Function processBindings has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

        public function processBindings($value= '', $resourceId= 0, $preProcess = true) {
            $bdata = $this->getBindingDataFromValue($value);
            if (empty($bdata['cmd'])) return $value;
    
            $modx =& $this->xpdo;
    Severity: Minor
    Found in core/model/modx/modtemplatevar.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 checkForFormCustomizationRules has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        public function checkForFormCustomizationRules($value,&$resource) {
            if ($this->xpdo->request && $this->xpdo->user instanceof modUser) {
                if (empty($resource)) {
                    $resource =& $this->xpdo->resource;
                }
    Severity: Minor
    Found in core/model/modx/modtemplatevar.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 findPolicy has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        public function findPolicy($context = '') {
            $policy = array();
            $context = !empty($context) ? $context : $this->xpdo->context->get('key');
            if ($context === $this->xpdo->context->get('key')) {
                $catEnabled = (boolean) $this->xpdo->getOption('access_category_enabled', null, true);
    Severity: Minor
    Found in core/model/modx/modtemplatevar.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 getRender has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRender($params,$value,array $paths,$method,$resourceId = 0,$type = 'text') {
            if (empty($type)) $type = 'text';
            if (empty($this->xpdo->resource)) {
                if (!empty($resourceId)) {
                    $this->xpdo->resource = $this->xpdo->getObject('modResource',$resourceId);
    Severity: Minor
    Found in core/model/modx/modtemplatevar.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 processInheritBinding has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        public function processInheritBinding($default = '',$resourceId = null) {
            $output = $default; /* Default to param value if no content from parents */
            $resource = null;
            $resourceColumns = $this->xpdo->getSelectColumns('modResource', '', '', array('id', 'parent'));
            $resourceQuery = new xPDOCriteria($this->xpdo, "SELECT {$resourceColumns} FROM {$this->xpdo->getTableName('modResource')} WHERE id = ?");
    Severity: Minor
    Found in core/model/modx/modtemplatevar.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 processBindings has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function processBindings($value= '', $resourceId= 0, $preProcess = true) {
            $bdata = $this->getBindingDataFromValue($value);
            if (empty($bdata['cmd'])) return $value;
    
            $modx =& $this->xpdo;
    Severity: Major
    Found in core/model/modx/modtemplatevar.class.php - About 4 hrs to fix

      Method checkForFormCustomizationRules has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function checkForFormCustomizationRules($value,&$resource) {
              if ($this->xpdo->request && $this->xpdo->user instanceof modUser) {
                  if (empty($resource)) {
                      $resource =& $this->xpdo->resource;
                  }
      Severity: Major
      Found in core/model/modx/modtemplatevar.class.php - About 3 hrs to fix

        Function getRenderDirectories has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getRenderDirectories($event,$subdir) {
                $context = $this->xpdo->context->get('key');
                $renderPath = $this->xpdo->getOption('processors_path').'element/tv/renders/'.$context.'/'.$subdir.'/';
                $renderDirectories = array(
                    $renderPath,
        Severity: Minor
        Found in core/model/modx/modtemplatevar.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

        modTemplateVar has 26 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class modTemplateVar extends modElement {
            /**
             * Supported bindings for MODX
             * @var array $bindings
             */
        Severity: Minor
        Found in core/model/modx/modtemplatevar.class.php - About 3 hrs to fix

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

              public function findPolicy($context = '') {
                  $policy = array();
                  $context = !empty($context) ? $context : $this->xpdo->context->get('key');
                  if ($context === $this->xpdo->context->get('key')) {
                      $catEnabled = (boolean) $this->xpdo->getOption('access_category_enabled', null, true);
          Severity: Major
          Found in core/model/modx/modtemplatevar.class.php - About 2 hrs to fix

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

                public function renderInput($resource= null, $options = array()) {
                    if (is_int($resource)) {
                        $resource = $this->xpdo->getObject('modResource',$resource);
                    }
                    if (empty($resource)) {
            Severity: Minor
            Found in core/model/modx/modtemplatevar.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 parseInput has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function parseInput($src, $delim= "||", $type= "string") {
                    if (is_object($src)) {
                        if ($src instanceof PDOStatement) {
                            $rs= $src->fetchAll(PDO::FETCH_ASSOC);
                            if ($type != "array") {
            Severity: Minor
            Found in core/model/modx/modtemplatevar.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 prepareOutput has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function prepareOutput($value, $resourceId= 0) {
                    /* Allow custom source types to manipulate the output URL for image/file tvs */
                    $mTypes = $this->xpdo->getOption('manipulatable_url_tv_output_types',null,'image,file');
                    $mTypes = explode(',',$mTypes);
                    if (!empty($value) && in_array($this->get('type'),$mTypes)) {
            Severity: Minor
            Found in core/model/modx/modtemplatevar.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 renderInput has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function renderInput($resource= null, $options = array()) {
                    if (is_int($resource)) {
                        $resource = $this->xpdo->getObject('modResource',$resource);
                    }
                    if (empty($resource)) {
            Severity: Minor
            Found in core/model/modx/modtemplatevar.class.php - About 1 hr to fix

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

                  public function getRender($params,$value,array $paths,$method,$resourceId = 0,$type = 'text') {
                      if (empty($type)) $type = 'text';
                      if (empty($this->xpdo->resource)) {
                          if (!empty($resourceId)) {
                              $this->xpdo->resource = $this->xpdo->getObject('modResource',$resourceId);
              Severity: Minor
              Found in core/model/modx/modtemplatevar.class.php - About 1 hr to fix

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

                    public function setValue($resourceId= 0, $value= null) {
                        $oldValue= '';
                        if (intval($resourceId)) {
                            $templateVarResource = $this->xpdo->getObject('modTemplateVarResource',array(
                                'tmplvarid' => $this->get('id'),
                Severity: Minor
                Found in core/model/modx/modtemplatevar.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 getRenderDirectories has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getRenderDirectories($event,$subdir) {
                        $context = $this->xpdo->context->get('key');
                        $renderPath = $this->xpdo->getOption('processors_path').'element/tv/renders/'.$context.'/'.$subdir.'/';
                        $renderDirectories = array(
                            $renderPath,
                Severity: Minor
                Found in core/model/modx/modtemplatevar.class.php - About 1 hr to fix

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

                      public function processInheritBinding($default = '',$resourceId = null) {
                          $output = $default; /* Default to param value if no content from parents */
                          $resource = null;
                          $resourceColumns = $this->xpdo->getSelectColumns('modResource', '', '', array('id', 'parent'));
                          $resourceQuery = new xPDOCriteria($this->xpdo, "SELECT {$resourceColumns} FROM {$this->xpdo->getTableName('modResource')} WHERE id = ?");
                  Severity: Minor
                  Found in core/model/modx/modtemplatevar.class.php - About 1 hr to fix

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

                        public function render($value,array $params = array()) {
                            if (!empty($params)) {
                                foreach ($params as $k => $v) {
                                    if ($v === 'true') {
                                        $params[$k] = TRUE;
                    Severity: Minor
                    Found in core/model/modx/modtemplatevar.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 getValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getValue($resourceId= 0) {
                            $value= null;
                            $resourceId = intval($resourceId);
                            if ($resourceId) {
                                if (is_object($this->xpdo->resource) && $resourceId === (integer) $this->xpdo->resourceIdentifier && is_array($this->xpdo->resource->get($this->get('name')))) {
                    Severity: Minor
                    Found in core/model/modx/modtemplatevar.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 process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function process($properties= null, $content= null) {
                            parent :: process($properties, $content);
                            if (!$this->_processed) {
                                $this->_content= $this->renderOutput($this->xpdo->resourceIdentifier);
                    
                    
                    Severity: Minor
                    Found in core/model/modx/modtemplatevar.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 process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function process($properties= null, $content= null) {
                            parent :: process($properties, $content);
                            if (!$this->_processed) {
                                $this->_content= $this->renderOutput($this->xpdo->resourceIdentifier);
                    
                    
                    Severity: Minor
                    Found in core/model/modx/modtemplatevar.class.php - About 1 hr to fix

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

                          public function getDisplayParams() {
                              $settings = array();
                              $params = $this->get('display_params');
                              $ps = explode('&',$params);
                              foreach ($ps as $p) {
                      Severity: Minor
                      Found in core/model/modx/modtemplatevar.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 renderOutput has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function renderOutput($resourceId= 0) {
                              $value= $this->getValue($resourceId);
                      
                              /* process any TV commands in value */
                              $value= $this->processBindings($value, $resourceId);
                      Severity: Minor
                      Found in core/model/modx/modtemplatevar.class.php - About 45 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                          public function getRender($params,$value,array $paths,$method,$resourceId = 0,$type = 'text') {
                      Severity: Minor
                      Found in core/model/modx/modtemplatevar.class.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (!$isAbsolute) {
                                                    $value = $source->prepareOutputUrl($value);
                                                }
                        Severity: Major
                        Found in core/model/modx/modtemplatevar.class.php - About 45 mins to fix

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

                              public function checkResourceGroupAccess($user = null,$context = '') {
                                  $context = !empty($context) ? $context : '';
                          
                                  $c = $this->xpdo->newQuery('modResourceGroup');
                                  $c->innerJoin('modTemplateVarResourceGroup','TemplateVarResourceGroups',array(
                          Severity: Minor
                          Found in core/model/modx/modtemplatevar.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function save($cacheFlag = null) {
                                  $isNew = $this->isNew();
                                  if ($this->xpdo instanceof modX) {
                                      $this->xpdo->invokeEvent('OnTemplateVarBeforeSave',array(
                                          'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
                          Severity: Minor
                          Found in core/model/modx/modtemplatevar.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 hasTemplate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function hasTemplate($templatePk) {
                                  if (!is_int($templatePk) && !is_object($templatePk)) {
                                      $template = $this->xpdo->getObject('modTemplate',array('templatename' => $templatePk));
                                      if (empty($template) || !is_object($template) || !($template instanceof modTemplate)) {
                                          $this->xpdo->log(modX::LOG_LEVEL_ERROR,'modTemplateVar::hasTemplate - No template: '.$templatePk);
                          Severity: Minor
                          Found in core/model/modx/modtemplatevar.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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function remove(array $ancestors= array ()) {
                                  if ($this->xpdo instanceof modX) {
                                      $this->xpdo->invokeEvent('OnTemplateVarBeforeRemove',array(
                                          'templateVar' => &$this,
                                          'cacheFlag' => true,
                          Severity: Minor
                          Found in core/model/modx/modtemplatevar.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 processFileBinding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function processFileBinding($file) {
                                  if (file_exists($file) && @ $handle= fopen($file,'r')) {
                                      $buffer= "";
                                      while (!feof($handle)) {
                                          $buffer .= fgets($handle, 4096);
                          Severity: Minor
                          Found in core/model/modx/modtemplatevar.class.php - About 25 mins to fix

                          Cognitive Complexity

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

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

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

                          Further reading

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

                                          if ($rgEnabled) {
                                              $accessTable = $this->xpdo->getTableName('modAccessResourceGroup');
                                              $resourceGroupTable = $this->xpdo->getTableName('modTemplateVarResourceGroup');
                                              $sql = "SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data FROM {$accessTable} Acl " .
                                                      "LEFT JOIN {$policyTable} Policy ON Policy.id = Acl.policy " .
                          Severity: Major
                          Found in core/model/modx/modtemplatevar.class.php and 1 other location - About 7 hrs to fix
                          core/model/modx/modtemplatevar.class.php on lines 1019..1043

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

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                          if ($catEnabled) {
                                              $accessTable = $this->xpdo->getTableName('modAccessCategory');
                                              $categoryClosureTable = $this->xpdo->getTableName('modCategoryClosure');
                                              $sql = "SELECT Acl.target, Acl.principal, Acl.authority, Acl.policy, Policy.data FROM {$accessTable} Acl " .
                                                      "LEFT JOIN {$policyTable} Policy ON Policy.id = Acl.policy " .
                          Severity: Major
                          Found in core/model/modx/modtemplatevar.class.php and 1 other location - About 7 hrs to fix
                          core/model/modx/modtemplatevar.class.php on lines 994..1018

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

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

                              public function save($cacheFlag = null) {
                                  $isNew = $this->isNew();
                                  if ($this->xpdo instanceof modX) {
                                      $this->xpdo->invokeEvent('OnTemplateVarBeforeSave',array(
                                          'mode' => $isNew ? modSystemEvent::MODE_NEW : modSystemEvent::MODE_UPD,
                          Severity: Major
                          Found in core/model/modx/modtemplatevar.class.php and 2 other locations - About 7 hrs to fix
                          core/model/modx/modplugin.class.php on lines 42..66
                          core/model/modx/modtemplate.class.php on lines 58..82

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

                          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_string($this->_output) && !empty ($this->_output)) {
                                          /* turn the processed properties into placeholders */
                                          $scope = $this->xpdo->toPlaceholders($this->_properties, '', '.', true);
                          
                                          /* collect element tags in the content and process them */
                          Severity: Major
                          Found in core/model/modx/modtemplatevar.class.php and 1 other location - About 5 hrs to fix
                          core/model/modx/modchunk.class.php on lines 109..129

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

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

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

                                  if (!is_int($templatePk) && !is_object($templatePk)) {
                                      $template = $this->xpdo->getObject('modTemplate',array('templatename' => $templatePk));
                                      if (empty($template) || !is_object($template) || !($template instanceof modTemplate)) {
                                          $this->xpdo->log(modX::LOG_LEVEL_ERROR,'modTemplateVar::hasTemplate - No template: '.$templatePk);
                                          return false;
                          Severity: Major
                          Found in core/model/modx/modtemplatevar.class.php and 1 other location - About 1 hr to fix
                          core/model/modx/modtemplate.class.php on lines 204..212

                          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