The function stanford_profile_helper_entity_field_access() has an NPath complexity of 280. 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' &&
- Read upRead up
- Exclude checks
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_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',
- Read upRead up
- Exclude checks
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 18. 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' &&
- Read upRead up
- Exclude checks
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_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.
- Read upRead up
- Exclude checks
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'] = [
- 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
Avoid using undefined variables such as '$themes' which will lead to PHP notices. Open
$themes['rabbit_hole_message'] = [
- 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
Avoid using undefined variables such as '$themes' which will lead to PHP notices. Open
return $themes;
- 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
Missing class import via use statement (line '282', column '24'). Open
$example_start = new DateTime('today 8:00 AM');
- Read upRead up
- Exclude checks
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)
Open
if (!$node->isPublished() && $node->original?->isPublished() && \Drupal::hasService('search_api_algolia.helper')) {
- Exclude checks
Avoid excessively long variable names like $purgeInvalidationFactory. Keep variable name length under 20. Wontfix
$purgeInvalidationFactory = \Drupal::service('purge.invalidation.factory');
- Read upRead up
- Exclude checks
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_403_page. Keep variable name length under 20. Open
$stanford_profile_helper_403_page = \Drupal::config('system.site')
- Read upRead up
- Exclude checks
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')
- Read upRead up
- Exclude checks
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 space after "?"; 0 found Open
if (!$node->isPublished() && $node->original?->isPublished() && \Drupal::hasService('search_api_algolia.helper')) {
- Exclude checks
Expected 1 space before "?"; 0 found Open
if (!$node->isPublished() && $node->original?->isPublished() && \Drupal::hasService('search_api_algolia.helper')) {
- Exclude checks
Doc comment short description must end with a full stop Open
* stanford_profile_helper_helper.module
- Exclude checks
Expected 1 space before "?"; 0 found Invalid
$items?->getEntity()->getEntityTypeId() == 'node' &&
- Exclude checks
Expected 1 space after "?"; 0 found Invalid
$items?->getEntity()->getEntityTypeId() == 'node' &&
- Exclude checks
Expected 1 blank line before function; 0 found Open
function stanford_profile_helper_node_update(NodeInterface $node) {
- Exclude checks
Additional blank lines found at end of doc comment Open
*/
- Exclude checks
Doc comment short description must start with a capital letter Open
* stanford_profile_helper_helper.module
- Exclude checks
Unused use statement Open
use Drupal\views\ViewEntityInterface;
- Exclude checks
Expected 1 space after "?"; 0 found Open
$property_path = $index->getField($name)?->getPropertyPath() ?: '';
- Exclude checks
Only string literals should be passed to t() where possible Wontfix
$form['container'][$source_field]['#description'] = t($new_desc, $args);
- Exclude checks
Variable $role is undefined. Invalid
return array_map(fn($role) => $role->label(), $roles);
- Exclude checks
Line exceeds 80 characters; contains 82 characters Open
// in the UI. If cron is running, the current host won't match the canonical
- Exclude checks
Expected 1 space before ":"; 0 found Invalid
case $stanford_profile_helper_403_page:
- Exclude checks
Only string literals should be passed to t() where possible Wontfix
$element['value']['#description'] = t($new_desc, $args);
- Exclude checks
Variable $role is undefined. Invalid
return array_map(fn($role) => $role->label(), $roles);
- Exclude checks
Expected 1 space before "?"; 0 found Open
$property_path = $index->getField($name)?->getPropertyPath() ?: '';
- Exclude checks
Possible parse error: CASE missing opening colon Invalid
case $stanford_profile_helper_403_page:
- Exclude checks
Object operator not indented correctly; expected 4 spaces but found 6 Open
->getName() == 'layout_selection') {
- Exclude checks
Expected 1 space before ":"; 0 found Open
case $stanford_profile_helper_404_page:
- Exclude checks