Showing 90 of 90 total issues
Function query
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public function query($queryString, $line = '', $file = '')
{
/* No empty queries, please, since PHP4 chokes on them. */
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
- 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 Db.php
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* MySQL Related Functionality
* @author Joe Huss <detain@interserver.net>
* @copyright 2019
Db
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Db extends Generic implements Db_Interface
{
/* public: this is an api revision, not a CVS revision. */
public $type = 'pgsql';
public $port = '';
Method query
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query($queryString, $line = '', $file = '')
{
/* No empty queries, please, since PHP4 chokes on them. */
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
Db
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Db extends Generic implements Db_Interface
{
/**
* @var string
*/
Function connect
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function connect($database = '', $host = '', $user = '', $password = '', $port = '')
{
/* Handle defaults */
if ($database == '') {
$database = $this->database;
- 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 connect
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($database = '', $host = '', $user = '', $password = '', $port = '')
{
/* Handle defaults */
if ($database == '') {
$database = $this->database;
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '')
{
$this->Type = $Type;
if (!defined('db')) {
switch ($this->Type) {
Avoid using undefined variables such as '$mysqli' which will lead to PHP notices. Open
$this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
- 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 '$mysqli' which will lead to PHP notices. Open
$this->halt("connect($host, $user, \$password) failed. ".$mysqli->connect_error);
- 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 '$success' which will lead to PHP notices. Open
$this->log("ADOdb Query $queryString (S:$success) - ".count($this->Rows).' Rows', __LINE__, __FILE__);
- 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 connect
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
{
/* Handle defaults */
if ('' == $database) {
$database = $this->database;
Method logBackTrace
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function logBackTrace($msg, $line = '', $file = '')
{
$backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []);
$this->log(
('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : '').
Function lock
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function lock($table, $mode = 'write')
{
$this->connect();
$query = 'lock tables ';
if (is_array($table)) {
- 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 10 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($Type = '', $database = '', $user = '', $password = '', $host = 'localhost', $query = '')
{
$this->Type = $Type;
if (!defined('db')) {
switch ($this->Type) {
- 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 connect
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function connect($database = '', $host = '', $user = '', $password = '', $driver = 'mysql')
{
/* Handle defaults */
if ('' == $database) {
$database = $this->database;
- 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 classes with short names like Db. Configured minimum length is 3. Open
class Db extends MysqliDb implements Db_Interface
{
public $host = 'localhost';
public $user = 'pdns';
public $password = '';
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Db. Configured minimum length is 3. Open
class Db extends Generic implements Db_Interface
{
/**
* @var string
*/
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Db. Configured minimum length is 3. Open
class Db extends Generic implements Db_Interface
{
/* public: connection parameters */
public $driver = 'mysql';
public $Rows = [];
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Db. Configured minimum length is 3. Open
class Db extends Generic implements Db_Interface
{
public $driver = 'mysql';
public $Rows = [];
public $type = 'adodb';
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}