Showing 168 of 168 total issues
Function fallback
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
public static function fallback( $args ) {
if ( current_user_can( 'manage_options' ) ) {
/* Get Arguments. */
$container = $args['container'];
- 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 fallback
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function fallback( $args ) {
if ( current_user_can( 'manage_options' ) ) {
/* Get Arguments. */
$container = $args['container'];
Method start_el
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
// Check if the link it disables Disabled, Active or regular menu item.
if ( stristr( $item->attr_title, 'disabled' ) ) {
The parameter $children_elements is not named in camelCase. Open
Open
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( ! $element ) {
return;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
Open
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
- 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
The class WP_Bootstrap_Navlist_Walker is not named in CamelCase. Open
Open
class WP_Bootstrap_Navlist_Walker extends Walker_Nav_Menu {
/**
* See Walker: start_lvl function.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The parameter $max_depth is not named in camelCase. Open
Open
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( ! $element ) {
return;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Method display_element
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
Method start_el
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
Expected 1 space before "?"; 3 found Open
Open
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
- Exclude checks
Spaces must be used for mid-line alignment; tabs are not allowed Open
Open
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
- Exclude checks
Spaces must be used for mid-line alignment; tabs are not allowed Open
Open
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
- Exclude checks
Expected 1 space before "?"; 5 found Open
Open
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
- Exclude checks
Visibility must be declared on method "end_lvl" Open
Open
function end_lvl( &$output, $depth = 0, $args = array() ) {
- Exclude checks
Spaces must be used for mid-line alignment; tabs are not allowed Open
Open
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
- Exclude checks
Expected 1 space before "?"; 5 found Open
Open
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
- Exclude checks
Concat operator must be surrounded by a single space Open
Open
} else { $item_output .= '<a'. $attributes .'>';
- Exclude checks
Spaces must be used for mid-line alignment; tabs are not allowed Open
Open
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
- Exclude checks
Spaces must be used for mid-line alignment; tabs are not allowed Open
Open
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space Open
Open
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
- Exclude checks