Function generateContext
has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring. Open
public function generateContext($key, array $options = array()) {
$results = array();
if (!$this->getOption('transient_context', $options, false)) {
/** @var modContext $obj */
$obj= $this->modx->getObject('modContext', $key, true);
- Read upRead up
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
File modcachemanager.class.php
has 626 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* This file is part of MODX Revolution.
*
* Copyright (c) MODX, LLC. All Rights Reserved.
Function generateResource
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function generateResource(modResource & $obj, array $options = array()) {
$results= array();
if ($this->getOption('cache_resource', $options, true)) {
if (is_object($obj) && $obj instanceof modResource && $obj->getProcessed() && $obj->get('cacheable') && $obj->get('id')) {
$results['resourceClass']= $obj->_class;
- Read upRead up
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 refresh
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function refresh(array $providers = array(), array &$results = array()) {
if (empty($providers)) {
$contexts = array();
$query = $this->xpdo->newQuery('modContext');
$query->select($this->xpdo->escape('key'));
- Read upRead up
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 clearCache
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function clearCache(array $paths= array(), array $options= array()) {
$this->modx->deprecated('2.1.0', 'Use modCacheManager::refresh() instead.');
$results= array();
$delObjs= array();
if ($clearObjects = $this->getOption('objects', $options)) {
- Read upRead up
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 autoPublish
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function autoPublish(array $options = array()) {
$publishingResults= array();
$tblResource= $this->modx->getTableName('modResource');
$timeNow= time();
- Read upRead up
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 generateContext
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateContext($key, array $options = array()) {
$results = array();
if (!$this->getOption('transient_context', $options, false)) {
/** @var modContext $obj */
$obj= $this->modx->getObject('modContext', $key, true);
Method refresh
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function refresh(array $providers = array(), array &$results = array()) {
if (empty($providers)) {
$contexts = array();
$query = $this->xpdo->newQuery('modContext');
$query->select($this->xpdo->escape('key'));
Method autoPublish
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function autoPublish(array $options = array()) {
$publishingResults= array();
$tblResource= $this->modx->getTableName('modResource');
$timeNow= time();
Function generateConfig
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function generateConfig(array $options = array()) {
$config = array();
if ($collection= $this->modx->getCollection('modSystemSetting')) {
foreach ($collection as $setting) {
$k= $setting->get('key');
- Read upRead up
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 generateActionMap
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function generateActionMap($cacheKey, array $options = array()) {
$results= array();
$c = $this->modx->newQuery('modAction');
$c->select(array(
$this->modx->getSelectColumns('modAction', 'modAction'),
- Read upRead up
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 generateResource
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateResource(modResource & $obj, array $options = array()) {
$results= array();
if ($this->getOption('cache_resource', $options, true)) {
if (is_object($obj) && $obj instanceof modResource && $obj->getProcessed() && $obj->get('cacheable') && $obj->get('id')) {
$results['resourceClass']= $obj->_class;
Method clearCache
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function clearCache(array $paths= array(), array $options= array()) {
$this->modx->deprecated('2.1.0', 'Use modCacheManager::refresh() instead.');
$results= array();
$delObjs= array();
if ($clearObjects = $this->getOption('objects', $options)) {
Method generateExtensionPackagesCache
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateExtensionPackagesCache($cacheKey,array $options = array()) {
$results = array();
$c = $this->modx->newQuery('modExtensionPackage');
$c->innerJoin('modNamespace','Namespace');
Method getElementMediaSourceCache
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getElementMediaSourceCache(modElement $element,$contextKey, array $options = array()) {
$options[xPDO::OPT_CACHE_KEY] = $this->getOption('cache_media_sources_key', $options, 'media_sources');
$options[xPDO::OPT_CACHE_HANDLER] = $this->getOption('cache_media_sources_handler', $options, $this->getOption(xPDO::OPT_CACHE_HANDLER, $options));
$options[xPDO::OPT_CACHE_FORMAT] = (integer) $this->getOption('cache_media_sources_format', $options, $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP));
$options[xPDO::OPT_CACHE_ATTEMPTS] = (integer) $this->getOption('cache_media_sources_attempts', $options, $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 10));
Function generateExtensionPackagesCache
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function generateExtensionPackagesCache($cacheKey,array $options = array()) {
$results = array();
$c = $this->modx->newQuery('modExtensionPackage');
$c->innerJoin('modNamespace','Namespace');
- Read upRead up
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 generateActionMap
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateActionMap($cacheKey, array $options = array()) {
$results= array();
$c = $this->modx->newQuery('modAction');
$c->select(array(
$this->modx->getSelectColumns('modAction', 'modAction'),
Function generateNamespacesCache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function generateNamespacesCache($cacheKey, array $options = array()) {
$results = array();
$c = $this->modx->newQuery('modNamespace');
$c->select($this->modx->getSelectColumns('modNamespace', 'modNamespace'));
$c->sortby('name','ASC');
- Read upRead up
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 generateConfig
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateConfig(array $options = array()) {
$config = array();
if ($collection= $this->modx->getCollection('modSystemSetting')) {
foreach ($collection as $setting) {
$k= $setting->get('key');
Method generateNamespacesCache
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateNamespacesCache($cacheKey, array $options = array()) {
$results = array();
$c = $this->modx->newQuery('modNamespace');
$c->select($this->modx->getSelectColumns('modNamespace', 'modNamespace'));
$c->sortby('name','ASC');
Function generateScript
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function generateScript(modScript &$objElement, $objContent= null, array $options= array()) {
$results= false;
if (is_object($objElement) && $objElement instanceof modScript) {
$results= $objElement->getContent(is_string($objContent) ? array('content' => $objContent) : array());
$results = rtrim($results, "\n") . "\nreturn;\n";
- Read upRead up
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 flushPermissions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function flushPermissions() {
$ctxQuery = $this->modx->newQuery('modContext');
$ctxQuery->select($this->modx->getSelectColumns('modContext', '', '', array('key')));
if ($ctxQuery->prepare() && $ctxQuery->stmt->execute()) {
$contexts = $ctxQuery->stmt->fetchAll(PDO::FETCH_COLUMN);
- Read upRead up
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 3 locations. Consider refactoring. Open
if (!empty($results) && $this->getOption('cache_action_map', $options, true)) {
$options[xPDO::OPT_CACHE_KEY] = $this->getOption('cache_action_map_key', $options, 'action_map');
$options[xPDO::OPT_CACHE_HANDLER] = $this->getOption('cache_action_map_handler', $options, $this->getOption(xPDO::OPT_CACHE_HANDLER, $options));
$options[xPDO::OPT_CACHE_FORMAT] = (integer) $this->getOption('cache_action_map_format', $options, $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP));
$options[xPDO::OPT_CACHE_ATTEMPTS] = (integer) $this->getOption('cache_action_map_attempts', $options, $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 1));
- Read upRead up
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 302.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (!empty($results) && $this->getOption('cache_extension_packages', $options, true)) {
$options[xPDO::OPT_CACHE_KEY] = $this->getOption('cache_extension_packages_key', $options,'namespaces');
$options[xPDO::OPT_CACHE_HANDLER] = $this->getOption('cache_extension_packages_handler', $options, $this->getOption(xPDO::OPT_CACHE_HANDLER, $options));
$options[xPDO::OPT_CACHE_FORMAT] = (integer) $this->getOption('cache_extension_packages_format', $options, $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP));
$options[xPDO::OPT_CACHE_ATTEMPTS] = (integer) $this->getOption('cache_extension_packages_attempts', $options, $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 1));
- Read upRead up
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 302.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (!empty($results) && $this->getOption('cache_namespaces', $options, true)) {
$options[xPDO::OPT_CACHE_KEY] = $this->getOption('cache_namespaces_key', $options,'namespaces');
$options[xPDO::OPT_CACHE_HANDLER] = $this->getOption('cache_namespaces_handler', $options, $this->getOption(xPDO::OPT_CACHE_HANDLER, $options));
$options[xPDO::OPT_CACHE_FORMAT] = (integer) $this->getOption('cache_namespaces_format', $options, $this->getOption(xPDO::OPT_CACHE_FORMAT, $options, xPDOCacheManager::CACHE_PHP));
$options[xPDO::OPT_CACHE_ATTEMPTS] = (integer) $this->getOption('cache_namespaces_attempts', $options, $this->getOption(xPDO::OPT_CACHE_ATTEMPTS, $options, 1));
- Read upRead up
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 302.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($stmt) {
$stmt->bindValue(1, 0);
if ($stmt->execute()) {
foreach ($stmt->fetchAll(PDO::FETCH_NUM) as $value) {
$minunpub= $value[0];
- Read upRead up
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 124.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($stmt) {
$stmt->bindValue(1, 0);
if ($stmt->execute()) {
foreach ($stmt->fetchAll(PDO::FETCH_NUM) as $value) {
$minpub= $value[0];
- Read upRead up
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 124.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76