Showing 720 of 720 total issues
Method go
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function go($debug = false) {
switch ($this->dbQuery->getType()) {
case (DBQueryType::SELECT):
$this->dbQuery->query = "SELECT * FROM " . static::TABLE_NAME;
break;
Function __construct
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($type = "", $name = "", $value = null) {
if (!(bool)preg_match("#^[a-zA-Z][a-zA-Z0-9_]*$#", $name)) {
throw new DBFieldException("Can't create DBField object: invalid field name '" . $name . "'");
}
$this->name = $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
Method curlRequestAsync
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function curlRequestAsync($url, $params, $type = self::POST, $timeout = 30) {
$postParams = [];
foreach ($params as $key => &$val) {
if (is_array($val)) {
$val = implode(',', $val);
Function filterBouncedEmails
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function filterBouncedEmails($emailData) {
$emails = [];
if (isset($emailData[0])) {
if (is_array($emailData[0])) {
- 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 showQueryDebugInfo
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function showQueryDebugInfo($query = "", $types = "", array $params = []) {
OutputStream::start();
if (!empty($query)) {
if (empty($types) && empty($params)) {
OutputStream::message(OutputStream::MSG_INFO, "Q: " . $query);
- 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 start
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function start($name = "", array $iniSettings = [], $useCookie = false,
$lifetime = null, $path = null, $domain = null, $secure = null, $httponly = null)
{
if (!empty($iniSettings)) {
foreach ($iniSettings as $key => $value) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getBouncedEmails
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getBouncedEmails($delete = true, $number = null) {
$emails = [];
for ($i = 1; (is_null($number) ? true : $i <= $number); $i++) {
$message = $this->getMessage($i);
Avoid excessively long variable names like $currentAvatarFileName. Keep variable name length under 20. Open
$currentAvatarFileName = $this->avatar;
- 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 $currentAvatarFileName. Keep variable name length under 20. Open
$currentAvatarFileName = $this->avatar;
- 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
Method __call
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __call($methodName, $methodParams) {
/*
* Selects DBObject record by some field value.
*
* @param <mixed> Value of the field
Method log
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function log($type, $message, $format = "\[Y-m-d H:i:s\]", $time = null) {
$msgType = null;
switch ($type) {
case (self::LOG_INFO):
$msgType = OutputStream::MSG_INFO;
Function initQuery
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function initQuery($queryType, $conditions = [], $fields = []) {
$this->dbQuery = new DBPreparedQuery();
$this->dbQuery->setType($queryType);
- 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 _get
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function _get($ip, $type, $provider) {
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
throw new LocationDetectorException("Invalid IP address.");
}
- 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 getFieldValue
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function getFieldValue($fieldName, $source = null) {
$value = null;
try {
switch ($source) {
- 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 using short method names like DBPreparedQuery::go(). The configured minimum method name length is 3. Open
public function go($debug = false) {
if ($debug) {
$this->debug();
} else {
if ($this->isSelector()) {
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like DBObject::go(). The configured minimum method name length is 3. Open
public function go($debug = false) {
switch ($this->dbQuery->getType()) {
case (DBQueryType::SELECT):
$this->dbQuery->query = "SELECT * FROM " . static::TABLE_NAME;
break;
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Method setFieldsValues
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setFieldsValues($valuesList) {
if (is_array($valuesList)) {
$count = 0;
foreach ($this->fieldsList as $fieldName => &$fieldValue) {
if (isset($valuesList[$fieldName])) {
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($type = "", $name = "", $value = null) {
if (!(bool)preg_match("#^[a-zA-Z][a-zA-Z0-9_]*$#", $name)) {
throw new DBFieldException("Can't create DBField object: invalid field name '" . $name . "'");
}
$this->name = $name;
Method friendlyErrorType
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function friendlyErrorType($type) {
switch($type) {
case E_ERROR: // 1
return 'E_ERROR';
case E_WARNING: // 2
Method getFieldValue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getFieldValue($fieldName, $source = null) {
$value = null;
try {
switch ($source) {