Function AnalyzeTable
has a Cognitive Complexity of 180 (exceeds 5 allowed). Consider refactoring. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- 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 QDatabaseCodeGen.class.php
has 1020 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
require(__QCUBED_CORE__ . '/codegen/QSqlColumn.class.php');
require(__QCUBED_CORE__ . '/codegen/QIndex.class.php');
require(__QCUBED_CORE__ . '/codegen/QManyToManyReference.class.php');
require(__QCUBED_CORE__ . '/codegen/QReference.class.php');
Function AnalyzeDatabase
has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- 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 __construct
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($objSettingsXml) {
parent::__construct($objSettingsXml);
// Make settings file accessible to templates
//$this->objSettingsXml = $objSettingsXml;
- 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 AnalyzeTable
has 220 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
Method __construct
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($objSettingsXml) {
parent::__construct($objSettingsXml);
// Make settings file accessible to templates
//$this->objSettingsXml = $objSettingsXml;
Function AnalyzeAssociationTable
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
- 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 AnalyzeAssociationTable
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
Function GenerateAll
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function GenerateAll() {
$strReport = '';
// Iterate through all the tables, generating one class at a time
if ($this->objTableArray) foreach ($this->objTableArray as $objTable) {
- 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 QDatabaseCodeGen has an overall complexity of 273 which is very high. The configured complexity threshold is 50. Open
class QDatabaseCodeGen extends QCodeGen {
public $objSettingsXml; // Make public so templates can use it directly.
// Objects
/** @var array|QSqlTable[] Array of tables in the database */
- Exclude checks
Method AnalyzeDatabase
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
QDatabaseCodeGen
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class QDatabaseCodeGen extends QCodeGen {
public $objSettingsXml; // Make public so templates can use it directly.
// Objects
/** @var array|QSqlTable[] Array of tables in the database */
Method AnalyzeTypeTable
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function AnalyzeTypeTable(QTypeTable $objTypeTable) {
// Setup the Array of Reserved Words
$strReservedWords = explode(',', QCodeGen::PhpReservedWords);
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
Function AnalyzeTypeTable
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function AnalyzeTypeTable(QTypeTable $objTypeTable) {
// Setup the Array of Reserved Words
$strReservedWords = explode(',', QCodeGen::PhpReservedWords);
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- 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 GenerateAggregateHelper
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function GenerateAggregateHelper($objCodeGenArray) {
$strToReturn = array();
if (count($objCodeGenArray)) {
// Standard ORM Tables
- 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 GetForeignKeyForSqlRelationshipDefinition
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function GetForeignKeyForSqlRelationshipDefinition($strTableName, $strLine) {
$strMatches = array();
// Start
$strPattern = '/alter[\s]+table[\s]+';
Method AnalyzeTableColumn
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
The class QDatabaseCodeGen has 35 fields. Consider redesigning QDatabaseCodeGen to keep the number of fields under 15. Open
class QDatabaseCodeGen extends QCodeGen {
public $objSettingsXml; // Make public so templates can use it directly.
// Objects
/** @var array|QSqlTable[] Array of tables in the database */
- 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
Function AnalyzeTableColumn
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- 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 GetForeignKeysFromRelationshipsScript
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function GetForeignKeysFromRelationshipsScript($strTableName, $objForeignKeyArray) {
foreach ($this->strRelationshipLinesQcubed as $strLine) {
if ($strLine) {
$objForeignKey = $this->GetForeignKeyForQcubedRelationshipDefinition($strTableName, $strLine);
- 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 ValidateTableColumn
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function ValidateTableColumn($strTableName, $strColumnName) {
$strTableName = trim(strtolower($strTableName));
$strColumnName = trim(strtolower($strColumnName));
if (array_key_exists($strTableName, $this->objTableArray))
- 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 GenerateAggregateHelper
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function GenerateAggregateHelper($objCodeGenArray) {
$strToReturn = array();
if (count($objCodeGenArray)) {
// Standard ORM Tables
Function GetForeignKeyForSqlRelationshipDefinition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function GetForeignKeyForSqlRelationshipDefinition($strTableName, $strLine) {
$strMatches = array();
// Start
$strPattern = '/alter[\s]+table[\s]+';
- 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 deeply nested control flow statements. Open
if (($strLine) &&
(substr($strLine, 0, 2) != '//') &&
(substr($strLine, 0, 2) != '--') &&
(substr($strLine, 0, 1) != '#')) {
$strLine = str_replace(' ', ' ', $strLine);
Avoid deeply nested control flow statements. Open
if ($objIndex->Unique)
$objColumn->Unique = true;
Avoid deeply nested control flow statements. Open
if ((strpos($strCommand, 'alter table') === 0) &&
(strpos($strCommand, 'foreign key') !== false))
$this->strRelationshipLinesSql[$strCommand] = $strCommand;
Method GetForeignKeyHelper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function GetForeignKeyHelper($strLine, $strFkName, $strTableName, $strColumnName, $strReferencedTable, $strReferencedColumn) {
Avoid too many return
statements within this method. Open
return ('$mixVal = (' . $objColumn->VariableType . ')$mixVal;');
Avoid too many return
statements within this method. Open
return $this->blnPrivateColumnVars;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return parent::__get($strName);
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return ('$mixVal = new QDateTime($mixVal, null, QDateTime::TimeOnlyType);');
Avoid too many return
statements within this method. Open
return $this->blnAutoInitialize;
The class QDatabaseCodeGen has 1430 lines of code. Current threshold is 1000. Avoid really long classes. Open
class QDatabaseCodeGen extends QCodeGen {
public $objSettingsXml; // Make public so templates can use it directly.
// Objects
/** @var array|QSqlTable[] Array of tables in the database */
- Exclude checks
The method AnalyzeAssociationTable() has 144 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
- Exclude checks
The method __construct() has 157 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function __construct($objSettingsXml) {
parent::__construct($objSettingsXml);
// Make settings file accessible to templates
//$this->objSettingsXml = $objSettingsXml;
- Exclude checks
The method AnalyzeDatabase() has 132 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- Exclude checks
The method AnalyzeAssociationTable() has an NPath complexity of 388800. The configured NPath complexity threshold is 200. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
- 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 AnalyzeDatabase() has an NPath complexity of 3409776. The configured NPath complexity threshold is 200. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- 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 an NPath complexity of 2304. The configured NPath complexity threshold is 200. Open
public function __construct($objSettingsXml) {
parent::__construct($objSettingsXml);
// Make settings file accessible to templates
//$this->objSettingsXml = $objSettingsXml;
- 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 AnalyzeTypeTable() has an NPath complexity of 342. The configured NPath complexity threshold is 200. Open
protected function AnalyzeTypeTable(QTypeTable $objTypeTable) {
// Setup the Array of Reserved Words
$strReservedWords = explode(',', QCodeGen::PhpReservedWords);
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- 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 AnalyzeTable() has an NPath complexity of 1711886400. The configured NPath complexity threshold is 200. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- 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 AnalyzeTable() has 323 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- Exclude checks
The method AnalyzeDatabase() has a Cyclomatic Complexity of 39. The configured cyclomatic complexity threshold is 10. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- 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 AnalyzeAssociationTable() has a Cyclomatic Complexity of 26. The configured cyclomatic complexity threshold is 10. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
- 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 __construct() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10. Open
public function __construct($objSettingsXml) {
parent::__construct($objSettingsXml);
// Make settings file accessible to templates
//$this->objSettingsXml = $objSettingsXml;
- 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 GetCastString() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function GetCastString (QSqlColumn $objColumn) {
switch ($objColumn->DbType) {
case QDatabaseFieldType::Bit:
return ('$mixVal = (bool)$mixVal;');
- 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 AnalyzeTableColumn() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- 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 AnalyzeTypeTable() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
protected function AnalyzeTypeTable(QTypeTable $objTypeTable) {
// Setup the Array of Reserved Words
$strReservedWords = explode(',', QCodeGen::PhpReservedWords);
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- 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 AnalyzeTable() has a Cyclomatic Complexity of 57. The configured cyclomatic complexity threshold is 10. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- 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
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
($objField->Name != $objManyToManyReferenceArray[1]->Column)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
if (($objField->Name != $objManyToManyReferenceArray[0]->Column) &&
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$strTableWithReference = $objManyToManyReferenceArray[($intIndex == 0) ? 1 : 0]->AssociatedTable;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReferenceArray[0]->ColumnArray = $objColumnArray;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReferenceArray[0] = new QManyToManyReference();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReferenceArray[1] = new QManyToManyReference();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReference = $objManyToManyReferenceArray[$intIndex];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReferenceArray[1]->ColumnArray = $objColumnArray;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$objManyToManyReferenceArray' which will lead to PHP notices. Open
$objManyToManyReference = $objManyToManyReferenceArray[$intIndex];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The class QDatabaseCodeGen has a coupling between objects value of 18. Consider to reduce the number of dependencies under 13. Open
class QDatabaseCodeGen extends QCodeGen {
public $objSettingsXml; // Make public so templates can use it directly.
// Objects
/** @var array|QSqlTable[] Array of tables in the database */
- 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
Missing class import via use statement (line '87', column '14'). Open
throw new QCallerException(sprintf('Table does not exist or could not be processed: %s. %s', $strTableName, $this->strErrors));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '100', column '14'). Open
throw new QCallerException(sprintf('Column does not exist in %s: %s', $strTableName, $strColumnName));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '494', column '24'). Open
$objTable = new QSqlTable($strTableName);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '391', column '42'). Open
$this->objModelConnectorOptions = new QModelConnectorOptions();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '603', column '42'). Open
$objManyToManyReferenceArray[0] = new QManyToManyReference();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '475', column '28'). Open
$objTypeTable = new QTypeTable($strTableName);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '604', column '42'). Open
$objManyToManyReferenceArray[1] = new QManyToManyReference();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '1422', column '16'). Open
throw new QCallerException('The field objSettingsXml is deprecated');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '842', column '21'). Open
$objIndex = new QIndex();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '1012', column '36'). Open
$objReverseReference = new QReverseReference();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '948', column '24'). Open
$objIndex = new QIndex();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '887', column '24'). Open
$objIndex = new QIndex();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '970', column '28'). Open
$objReference = new QReference();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '1113', column '21'). Open
$objColumn = new QSqlColumn();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '1298', column '15'). Open
return new QDatabaseForeignKey($strFkName, array($strColumnName), $strReferencedTable, array($strReferencedColumn));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '1389', column '16'). Open
throw new Exception ('Invalid database field type');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strExcludePattern = QCodeGen::LookupSetting($objSettingsXml, 'excludeTables', 'pattern');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strRelationshipsScriptFormat = QCodeGen::LookupSetting($objSettingsXml, 'relationshipsScript', 'format');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->blnManualQuerySupport = QCodeGen::LookupSetting($objSettingsXml, 'manualQuery', 'support', QType::Boolean);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strClassSuffix = QCodeGen::LookupSetting($objSettingsXml, 'className', 'suffix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->intDatabaseIndex = QCodeGen::LookupSetting($objSettingsXml, null, 'index', QType::Integer);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$strTypeTableSuffixList = QCodeGen::LookupSetting($objSettingsXml, 'typeTableIdentifier', 'suffix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$strExcludeList = QCodeGen::LookupSetting($objSettingsXml, 'excludeTables', 'list');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strRelationships = QCodeGen::LookupSetting($objSettingsXml, 'relationships');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strStripTablePrefix = QCodeGen::LookupSetting($objSettingsXml, 'stripFromTableName', 'prefix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method AnalyzeAssociationTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
$objKeyColumn = false; // multiple key columns
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->blnPrivateColumnVars = QCodeGen::LookupSetting($objSettingsXml, 'createOptions', 'privateColumnVars', QType::Boolean);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->blnAutoInitialize = QCodeGen::LookupSetting($objSettingsXml, 'createOptions', 'autoInitialize', QType::Boolean);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strClassPrefix = QCodeGen::LookupSetting($objSettingsXml, 'className', 'prefix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strAssociationTableSuffix = QCodeGen::LookupSetting($objSettingsXml, 'associationTableIdentifier', 'suffix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strAssociatedObjectPrefix = QCodeGen::LookupSetting($objSettingsXml, 'associatedObjectName', 'prefix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strIncludePattern = QCodeGen::LookupSetting($objSettingsXml, 'includeTables', 'pattern');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strRelationshipsScriptPath = QCodeGen::LookupSetting($objSettingsXml, 'relationshipsScript', 'filepath');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strAssociatedObjectSuffix = QCodeGen::LookupSetting($objSettingsXml, 'associatedObjectName', 'suffix');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$strIncludeList = QCodeGen::LookupSetting($objSettingsXml, 'includeTables', 'list');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method AnalyzeDatabase uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// If we're here, then we want to exclude this table
$this->strExcludedTableArray[strtolower($strTableName)] = true;
// Exit this iteration of the foreach loop
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeAssociationTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$strGraphPrefixArray = array('', '');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->blnGenerateControlId = QCodeGen::LookupSetting($objSettingsXml, 'generateControlId', 'support', QType::Boolean);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method AnalyzeDatabase uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// Create a Regular Table and add it to the array
$objTable = new QSqlTable($strTableName);
$this->objTableArray[strtolower($strTableName)] = $objTable;
// _p("Table: $strTableName<br />", false);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QCodeGen' in method '__construct'. Open
$this->strCommentConnectorLabelDelimiter = QCodeGen::LookupSetting($objSettingsXml, 'columnCommentForModelConnector', 'delimiter');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
$strScript = strtolower(trim(file_get_contents($this->strRelationshipsScriptPath)));
switch (strtolower($this->strRelationshipsScriptFormat)) {
case 'qcubed':
$strLines = explode("\n", $strScript);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid assigning values to variables in if clauses and the like (line '936', column '8'). Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '940', column '11'). Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$objReference->IsType = false;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->strErrors .= sprintf("Foreign Key %s in table %s indexes on a column that does not appear to exist.\n",
$objForeignKey->KeyName, $strTableName);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid assigning values to variables in if clauses and the like (line '1146', column '6'). Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'QCodeGen' in method 'AnalyzeTypeTable'. Open
$strFieldName = QCodeGen::TypeColumnPropertyName($objFieldArray[$i]->Name);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
// Make sure the column in the FK definition actually exists in this table
$strColumnName = $objForeignKey->ColumnNameArray[0];
if (array_key_exists(strtolower($strColumnName), $objTable->ColumnArray) &&
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->strErrors .= sprintf("Table '%s' can only contain characters that are alphanumeric or _, and must not begin with a number.\r\n", $strTableName);
unset($this->objTableArray[strtolower($strTableName)]);
return;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QType' in method 'AnalyzeTableColumn'. Open
$objColumn->VariableTypeAsConstant = QType::Constant($objColumn->VariableType);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'QCodeGen' in method 'GenerateControlId'. Open
$strLabelName = QCodeGen::ModelConnectorControlName($objColumn);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// Otherwise, add a warning
$this->strErrors .= sprintf("Index %s in table %s indexes on the column %s, which does not appear to exist.\n",
$objDatabaseIndex->KeyName, $strTableName, $strColumnName);
$blnFailed = true;
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->strErrors .= sprintf("Foreign Key %s in table %s references a table %s that does not appear to exist.\n",
$objForeignKey->KeyName, $strTableName, $objForeignKey->ReferenceTableName);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid assigning values to variables in if clauses and the like (line '1145', column '6'). Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method AnalyzeTableColumn uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$objColumn->Comment = $strComment;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
// Ensure every column exist in the DbIndex's ColumnNameArray
$blnFailed = false;
foreach ($objArray = $objDatabaseIndex->ColumnNameArray as $strColumnName) {
if (array_key_exists(strtolower($strColumnName), $objTable->ColumnArray) &&
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->strErrors .= sprintf("Table '%s' has an invalid column name: '%s'\r\n", $strTableName, $strColumnName);
unset($this->objTableArray[strtolower($strTableName)]);
return;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'QConvertNotation' in method 'AnalyzeTable'. Open
$objReverseReference->ObjectMemberVariable = QConvertNotation::PrefixFromType(QType::Object) . $objReverseReference->VariableType;
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '1144', column '9'). Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
The method GetForeignKeyForSqlRelationshipDefinition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->strErrors .= sprintf("Could not parse Relationships Script reference: %s (Not in ANSI SQL Format)\r\n", $strLine);
$this->strRelationshipLinesSql[$strLine] = null;
return null;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method AnalyzeTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
$objKeyColumn = false; // multiple key columns
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused local variables such as '$strObjectName'. Open
$strObjectName = $this->ModelVariableName($objTable->Name);
- 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 local variables such as '$strLabelName'. Open
$strLabelName = QCodeGen::ModelConnectorControlName($objColumn);
- 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
The method GetCastString() contains an exit expression. Open
exit;
- 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 using count() function in for loops. Open
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Avoid using count() function in for loops. Open
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- Read upRead up
- Exclude checks
CountInLoopExpression
Since: 2.7.0
Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.
Example
class Foo {
public function bar()
{
$array = array();
for ($i = 0; count($array); $i++) {
// ...
}
}
}
Source https://phpmd.org/rules/design.html#countinloopexpression
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($strLines) foreach ($strLines as $strLine) {
$strLine = trim($strLine);
if (($strLine) &&
(strlen($strLine) > 2) &&
- 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 121.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($strLines) foreach ($strLines as $strLine) {
$strLine = trim($strLine);
if (($strLine) &&
(strlen($strLine) > 2) &&
- 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 121.
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
Avoid excessively long variable names like $strRelationshipLinesQcubed. Keep variable name length under 20. Open
protected $strRelationshipLinesQcubed = array();
- 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 $intTypeTableSuffixLengthArray. Keep variable name length under 20. Open
protected $intTypeTableSuffixLengthArray;
- 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 $strAssociationTableName. Keep variable name length under 20. Open
if ($this->strAssociationTableNameArray) foreach ($this->strAssociationTableNameArray as $strAssociationTableName)
- 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 $strAssociationTableNameArray. Keep variable name length under 20. Open
protected $strAssociationTableNameArray;
- 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 $strAssociatedObjectPrefix. Keep variable name length under 20. Open
protected $strAssociatedObjectPrefix;
- 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 $strAssociatedObjectSuffix. Keep variable name length under 20. Open
protected $strAssociatedObjectSuffix;
- 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 $blnManualQuerySupport. Keep variable name length under 20. Open
protected $blnManualQuerySupport = false;
- 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 $strTableWithReference. Keep variable name length under 20. Open
$strTableWithReference = $objManyToManyReferenceArray[($intIndex == 0) ? 1 : 0]->AssociatedTable;
- 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 $objOppositeForeignKey. Keep variable name length under 20. Open
$objOppositeForeignKey = $objForeignKeyArray[($intIndex == 0) ? 1 : 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 $blnRelationshipsIgnoreCase. Keep variable name length under 20. Open
protected $blnRelationshipsIgnoreCase;
- 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 $objModelConnectorOptions. Keep variable name length under 20. Open
protected $objModelConnectorOptions;
- 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 $strCommentConnectorLabelDelimiter. Keep variable name length under 20. Open
protected $strCommentConnectorLabelDelimiter;
- 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 $strRelationshipsScriptFormat. Keep variable name length under 20. Open
protected $strRelationshipsScriptFormat;
- 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 $blnRelationshipsScriptIgnoreCase. Keep variable name length under 20. Open
protected $blnRelationshipsScriptIgnoreCase;
- 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 $intTypeTableSuffixLength. Keep variable name length under 20. Open
foreach ($this->intTypeTableSuffixLengthArray as $intIndex => $intTypeTableSuffixLength) {
- 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 $intStripTablePrefixLength. Keep variable name length under 20. Open
protected $intStripTablePrefixLength;
- 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 $strAssociationTableSuffix. Keep variable name length under 20. Open
protected $strAssociationTableSuffix;
- 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 $strRelationshipLinesSql. Keep variable name length under 20. Open
protected $strRelationshipLinesSql = array();
- 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 $objManyToManyReference. Keep variable name length under 20. Open
$objManyToManyReference = $objManyToManyReferenceArray[$intIndex];
- 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 $intAssociationTableSuffixLength. Keep variable name length under 20. Open
protected $intAssociationTableSuffixLength;
- 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 $strRelationshipsScriptPath. Keep variable name length under 20. Open
protected $strRelationshipsScriptPath;
- 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 $strExcludedTableArray. Keep variable name length under 20. Open
protected $strExcludedTableArray;
- 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 $strTypeTableSuffixArray. Keep variable name length under 20. Open
protected $strTypeTableSuffixArray;
- 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 $strTypeTableSuffixList. Keep variable name length under 20. Open
$strTypeTableSuffixList = QCodeGen::LookupSetting($objSettingsXml, 'typeTableIdentifier', 'suffix');
- 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 $strTypeTableSuffixArray. Keep variable name length under 20. Open
$strTypeTableSuffixArray = explode(',', $strTypeTableSuffixList);
- 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 $objManyToManyReferenceArray. Keep variable name length under 20. Open
$objManyToManyReferenceArray[0] = new QManyToManyReference();
- 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 $strReferencedTableName. Keep variable name length under 20. Open
$strReferencedTableName = $objForeignKey->ReferenceTableName;
- 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 $strReferenceTableName. Keep variable name length under 20. Open
$strReferenceTableName = trim($strDestinationTokens[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 $strReferenceColumnName. Keep variable name length under 20. Open
$strReferenceColumnName = trim($strDestinationTokens[1]);
- 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 $strReferenceTableName. Keep variable name length under 20. Open
$strReferenceTableName = trim($strMatches[7]);
- 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 $strExtraPropertyArray. Keep variable name length under 20. Open
$strExtraPropertyArray = array();
- 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 $strReferenceColumnName. Keep variable name length under 20. Open
$strReferenceColumnName = trim($strMatches[8]);
- 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 = $strRowArray[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 $a. Configured minimum length is 3. Open
$a = json_decode($strJson, true);
- 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 $Database is not named in camelCase. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- 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 $Database is not named in camelCase. Open
public function GetTitle() {
if (!QApplication::$Database) {
return '';
}
- 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 ListOfColumnsFromTable is not named in camelCase. Open
protected function ListOfColumnsFromTable(QSqlTable $objTable) {
$strArray = array();
$objColumnArray = $objTable->ColumnArray;
if ($objColumnArray) foreach ($objColumnArray as $objColumn)
array_push($strArray, $objColumn->Name);
- 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() {
}
}
Source
The method GenerateAggregateHelper is not named in camelCase. Open
public static function GenerateAggregateHelper($objCodeGenArray) {
$strToReturn = array();
if (count($objCodeGenArray)) {
// Standard ORM Tables
- 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() {
}
}
Source
The method GetConfigXml is not named in camelCase. Open
public function GetConfigXml() {
$strCrLf = "\r\n";
$strToReturn = sprintf(' <database index="%s">%s', $this->intDatabaseIndex, $strCrLf);
$strToReturn .= sprintf(' <className prefix="%s" suffix="%s"/>%s', $this->strClassPrefix, $this->strClassSuffix, $strCrLf);
$strToReturn .= sprintf(' <associatedObjectName prefix="%s" suffix="%s"/>%s', $this->strAssociatedObjectPrefix, $this->strAssociatedObjectSuffix, $strCrLf);
- 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() {
}
}
Source
The method GetColumnArray is not named in camelCase. Open
protected function GetColumnArray(QSqlTable $objTable, $strColumnNameArray) {
$objToReturn = array();
if ($strColumnNameArray) foreach ($strColumnNameArray as $strColumnName) {
array_push($objToReturn, $objTable->ColumnArray[strtolower($strColumnName)]);
- 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() {
}
}
Source
The method GetReportLabel is not named in camelCase. Open
public function GetReportLabel() {
// Setup Report Label
$intTotalTableCount = count($this->objTableArray) + count($this->objTypeTableArray);
if ($intTotalTableCount == 0)
$strReportLabel = 'There were no tables available to attempt code generation.';
- 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() {
}
}
Source
The method GetTable is not named in camelCase. Open
public function GetTable($strTableName) {
$strTableName = strtolower($strTableName);
if (array_key_exists($strTableName, $this->objTableArray))
return $this->objTableArray[$strTableName];
if (array_key_exists($strTableName, $this->objTypeTableArray))
- 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() {
}
}
Source
The method ValidateTableColumn is not named in camelCase. Open
public function ValidateTableColumn($strTableName, $strColumnName) {
$strTableName = trim(strtolower($strTableName));
$strColumnName = trim(strtolower($strColumnName));
if (array_key_exists($strTableName, $this->objTableArray))
- 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() {
}
}
Source
The method GenerateAll is not named in camelCase. Open
public function GenerateAll() {
$strReport = '';
// Iterate through all the tables, generating one class at a time
if ($this->objTableArray) foreach ($this->objTableArray as $objTable) {
- 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() {
}
}
Source
The method AnalyzeAssociationTable is not named in camelCase. Open
protected function AnalyzeAssociationTable($strTableName) {
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Association tables must have 2 fields
if (count($objFieldArray) != 2) {
- 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() {
}
}
Source
The method GetTitle is not named in camelCase. Open
public function GetTitle() {
if (!QApplication::$Database) {
return '';
}
- 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() {
}
}
Source
The method GenerateTypeTable is not named in camelCase. Open
public function GenerateTypeTable(QTypeTable $objTypeTable) {
// Create Argument Array
$mixArgumentArray = array('objTypeTable' => $objTypeTable);
return $this->GenerateFiles('db_type', $mixArgumentArray);
}
- 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() {
}
}
Source
The method GetColumn is not named in camelCase. Open
public function GetColumn($strTableName, $strColumnName) {
try {
$objTable = $this->GetTable($strTableName);
} catch (QCallerException $objExc) {
$objExc->IncrementOffset();
- 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() {
}
}
Source
The method GenerateTable is not named in camelCase. Open
public function GenerateTable(QSqlTable $objTable) {
// Create Argument Array
$mixArgumentArray = array('objTable' => $objTable);
return $this->GenerateFiles('db_orm', $mixArgumentArray);
}
- 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() {
}
}
Source
The method AnalyzeDatabase is not named in camelCase. Open
protected function AnalyzeDatabase() {
if (!QApplication::$Database) {
$this->strErrors = 'FATAL ERROR: No databases are listed in the configuration file.';
return;
}
- 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() {
}
}
Source
The method GetForeignKeyForSqlRelationshipDefinition is not named in camelCase. Open
protected function GetForeignKeyForSqlRelationshipDefinition($strTableName, $strLine) {
$strMatches = array();
// Start
$strPattern = '/alter[\s]+table[\s]+';
- 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() {
}
}
Source
The method AnalyzeTableColumn is not named in camelCase. Open
protected function AnalyzeTableColumn(QDatabaseFieldBase $objField, $objTable) {
$objColumn = new QSqlColumn();
$objColumn->Name = $objField->Name;
$objColumn->OwnerTable = $objTable;
if (substr_count($objField->Name, "-")) {
- 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() {
}
}
Source
The method StripPrefixFromTable is not named in camelCase. Open
protected function StripPrefixFromTable($strTableName) {
// If applicable, strip any StripTablePrefix from the table name
if ($this->intStripTablePrefixLength &&
(strlen($strTableName) > $this->intStripTablePrefixLength) &&
(substr($strTableName, 0, $this->intStripTablePrefixLength - strlen($strTableName)) == $this->strStripTablePrefix))
- 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() {
}
}
Source
The method AnalyzeTable is not named in camelCase. Open
protected function AnalyzeTable(QSqlTable $objTable) {
// Setup the Table Object
$objTable->OwnerDbIndex = $this->intDatabaseIndex;
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ModelClassName($strTableName);
- 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() {
}
}
Source
The method GetCastString is not named in camelCase. Open
public function GetCastString (QSqlColumn $objColumn) {
switch ($objColumn->DbType) {
case QDatabaseFieldType::Bit:
return ('$mixVal = (bool)$mixVal;');
- 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() {
}
}
Source
The method GetForeignKeysFromRelationshipsScript is not named in camelCase. Open
protected function GetForeignKeysFromRelationshipsScript($strTableName, $objForeignKeyArray) {
foreach ($this->strRelationshipLinesQcubed as $strLine) {
if ($strLine) {
$objForeignKey = $this->GetForeignKeyForQcubedRelationshipDefinition($strTableName, $strLine);
- 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() {
}
}
Source
The method GetForeignKeyHelper is not named in camelCase. Open
protected function GetForeignKeyHelper($strLine, $strFkName, $strTableName, $strColumnName, $strReferencedTable, $strReferencedColumn) {
// Make Sure Tables/Columns Exist, or display error otherwise
if (!$this->ValidateTableColumn($strTableName, $strColumnName)) {
$this->strErrors .= sprintf("Could not parse Relationships Script reference: \"%s\" (\"%s.%s\" does not exist)\r\n",
$strLine, $strTableName, $strColumnName);
- 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() {
}
}
Source
The method AnalyzeTypeTable is not named in camelCase. Open
protected function AnalyzeTypeTable(QTypeTable $objTypeTable) {
// Setup the Array of Reserved Words
$strReservedWords = explode(',', QCodeGen::PhpReservedWords);
for ($intIndex = 0; $intIndex < count($strReservedWords); $intIndex++)
$strReservedWords[$intIndex] = strtolower(trim($strReservedWords[$intIndex]));
- 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() {
}
}
Source
The method GenerateControlId is not named in camelCase. Open
public function GenerateControlId($objTable, $objColumn) {
$strControlId = null;
if (isset($objColumn->Options['ControlId'])) {
$strControlId = $objColumn->Options['ControlId'];
} elseif ($this->blnGenerateControlId) {
- 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() {
}
}
Source
The method GetForeignKeyForQcubedRelationshipDefinition is not named in camelCase. Open
protected function GetForeignKeyForQcubedRelationshipDefinition($strTableName, $strLine) {
$strTokens = explode('=>', $strLine);
if (count($strTokens) != 2) {
$this->strErrors .= sprintf("Could not parse Relationships Script reference: %s (Incorrect Format)\r\n", $strLine);
$this->strRelationshipLinesQcubed[$strLine] = null;
- 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() {
}
}