Showing 194 of 194 total issues
Avoid using undefined variables such as '$attached_model_filter' which will lead to PHP notices. Open
if (isset($attached_model_filter) && $attached_model_filter instanceof \Closure) {
- 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
Function getFilters
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFilters: function(search_table_id)
{
var search_table = $('#'+search_table_id);
var current_filters = {
Method validateOperators
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
Function getCurrentSearchDetails
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getCurrentSearchDetails($use_session, $settings, $options, $search_name)
{
if (request()->ajax()) {
$settings_data = request()->all();
} else {
- 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 variables with short names like $tr. Configured minimum length is 3. Open
$tr = $tbody->tr();
- 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 $tr. Configured minimum length is 3. Open
$tr = $tbody->tr();
- 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
Method checkSearchResults
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected static function checkSearchResults($table, $result, &$search_request, $name, $column_span = 1, $config = [])
Avoid deeply nested control flow statements. Open
if (in_array($check_operator, $available_operators)) {
$operator = $check_operator;
$value1 = implode(' ', $value1_array);
}
Avoid deeply nested control flow statements. Open
if (isset($settings['name'])) {
$filter_detail['name'] = $settings['name'].': '.$filter_detail['attribute_name'];
}
Method applyFilterAttributeArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static function applyFilterAttributeArray($query, $attribute_list, $method, $arguments, $positive = true)
Method returnSearchResult
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected static function returnSearchResult($controller_name, $distinct_session, $search_request, $response, $extra_response = false)
Method showSearchAppliedFilters
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected static function showSearchAppliedFilters(&$tbody, &$search_request, $result, $model, $column_span = 1)
Method scopeModelJoin
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
Function compose
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function compose(View $view)
{
$view_data = $view->getData();
if ($view_data['template']) {
- 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 getSearchAppliedFilters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected static function getSearchAppliedFilters($controller_name, $distinct_session = '', $use_session = false)
{
// Filter provided.
if (is_array($use_session)) {
- 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 too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
The method scopeModelJoin has a boolean flag argument $where, which is a certain sign of a Single Responsibility Principle violation. Open
public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = 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
Avoid too many return
statements within this method. Open
return true;