Function processForm
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
protected function processForm($saveLabel = null, $data = null)
{
$model = $this->getModel();
$mname = $model->getName();
$request = $this->getRequest();
- 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 BrowseEditAction.php
has 564 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
*
* @package Gems
Gems_Controller_BrowseEditAction
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Gems_Controller_BrowseEditAction extends \Gems_Controller_ModelActionAbstract
{
const RESET_PARAM = 'reset';
const SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON';
Function getAutoSearchForm
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
protected function getAutoSearchForm($targetId)
{
if ($this->autoFilter) {
$model = $this->getModel();
$data = $this->getCachedRequestData();
- 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 processForm
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processForm($saveLabel = null, $data = null)
{
$model = $this->getModel();
$mname = $model->getName();
$request = $this->getRequest();
The class Gems_Controller_BrowseEditAction has 14 public methods. Consider refactoring Gems_Controller_BrowseEditAction to keep number of public methods under 10. Open
abstract class Gems_Controller_BrowseEditAction extends \Gems_Controller_ModelActionAbstract
{
const RESET_PARAM = 'reset';
const SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON';
- 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
The class Gems_Controller_BrowseEditAction has an overall complexity of 141 which is very high. The configured complexity threshold is 50. Open
abstract class Gems_Controller_BrowseEditAction extends \Gems_Controller_ModelActionAbstract
{
const RESET_PARAM = 'reset';
const SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON';
- Exclude checks
Function getAfterSaveRoute
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function getAfterSaveRoute($data) {
if ($currentItem = $this->menu->getCurrent()) {
$controller = $this->_getParam('controller');
$url = null;
- 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 _createTable
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function _createTable()
{
$model = $this->getModel();
$request = $this->getRequest();
$search = $this->getCachedRequestData(false);
- 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 beforeFormDisplay
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function beforeFormDisplay ($form, $isNew)
{
if ($this->useTabbedForms || $form instanceof \Gems_Form_TableForm) {
//If needed, add a row of link buttons to the bottom of the form
if ($links = $this->createMenuLinks($isNew ? $this->menuCreateIncludeLevel : $this->menuEditIncludeLevel)) {
- 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 getAutoSearchForm
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getAutoSearchForm($targetId)
{
if ($this->autoFilter) {
$model = $this->getModel();
$data = $this->getCachedRequestData();
The class Gems_Controller_BrowseEditAction has 19 fields. Consider redesigning Gems_Controller_BrowseEditAction to keep the number of fields under 15. Open
abstract class Gems_Controller_BrowseEditAction extends \Gems_Controller_ModelActionAbstract
{
const RESET_PARAM = 'reset';
const SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON';
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method _createTable
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _createTable()
{
$model = $this->getModel();
$request = $this->getRequest();
$search = $this->getCachedRequestData(false);
Function getCachedRequestData
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getCachedRequestData($includeDefaults = true, $sourceAction = null, $readonly = false, $filterEmpty = true)
{
if (! $this->requestCache) {
$this->requestCache = $this->util->getRequestCache($sourceAction, $readonly);
$this->requestCache->setMenu($this->menu);
- 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 getAfterSaveRoute
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAfterSaveRoute($data) {
if ($currentItem = $this->menu->getCurrent()) {
$controller = $this->_getParam('controller');
$url = null;
Method beforeFormDisplay
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function beforeFormDisplay ($form, $isNew)
{
if ($this->useTabbedForms || $form instanceof \Gems_Form_TableForm) {
//If needed, add a row of link buttons to the bottom of the form
if ($links = $this->createMenuLinks($isNew ? $this->menuCreateIncludeLevel : $this->menuEditIncludeLevel)) {
Function _createSelectElement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _createSelectElement($name, $options, $empty = null)
{
if ($options instanceof \MUtil_Model_ModelAbstract) {
$options = $options->get($name, 'multiOptions');
} elseif (is_string($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 indexAction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function indexAction()
{
// \MUtil_Model::$verbose = true;
$this->setPageTitle($this->getTopicTitle(), array('class' => 'title'));
- 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 getAfterSaveRoute() has an NPath complexity of 325. The configured NPath complexity threshold is 200. Open
public function getAfterSaveRoute($data) {
if ($currentItem = $this->menu->getCurrent()) {
$controller = $this->_getParam('controller');
$url = null;
- 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 processForm() has an NPath complexity of 20412. The configured NPath complexity threshold is 200. Open
protected function processForm($saveLabel = null, $data = null)
{
$model = $this->getModel();
$mname = $model->getName();
$request = $this->getRequest();
- 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 processForm() has 131 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function processForm($saveLabel = null, $data = null)
{
$model = $this->getModel();
$mname = $model->getName();
$request = $this->getRequest();
- Exclude checks
The method getAutoSearchForm() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
protected function getAutoSearchForm($targetId)
{
if ($this->autoFilter) {
$model = $this->getModel();
$data = $this->getCachedRequestData();
- 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 processForm() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10. Open
protected function processForm($saveLabel = null, $data = null)
{
$model = $this->getModel();
$mname = $model->getName();
$request = $this->getRequest();
- 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 beforeFormDisplay() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function beforeFormDisplay ($form, $isNew)
{
if ($this->useTabbedForms || $form instanceof \Gems_Form_TableForm) {
//If needed, add a row of link buttons to the bottom of the form
if ($links = $this->createMenuLinks($isNew ? $this->menuCreateIncludeLevel : $this->menuEditIncludeLevel)) {
- 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 getAfterSaveRoute() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function getAfterSaveRoute($data) {
if ($currentItem = $this->menu->getCurrent()) {
$controller = $this->_getParam('controller');
$url = null;
- 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 Gems_Controller_BrowseEditAction has a coupling between objects value of 25. Consider to reduce the number of dependencies under 13. Open
abstract class Gems_Controller_BrowseEditAction extends \Gems_Controller_ModelActionAbstract
{
const RESET_PARAM = 'reset';
const SEARCH_BUTTON = 'AUTO_SEARCH_TEXT_BUTTON';
- 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
Avoid unused parameters such as '$data'. Open
protected function getAutoSearchElements(\MUtil_Model_ModelAbstract $model, array $data)
- 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 parameters such as '$useStored'. Open
protected function _applySearchParameters(\MUtil_Model_ModelAbstract $model, $useStored = false)
- 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 parameters such as '$isNew'. Open
public function beforeSave(array &$data, $isNew, \Zend_Form $form = null)
- 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 parameters such as '$data'. Open
public function afterFormLoad(array &$data, $isNew)
- 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 parameters such as '$data'. Open
public function beforeSave(array &$data, $isNew, \Zend_Form $form = null)
- 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 parameters such as '$form'. Open
public function beforeSave(array &$data, $isNew, \Zend_Form $form = null)
- 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 parameters such as '$data'. Open
protected function getDataFilter(array $data)
- 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 '$linksCell'. Open
$linksCell = $table->tf($links);
- 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 '$model'. Open
protected function getAutoSearchSubmit(\MUtil_Model_ModelAbstract $model, \MUtil_Form $form)
- 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 parameters such as '$model'. Open
protected function addExcelColumns(\MUtil_Model_ModelAbstract $model) {}
- 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 parameters such as '$isNew'. Open
public function afterSave(array $data, $isNew)
- 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 parameters such as '$data'. Open
public function afterSave(array $data, $isNew)
- 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 parameters such as '$form'. Open
public function onFakeSubmit(&$form, &$data) {
- 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 parameters such as '$isNew'. Open
public function afterFormLoad(array &$data, $isNew)
- 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
TODO found Open
// TODO: Elementen automatisch toevoegen in \MUtil_Form
- Exclude checks
Avoid excessively long variable names like $menuCreateIncludeLevel. Keep variable name length under 20. Open
public $menuCreateIncludeLevel = 0;
- 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 $menuIndexIncludeLevel. Keep variable name length under 20. Open
public $menuIndexIncludeLevel = 4;
- 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 variables with short names like $id. Configured minimum length is 3. Open
$id = 'autofilter_target';
- 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;
}
}
}