Showing 720 of 720 total issues
Avoid variables with short names like $t. Configured minimum length is 3. Open
$t = explode(' ', $q);
- 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 $ip. Configured minimum length is 3. Open
public static function _get($ip, $type, $provider) {
- 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
Function sqlTypesString
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function sqlTypesString($fieldsList, $idFieldName = "") {
$typesString = "";
foreach ($fieldsList as $fieldName => $fieldValue) {
if ($fieldName != $idFieldName) {
if (Tools::isDouble($fieldValue)) {
- 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 getRedirectUrl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getRedirectUrl($url) {
$urlParts = @parse_url($url);
if (!$urlParts) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validateNotEmpty
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function validateNotEmpty($fieldName) {
$fieldValue = Request::getFieldValue($fieldName);
if (is_array($fieldValue)) {
foreach ($fieldValue as $value) {
$value = trim($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
Function getEmails
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getEmails($delete = true, $number = null) {
$emails = [];
for ($i = 1; (is_null($number) ? true : $i <= $number); $i++) {
$message = $this->getMessage($i);
- 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 open
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function open($host = "localhost", $port = 110, $username = "", $password = "") {
$sock = fsockopen($host, $port);
if ($sock) {
fgets($sock, 1024);
- 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 (!isset($array[$key]) || !is_array($array[$key])) {
break;
}
Function selectDBObjectsFromStatement
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function selectDBObjectsFromStatement($stmt, $className) {
if (is_object($className)) {
$className = get_class($className);
}
- 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 sendMail
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function sendMail($email, $subject, $message, $format = self::FORMAT_TEXT, $replyTo = "") {
Method prepare
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function prepare($query, $conditions = null, $order = null, $offset = null, $count = null) {
Method log
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function log($type, $called, $script, $line, $message) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($url = "", $pagesNumber = 1, $currentPage = 1, $pagesOffset = 3, $template = "") {
Method send
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function send($to, $subject, $message, $headers = [], $parameters = "") {
Function uniqueListing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function uniqueListing() {
fwrite($this->connection, "UIDL\r\n");
$response = "";
while (true) {
- 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 selectDBObjectFromStatement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function selectDBObjectFromStatement($stmt, $className) {
if (is_object($className)) {
$className = get_class($className);
}
- 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 selectSingleRecord
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function selectSingleRecord($query, $types = "", $params = []) {
if (!Tools::isInstanceOf($query, new DBPreparedQuery())) {
$dbQuery = new DBPreparedQuery($query, $types, $params);
} else {
$dbQuery = $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 parseHeader
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parseHeader($header) {
$avar = explode("\n", $header);
$len = count($avar);
$ret = $L2 = $L3 = null;
for ($i = 0; $i < $len; $i++) {
- 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 prepareOrder
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function prepareOrder() {
if (!empty($this->order)) {
$this->query.= " ORDER BY";
if (is_array($this->order)) {
foreach ($this->order as $fieldName => $ord) {
- 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 updateAvatar
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function updateAvatar($newAvatarFileName) {
$currentAvatarFileName = $this->avatar;
if (!empty($currentAvatarFileName) && file_exists(Config::DIR_AVATARS . $currentAvatarFileName)) {
unlink(Config::DIR_AVATARS . $currentAvatarFileName);
}
- 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"