Showing 137 of 137 total issues
Avoid excessively long variable names like $passwordRegularExpression. Keep variable name length under 20. Open
private static $passwordRegularExpression = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@!%*?&_-])[A-Za-z\d$@!%*?&_-]{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
Function applySettings
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applySettings() {
var username = $("#Username").val();
var name = $("#Name").val();
var surname = $("#Surname").val();
var mail = $("#Mail").val();
Avoid using undefined variables such as '$image' which will lead to PHP notices. Open
array_push($validImages, $image);
- 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 __construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function __construct(array $location)
{
echo '
<div id="' . $location['id_location'] . '" class="contentLocation">
<table style="width:100%" class="table" onclick="openlocation(' . $location['id_location'] . ', \'' . $location['name'] . '\')">
Function createLocation
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createLocation() {
var genericFormData = new FormData($("form")[1]);
$.ajax({
type: "POST",
Method updateSettings
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function updateSettings(string $newUsername, string $newName, string $newSurname, string $newMail, string $newPassword, string $newRepPassword, string $secret, string $authenticatorCode)
Avoid variables with short names like $to. Configured minimum length is 3. Open
public function loadLocations(int $from, int $to, string $nameFilter)
- 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 createLocation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function createLocation(int $idCreator, string $name, string $description, string $position){
if (strlen($name) < 50 && strlen($name) > 1 && strlen($description) < 100 && strlen($description) > 1) {
$inserted = $this->model->creatLocation($idCreator, $name, $description, $position);
if($inserted){
- 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 registerPerson
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function registerPerson(string $username, string $password, string $repeatPassword, string $surname, string $name, string $mail)
Method inputValid
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function inputValid(string $username, string $password, string $repeatPassword, string $surname, string $name, string $mail)
Method update
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function update(string $username, string $name, string $surname, string $mail, $password, $secret)
Method insert
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function insert(string $username, string $password, string $surname, string $name, string $mail)
Missing class import via use statement (line '28', column '33'). Open
$this->loginModel = new LoginModel();
- 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 '29', column '27'). Open
$loginModel = new LoginModel();
- 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 '25', column '30'). Open
$this->model = new LocationModel();
- 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 '24', column '22'). Open
$model = new EventModel();
- 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 '16', column '22'). Open
$model = new EventModel();
- 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 '27', column '28'). Open
$this->model = new EditSettingsModel();
- 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 '34', column '17'). Open
new DiscoverRowBuilder($location);
- 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 '24', column '28'). Open
$this->model = new LoginModel();
- 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();
}