wp-bootstrap/wp-bootstrap-navlist-walker

View on GitHub

Showing 168 of 168 total issues

Function fallback has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function fallback( $args ) {
        if ( current_user_can( 'manage_options' ) ) {

                /* Get Arguments. */
                $container = $args['container'];
Severity: Minor
Found in wp-bootstrap-navlist-walker.php - About 1 hr to fix

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

    public static function fallback( $args ) {
        if ( current_user_can( 'manage_options' ) ) {

                /* Get Arguments. */
                $container = $args['container'];
Severity: Minor
Found in wp-bootstrap-navlist-walker.php - About 1 hr to fix

    Method start_el has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    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' ) ) {
    Severity: Minor
    Found in wp-bootstrap-navlist-walker.php - About 1 hr to fix

      The parameter $children_elements is not named in camelCase.
      Open

          public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
              if ( ! $element ) {
                  return;
              }
      
      
      Severity: Minor
      Found in wp-bootstrap-navlist-walker.php by phpmd

      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

          public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
      Severity: Minor
      Found in wp-bootstrap-navlist-walker.php by phpmd

      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

      class WP_Bootstrap_Navlist_Walker extends Walker_Nav_Menu {
      
          /**
           * See Walker: start_lvl function.
           *
      Severity: Minor
      Found in wp-bootstrap-navlist-walker.php by phpmd

      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

          public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
              if ( ! $element ) {
                  return;
              }
      
      
      Severity: Minor
      Found in wp-bootstrap-navlist-walker.php by phpmd

      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

          public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
      Severity: Minor
      Found in wp-bootstrap-navlist-walker.php - About 45 mins to fix

        Method start_el has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
        Severity: Minor
        Found in wp-bootstrap-navlist-walker.php - About 35 mins to fix

          Expected 1 space before "?"; 3 found
          Open

                  $atts['title']  = ! empty( $item->title )    ? $item->title    : '';

          Spaces must be used for mid-line alignment; tabs are not allowed
          Open

                  $atts['rel']    = ! empty( $item->xfn )        ? $item->xfn    : '';

          Spaces must be used for mid-line alignment; tabs are not allowed
          Open

                  $atts['rel']    = ! empty( $item->xfn )        ? $item->xfn    : '';

          Expected 1 space before "?"; 5 found
          Open

                  $atts['href']     = ! empty( $item->url )     ? $item->url : '';

          Visibility must be declared on method "end_lvl"
          Open

              function end_lvl( &$output, $depth = 0, $args = array() ) {

          Spaces must be used for mid-line alignment; tabs are not allowed
          Open

                  $atts['target'] = ! empty( $item->target )    ? $item->target    : '';

          Expected 1 space before "?"; 5 found
          Open

                  $atts['rel']    = ! empty( $item->xfn )        ? $item->xfn    : '';

          Concat operator must be surrounded by a single space
          Open

                  } else { $item_output .= '<a'. $attributes .'>';

          Spaces must be used for mid-line alignment; tabs are not allowed
          Open

                  $atts['title']  = ! empty( $item->title )    ? $item->title    : '';

          Spaces must be used for mid-line alignment; tabs are not allowed
          Open

                  $atts['title']  = ! empty( $item->title )    ? $item->title    : '';

          Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
          Open

                          $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
          Severity
          Category
          Status
          Source
          Language