Showing 1,039 of 1,039 total issues
Avoid using undefined variables such as '$FANNIE_SERVER' which will lead to PHP notices. Open
$this->connection = new \COREPOS\common\SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW, true);
- 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 '$index' which will lead to PHP notices. Open
$sql .= ', ADD ' . $index . ' (' . $this->connection->identifierEscape($this->columns[$col_name]) . ')';
- 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
Method normalizeRename
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function normalizeRename($db_name, $mode=BasicModel::NORMALIZE_MODE_CHECK)
{
$current = $this->connection->detailedDefinition($this->name);
$recase_columns = array();
foreach ($this->columns as $col_name => $definition) {
Method readRoutes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function readRoutes()
{
// routes begin with method
$this->__method = $this->detectMethod();
Function addConnection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
{
if (empty($type)) {
return false;
} elseif (strtolower($type) == 'postgres9') {
- 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 writeLog
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function writeLog($message, array $context, $intLevel)
{
$file = $this->getLogLocation($intLevel);
$verboseDebug = $this->verboseDebugging();
Method arrayToSQL
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function arrayToSQL($definition, $dbms)
{
$sql = '';
$type = $definition['type'];
if (isset($this->meta_types[strtoupper($type)])) {
Method log
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function log($level, $message, array $context = array())
{
switch ($this->normalizeLevel($level)) {
case \Psr\Log\LogLevel::EMERGENCY:
$this->emergency($message, $context);
Method log
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function log($level, $message, array $context = array())
{
switch ($this->normalizeLevel($level)) {
case 'emergency':
$this->emergency($message, $context);
Method toOptions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toOptions($selected=0, $id_as_label=false)
{
if (count($this->unique) != 1) {
return '';
}
Consider simplifying this complex logical expression. Open
if (($argc < 3 || $argc > 4) || ($argc == 3 && $argv[1] != "--new" && $argv[1] != '--new-view') || ($argc == 4 && $argv[1] != '--update')) {
echo "Create new Model: php BasicModel.php --new <Model Name>\n";
echo "Create new View Model: php BasicModel.php --new-view <Model Name>\n";
echo "Update Table Structure: php BasicModel.php --update <Database name> <Subclass Filename>\n";
echo "Generate markdown documentation: php BasicModel.php --doc <Model Filename(s)>\n";
Function getDrivers
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static public function getDrivers()
{
$ret = array();
if (extension_loaded('mysqli')) {
$ret['MYSQLI'] = 'MySQLi';
- 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 log
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function log($level, $message, array $context = array())
{
switch ($this->normalizeLevel($level)) {
case \Psr\Log\LogLevel::EMERGENCY:
$this->emergency($message, $context);
- 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 log
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function log($level, $message, array $context = array())
{
switch ($this->normalizeLevel($level)) {
case 'emergency':
$this->emergency($message, $context);
- 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 columnsDoc
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function columnsDoc()
{
$ret = str_pad('Name', 25, ' ') . '|' . str_pad('Type', 15, ' ') . '|Info' . "\n";
$ret .= str_repeat('-', 25) . '|' . str_repeat('-', 15) . '|' . str_repeat('-', 10) . "\n";
foreach ($this->columns as $name => $info) {
- 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 toOptions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function toOptions($selected=0, $id_as_label=false)
{
if (count($this->unique) != 1) {
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
Method addConnection
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($server,$type,$database,$username,$password='',$persistent=false, $new=false)
Avoid variables with short names like $l. Configured minimum length is 3. Open
static public function setLogger($l)
- 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 property $window_dressing is not named in camelCase. Open
class CorePage
{
public $description = "
Base class for creating HTML pages.
";
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}