SU-HKKU/cardinal_service_profile

View on GitHub

Showing 66 of 150 total issues

Avoid assigning values to variables in if clauses and the like (line '106', column '11').
Open

  public function runTask(array &$install_state) {
    $this->state->set('nobots', FALSE);

    $node_pages = [
      '403_page' => '4b8018dc-49a6-4018-9c54-e8c3e462beee',

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

The function cardinal_service_profile_entity_field_access() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

function cardinal_service_profile_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  $route_match = \Drupal::routeMatch();

  // When the user is viwing the node detail page, hide some of the fields
  // based on other fields having some data.
Severity: Minor
Found in cardinal_service_profile.inc by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Class should be nested within its parent Type-selector
Open

.su-secondary-nav > ul > li.su-secondary-nav__item--parent:first-child{

Force Element Nesting

Rule force-element-nesting will enforce the nesting of elements

Examples

When enabled, the following are disallowed:

div p {
  content: '';
}

.parent {
  &__child h1 {
    content: '';
  }
}

a[target="_blank"] span {
  content: '';
}

When enabled, the following are allowed:

div {
  p {
    content: '';
  }
}

.parent {
  &__child {
    h1 {
      content: '';
    }
  }
}

a[target="_blank"] {
  span {
    content: '';
  }
}

Whitespace required before {
Open

.su-secondary-nav > ul > li.su-secondary-nav__item--parent:first-child{

Space Before Brace

Rule space-before-brace will enforce whether or not a space should be included before a brace ({).

Options

  • include: true/false (defaults to true)

Examples

When include: true, the following are allowed. When include: false, the following are disallowed:

.foo {
  content: 'bar';

  @include breakpoint {
    content: 'baz';
  }
}

@mixin foo {
  content: 'bar';
}

When include: false, the following are allowed. When include: true, the following are disallowed:

.foo{
  content: 'bar';

  @include breakpoint{
    content: 'baz';
  }
}

@mixin foo{
  content: 'bar';
}

Qualifying elements are not allowed for class selectors
Open

.su-secondary-nav > ul > li.su-secondary-nav__item--parent:first-child{

No Qualifying Elements

Rule no-qualifying-elements will enforce that selectors are not allowed to have qualifying elements.

Options

  • allow-element-with-attribute: true/false (defaults to false)
  • allow-element-with-class: true/false (defaults to false)
  • allow-element-with-id: true/false (defaults to false)

Examples

By default, the following are disallowed:

div.foo {
  content: 'foo';
}

ul#foo {
  content: 'foo';
}

input[type='email'] {
  content: 'foo';
}

allow-element-with-attribute

When allow-element-with-attribute: true, the following are allowed. When allow-element-with-attribute: false, the following are disallowed.

input[type='email'] {
  content: 'foo';
}

a[href] {
  content: 'foo';
}

allow-element-with-class

When allow-element-with-class: true, the following are allowed. When allow-element-with-class: false, the following are disallowed.

div.foo {
  content: 'foo';
}

h1.bar {
  content: 'foo';
}

allow-element-with-id

When allow-element-with-id: true, the following are allowed. When allow-element-with-id: false, the following are disallowed.

ul#foo {
  content: 'foo';
}

p#bar {
  content: 'foo';
}

TODO found
Open

    // @TODO: Update link when launch process guide is available.
Severity
Category
Status
Source
Language