SU-SWS/stanford_profile_helper

View on GitHub
stanford_profile_helper.module

Summary

Maintainability
Test Coverage

The function stanford_profile_helper_entity_field_access() has an NPath complexity of 240. The configured NPath complexity threshold is 200.
Wontfix

function stanford_profile_helper_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  if (
    $operation != 'view' &&
    $field_definition->getName() == 'status' &&
    $field_definition->getTargetEntityTypeId() == 'node' &&
Severity: Minor
Found in stanford_profile_helper.module by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

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

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

function stanford_profile_helper_search_api_algolia_objects_alter(array &$objects, IndexInterface $index, array $items) {
  /** @var \Drupal\config_pages\ConfigPagesLoaderServiceInterface $config_page_loader */
  $config_page_loader = \Drupal::service('config_pages.loader');

  // If the canonical url is set, use that to adjust the urls.
Severity: Minor
Found in stanford_profile_helper.module 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

The function stanford_profile_helper_entity_field_access() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
Wontfix

function stanford_profile_helper_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
  if (
    $operation != 'view' &&
    $field_definition->getName() == 'status' &&
    $field_definition->getTargetEntityTypeId() == 'node' &&
Severity: Minor
Found in stanford_profile_helper.module 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

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

function stanford_profile_helper_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  $list_types = [
    'entity_reference_list_label_class',
    'link_list_class',
    'list_string_list_class',
Severity: Minor
Found in stanford_profile_helper.module 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

Avoid using undefined variables such as '$themes' which will lead to PHP notices.
Open

  $themes['block__stanford_basic_search'] = [
Severity: Minor
Found in stanford_profile_helper.module by phpmd

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

Avoid using undefined variables such as '$themes' which will lead to PHP notices.
Open

  $themes['rabbit_hole_message'] = [
Severity: Minor
Found in stanford_profile_helper.module by phpmd

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

Avoid using undefined variables such as '$themes' which will lead to PHP notices.
Open

  return $themes;
Severity: Minor
Found in stanford_profile_helper.module by phpmd

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

Missing class import via use statement (line '297', column '24').
Open

  $example_start = new DateTime('today 8:00 AM');
Severity: Minor
Found in stanford_profile_helper.module by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

syntax error, unexpected '->' (T_OBJECT_OPERATOR)
Invalid

    $items?->getEntity()->getEntityTypeId() == 'node' &&
Severity: Critical
Found in stanford_profile_helper.module by phan

Avoid excessively long variable names like $stanford_profile_helper_403_page. Keep variable name length under 20.
Open

  $stanford_profile_helper_403_page = \Drupal::config('system.site')
Severity: Minor
Found in stanford_profile_helper.module by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $purgeInvalidationFactory. Keep variable name length under 20.
Wontfix

  $purgeInvalidationFactory = \Drupal::service('purge.invalidation.factory');
Severity: Minor
Found in stanford_profile_helper.module by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $stanford_profile_helper_404_page. Keep variable name length under 20.
Wontfix

  $stanford_profile_helper_404_page = \Drupal::config('system.site')
Severity: Minor
Found in stanford_profile_helper.module by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Expected 1 blank line after function; 2 found
Open

}

Object operator not indented correctly; expected 4 spaces but found 6
Open

      ->getName() == 'layout_selection') {

Expected 1 space before "?"; 0 found
Invalid

    $items?->getEntity()->getEntityTypeId() == 'node' &&

Possible parse error: CASE missing opening colon
Invalid

    case $stanford_profile_helper_403_page:

Only string literals should be passed to t() where possible
Wontfix

      $element['value']['#description'] = t($new_desc, $args);

Doc comment short description must end with a full stop
Open

 * stanford_profile_helper_helper.module

Variable $role is undefined.
Invalid

  return array_map(fn($role) => $role->label(), $roles);

Expected 1 space after "?"; 0 found
Invalid

    $items?->getEntity()->getEntityTypeId() == 'node' &&

Only string literals should be passed to t() where possible
Wontfix

      $form['container'][$source_field]['#description'] = t($new_desc, $args);

Expected 1 space after "?"; 0 found
Open

      $property_path = $index->getField($name)?->getPropertyPath() ?: '';

Expected 1 space before ":"; 0 found
Invalid

    case $stanford_profile_helper_403_page:

Line exceeds 80 characters; contains 82 characters
Open

      // in the UI. If cron is running, the current host won't match the canonical

Variable $role is undefined.
Invalid

  return array_map(fn($role) => $role->label(), $roles);

Doc comment short description must start with a capital letter
Open

 * stanford_profile_helper_helper.module

Expected 1 space before "?"; 0 found
Open

      $property_path = $index->getField($name)?->getPropertyPath() ?: '';

There are no issues that match your filters.

Category
Status