Showing 23 of 23 total issues
Avoid variables with short names like $v. Configured minimum length is 3. Open
Open
return array_map(function ($v) {
- 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 buildRequireArrayQuery
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
private function buildRequireArrayQuery($subclause, Builder $query)
{
if ($subclause['operator'] == 'IN') {
$query->whereIn($subclause['to_value_column'], $subclause['value']);
} elseif ($subclause['operator'] == 'NOT IN') {
- 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 makeArrayQueryIn
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private function makeArrayQueryIn(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
Method makeQueryWhenArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
protected function makeQueryWhenArray(EloquentBuilder|Builder $query, stdClass $rule, array $sqlOperator, array $value, $condition)
Method makeArrayQueryBetween
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private function makeArrayQueryBetween(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
The closing brace for the class must go on the next line after the body Open
Open
}
- Exclude checks
PHP keywords must be lowercase; expected "callable" but found "Callable" Open
Open
public function clean($field, Callable $callback = null)
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( $operator == 'NOT BETWEEN' ) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
function(Builder $query) use ($subclause) {
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
Open
}, $condition);
- Exclude checks
The method buildSubclauseWithNull has a boolean flag argument $isNotNull, which is a certain sign of a Single Responsibility Principle violation. Open
Open
private function buildSubclauseWithNull($subclause, Builder $query, $isNotNull = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Line exceeds 120 characters; contains 128 characters Open
Open
protected function convertIncomingQBtoQuery(EloquentBuilder|Builder $query, stdClass $rule, $value, $queryCondition = 'AND')
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
private function makeArrayQueryBetween(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
return $this->buildSubclauseWithNull($subclause, $query, ($subclause['operator'] == 'NOT NULL' ? true : false));
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
Open
protected function makeQueryWhenArray(EloquentBuilder|Builder $query, stdClass $rule, array $sqlOperator, array $value, $condition)
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
private function makeArrayQueryIn(EloquentBuilder|Builder $query, stdClass $rule, $operator, array $value, $condition)
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( $operator == 'NOT BETWEEN' ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
return $query->whereNotBetween( $rule->field, $value, $condition );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
return $query->whereNotBetween( $rule->field, $value, $condition );
- Exclude checks
The variable $_sql_op is not named in camelCase. Open
Open
private function buildSubclauseQuery($query, $rule, $value, $condition)
{
/*
* Convert the Operator (LIKE/NOT LIKE/GREATER THAN) given to us by QueryBuilder
* into on one that we can use inside the SQL query
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}