__construct accesses the super-global variable $_SERVER. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
preDispatch accesses the super-global variable $_POST. Open
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
$mvc = \Zend_Layout::getMvcInstance();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
preDispatch accesses the super-global variable $_SERVER. Open
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
$mvc = \Zend_Layout::getMvcInstance();
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
File GemsEscort.php
has 1410 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Project Application Core code
*
GemsEscort
has 77 functions (exceeds 20 allowed). Consider refactoring. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
Function routeShutdown
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
- 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 _initCache
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
Function _layoutCrumbs
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutCrumbs(array $args = null)
{
// Must be called after _layoutNavigation()
if ($this->menu && $this->menu->isVisible()) {
- 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 _initCache
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
- 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 routeShutdown
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
Function __construct
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- 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 requestChanged
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function requestChanged(\Zend_Controller_Request_Abstract $request)
{
if ($this->project->isMultiLocale()) {
// Get the choosen language
$localeId = \Gems_Cookies::getLocale($request);
- 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
The class GemsEscort has 62 non-getter- and setter-methods. Consider refactoring GemsEscort to keep number of methods under 25. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class GemsEscort has an overall complexity of 330 which is very high. The configured complexity threshold is 50. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
- Exclude checks
The class GemsEscort has 15 public methods. Consider refactoring GemsEscort to keep number of public methods under 10. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
Function postDispatch
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$headers = $this->project->getResponseHeaders();
foreach ($headers as $name => $value) {
- 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 _checkParameters
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function _checkParameters(array $params, array $posts)
{
foreach ($params as $key => $value) {
$rest = strpbrk($key, '<>=%&"\'`');
if (false !== $rest) {
- 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 __construct
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
Method controllerInit
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function controllerInit(\Zend_Controller_Action $actionController = null)
{
$this->_copyVariables($actionController ? $actionController : $this->controllerAfterAction);
$this->prepareController();
Method requestChanged
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function requestChanged(\Zend_Controller_Request_Abstract $request)
{
if ($this->project->isMultiLocale()) {
// Get the choosen language
$localeId = \Gems_Cookies::getLocale($request);
Function prepareLayout
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function prepareLayout($layoutFuncs, $layoutArgs)
{
foreach ($layoutFuncs as $prepare => $type) {
if (!$type) {
continue;
- 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 _layoutCrumbs
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _layoutCrumbs(array $args = null)
{
// Must be called after _layoutNavigation()
if ($this->menu && $this->menu->isVisible()) {
Method postDispatch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$headers = $this->project->getResponseHeaders();
foreach ($headers as $name => $value) {
Function preDispatch
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
$mvc = \Zend_Layout::getMvcInstance();
- 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 getDatabasePaths
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDatabasePaths()
{
$paths = [];
$path = APPLICATION_PATH . '/configs/db';
Method getUiSwitcher
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getUiSwitcher($items, $currentId, $elementId, $elementName, $controller, array $args = null, $action = 'change-ui')
{
$uiSwitch = \MUtil_Html::create('div', $args, array('id' => $elementId));
$params = $this->request->getparams();
unset($params['error_handler']); // If present, this is an object and causes a warning
Method _checkParameters
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _checkParameters(array $params, array $posts)
{
foreach ($params as $key => $value) {
$rest = strpbrk($key, '<>=%&"\'`');
if (false !== $rest) {
Function _initEvent
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function _initEvent()
{
$dispatcher = new \Gems\Event\EventDispatcher();
// Add Gems general Event subscriber.
- 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 _initTranslate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _initTranslate()
{
$this->bootstrap(['event', 'locale']);
$language = $this->locale->getLanguage();
Method includeFile
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function includeFile($fileName)
{
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
if (! $extension) {
Method _initLogger
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _initLogger()
{
$this->bootstrap('project'); // Make sure the project object is available
$logger = \Gems_Log::getLogger();
Method preDispatch
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function preDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
$mvc = \Zend_Layout::getMvcInstance();
Method _layoutLocaleSet
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _layoutLocaleSet(array $args = null)
{
// LOCALE
$currentUri = base64_encode($this->view->url());
$localeDiv = \MUtil_Html::create('div', $args, array('id' => 'languages'));
Function _layoutOrganizationName
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutOrganizationName(array $args = null)
{
if (isset($args['tagName'])) {
$tagName = $args['tagName'];
unset($args['tagName']);
- 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 getUiSwitcher
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function getUiSwitcher($items, $currentId, $elementId, $elementName, $controller, array $args = null, $action = 'change-ui')
Avoid deeply nested control flow statements. Open
if (file_exists($languageFilename)) {
$this->translate->addTranslation($languageFilename, $localeId);
}
Function _layoutLocaleSet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutLocaleSet(array $args = null)
{
// LOCALE
$currentUri = base64_encode($this->view->url());
$localeDiv = \MUtil_Html::create('div', $args, array('id' => 'languages'));
- 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 _layoutCss
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutCss()
{
// Set CSS stylescheet(s)
$projectCss = isset($this->project->css) ? (array) $this->project->css : [];
$projectCss = array_reverse($projectCss);
- 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 getModules
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getModules()
{
if (!$this->moduleSettings && static::$modules) {
$settings = [];
foreach(static::$modules as $name=>$settingsClass) {
- 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
Avoid too many return
statements within this method. Open
return 'DEV';
Avoid too many return
statements within this method. Open
return strtoupper(substr(APPLICATION_ENV, 0 , 4));
Function _layoutTitle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutTitle(array $args = null)
{
if (is_array($args) && array_key_exists('separator', $args)) {
$separator = $args['separator'];
} else {
- 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 _layoutContact
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutContact(array $args = null)
{
if ($this->menu instanceof \Gems_Menu) {
$menuItem = $this->menu->find(array('controller' => 'contact', 'action' => 'index'));
- 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 _copyVariables
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _copyVariables($object)
{
// Store for _updateVariable
$this->_copyDestinations[] = $object;
- 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 _layoutProjectName
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _layoutProjectName(array $args = null)
{
if (isset($args['tagName'])) {
$tagName = $args['tagName'];
unset($args['tagName']);
- 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 includeFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function includeFile($fileName)
{
$extension = pathinfo($fileName, PATHINFO_EXTENSION);
if (! $extension) {
- 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 _initLocale
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _initLocale()
{
$this->bootstrap(array('project', 'session'));
// Get the choosen language
- 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
The method _initCache() has an NPath complexity of 348. The configured NPath complexity threshold is 200. Open
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method _initCache() has 165 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
- Exclude checks
The class GemsEscort has 2623 lines of code. Current threshold is 1000. Avoid really long classes. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
- Exclude checks
The method routeShutdown() has 149 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
- Exclude checks
The method routeShutdown() has an NPath complexity of 4752. The configured NPath complexity threshold is 200. Open
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method __construct() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method _initCache() has a Cyclomatic Complexity of 28. The configured cyclomatic complexity threshold is 10. Open
protected function _initCache()
{
$this->bootstrap('project');
$useCache = $this->getResource('project')->getCache();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method _layoutCrumbs() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
protected function _layoutCrumbs(array $args = null)
{
// Must be called after _layoutNavigation()
if ($this->menu && $this->menu->isVisible()) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method requestChanged() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public function requestChanged(\Zend_Controller_Request_Abstract $request)
{
if ($this->project->isMultiLocale()) {
// Get the choosen language
$localeId = \Gems_Cookies::getLocale($request);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method postDispatch() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$headers = $this->project->getResponseHeaders();
foreach ($headers as $name => $value) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method routeShutdown() has a Cyclomatic Complexity of 28. The configured cyclomatic complexity threshold is 10. Open
public function routeShutdown(\Zend_Controller_Request_Abstract $request)
{
$loader = $this->getLoader();
// Load the menu. As building the menu can depend on all resources and the request, we do it here.
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class GemsEscort has a coupling between objects value of 81. Consider to reduce the number of dependencies under 13. Open
class GemsEscort extends \MUtil_Application_Escort
{
/**
* Default reception code value
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The method _initLogger() contains an exit expression. Open
die(str_replace(GEMS_ROOT_DIR . '/', '', sprintf(
$this->translateAdapter->_('Path %s not writable') . "\n%s\n",
$logPath,
$exc->getMessage()
)));
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
Avoid unused local variables such as '$bootstrap'. Open
$bootstrap = \MUtil_Bootstrap::bootstrap(array('fontawesome' => true));
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$fullHost'. Open
public function isAllowedHost($fullHost)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$name'. Open
foreach ($moduleSettings as $name => $settings) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
BUG found Open
// FIRE BUG
- Exclude checks
Avoid excessively long variable names like $maintenanceAccessiblePages. Keep variable name length under 20. Open
protected $maintenanceAccessiblePages = [
'index' => ['index', 'login', 'logoff', 'resetpassword'],
'ask' => ['index', 'forward', 'return', 'token'],
'contact'=> ['index', 'about', 'gems', 'bugs', 'support'],
];
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $previousRequestParameters. Keep variable name length under 20. Open
if ($this->session->user_id && $previousRequestParameters = $staticSession->previousRequestParameters) {
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid using short method names like GemsEscort::_(). The configured minimum method name length is 3. Open
public function _($text, $locale = null)
{
if (! isset($this->request)) {
// Locale is fixed by request.
$this->setException(new \Gems_Exception_Coding('Requested translation before request was made available.'));
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid variables with short names like $p. Configured minimum length is 3. Open
$p = $div->p();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $resource->getDbAdapter();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = $this->getPluginResource('db');
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $ul. Configured minimum length is 3. Open
if ($ul = $menuItem->toUl()) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $e. Configured minimum length is 3. Open
$e = new \Gems_Exception_Security($message, $code, null, $info);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $e. Configured minimum length is 3. Open
public function setException(exception $e)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The variable $GEMS_DIRS is not named in camelCase. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $GEMS_DIRS is not named in camelCase. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $GEMS_DIRS is not named in camelCase. Open
public function __construct($application)
{
parent::__construct($application);
self::$_instanceOfSelf = $this;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _ is not named in camelCase. Open
public function _($text, $locale = null)
{
if (! isset($this->request)) {
// Locale is fixed by request.
$this->setException(new \Gems_Exception_Coding('Requested translation before request was made available.'));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}