deims_variable_remove_js accesses the super-global variable $_POST. Open
function deims_variable_remove_js() {
require_once DRUPAL_ROOT . '/includes/form.inc';
// drupal_html_id() very helpfully ensures that all html IDS are unique
// on a page. Unfortunately what it doesn't realize is that the IDs
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
deims_variable_remove_js accesses the super-global variable $_POST. Open
function deims_variable_remove_js() {
require_once DRUPAL_ROOT . '/includes/form.inc';
// drupal_html_id() very helpfully ensures that all html IDS are unique
// on a page. Unfortunately what it doesn't realize is that the IDs
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
The function deims_variable_field_formatter_view() has 254 lines of code. Current threshold is set to 100. Avoid really long methods. Open
function deims_variable_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'deims_variable_summary':
- Exclude checks
The function deims_variable_field_widget_form() has 220 lines of code. Current threshold is set to 100. Avoid really long methods. Open
function deims_variable_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// We need to actually track the form parents of our widget since it may be
// used with inline entity forms.
$field_name = $element['#field_name'];
$langcode = $element['#language'];
- Exclude checks
The function deims_variable_field_widget_form() has an NPath complexity of 24192. The configured NPath complexity threshold is 200. Open
function deims_variable_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// We need to actually track the form parents of our widget since it may be
// used with inline entity forms.
$field_name = $element['#field_name'];
$langcode = $element['#language'];
- 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 deims_variable_field_formatter_view() has an NPath complexity of 256. The configured NPath complexity threshold is 200. Open
function deims_variable_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'deims_variable_summary':
- 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 deims_variable_field_validate() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
function deims_variable_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) {
if (!deims_variable_field_is_empty($item, $field)) {
if (empty($item['name'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
- 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 deims_variable_field_widget_form() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10. Open
function deims_variable_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// We need to actually track the form parents of our widget since it may be
// used with inline entity forms.
$field_name = $element['#field_name'];
$langcode = $element['#language'];
- 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 deims_variable_field_formatter_view() has a Cyclomatic Complexity of 42. The configured cyclomatic complexity threshold is 10. Open
function deims_variable_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'deims_variable_summary':
- 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 unused local variables such as '$delta'. Open
$delta = $context['delta'];
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$unitmetatada'. Open
$unitmetatada['minimum'] = $item['data']['minimum'];
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$items'. Open
$items = $context['items'];
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$entity'. Open
foreach ($entities as $id => $entity) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Expected 1 space after "="; 0 found Open
$attribute['gfc:FC_FeatureAttribute']['gfc:cardinality']['gco:Multiplicity gco:nilreason=unknown']='';
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
4 spaces found before inline comment; expected "// ISO 19110 is not yet part of ISO19115, it is in the DIS stage (Draft)" but found "// ISO 19110 is not yet part of ISO19115, it is in the DIS stage (Draft)" Open
// ISO 19110 is not yet part of ISO19115, it is in the DIS stage (Draft)
- Exclude checks
Array closing indentation error, expected 14 spaces but found 15 Open
),
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
If the line declaring an array spans longer than 80 characters, each element should be broken into its own line Open
$parents = array_merge($element['#field_parents'], array($field_name, $langcode, $delta));
- Exclude checks
Missing function doc comment Open
function deims_variable_variable_type_select_callback($form, $form_state) {
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
Line indented incorrectly; expected 6 spaces, found 0 Open
// ISO 19110 is not yet part of ISO19115, it is in the DIS stage (Draft)
- Exclude checks
Expected 1 space before "="; 0 found Open
$attribute['attrdomv']['rdom']['rdommin']= $item['data']['minimum'];
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 11 Open
$attribute[] = array(
- Exclude checks
Array indentation error, expected 16 spaces but found 17 Open
'codeExplanation' => $value,
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 14 Open
'message' => t('%name: the minimum value must be smaller than the maximum value.', array('%name' => $instance['label'])),
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 12 Open
$errors[$field['field_name']][$langcode][$delta][] = array(
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if( !$unitmetadata) {
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 12 Open
);
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 12 Open
);
- Exclude checks
Array indentation error, expected 13 spaces but found 14 Open
'value' => array(
- Exclude checks
Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses Open
// Sort by weight
- Exclude checks
Expected 1 space after "="; 2 found Open
$unitmetatada['minimum'] = $item['data']['minimum'];
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 14 Open
'error' => 'deims_variable_minimum_error',
- Exclude checks
Array indentation error, expected 13 spaces but found 14 Open
'key' => 'missingValueCode',
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 14 Open
'error' => 'deims_variable_maximum_error',
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 14 Open
'message' => t('%name: the maximum value must be larger than the minimum value.', array('%name' => $instance['label'])),
- Exclude checks
Case breaking statements must be followed by a single blank line Open
break;
- Exclude checks
Expected 1 space before "="; 0 found Open
$attribute['gfc:FC_FeatureAttribute']['gfc:cardinality']['gco:Multiplicity gco:nilreason=unknown']='';
- Exclude checks
Line indented incorrectly; expected 10 spaces, found 12 Open
$errors[$field['field_name']][$langcode][$delta][] = array(
- Exclude checks
Array indentation error, expected 16 spaces but found 17 Open
'code' => $key,
- Exclude checks
Concat operator must be surrounded by a single space Open
$attribute['gfc:FC_FeatureAttribute']['gfc:code']['gco:CharacterString'] = 'Date Time Format: '. $item['data']['pattern'];
- Exclude checks
Missing function doc comment Open
function deims_variable_convert_options_value_to_array($element, &$form_state) {
- Exclude checks
There should be no white space after an opening "(" Open
if( !$unitmetadata) {
- Exclude checks
Expected 1 space after "="; 0 found Open
$attribute['gfc:FC_FeatureAttribute']['gfc:valueMeasurementUnit'][$unitname]['gml:identifier codeSpace=http://unit.lternet.edu']='';
- Exclude checks
Expected 1 space before "="; 0 found Open
$attribute['gfc:FC_FeatureAttribute']['gfc:valueMeasurementUnit'][$unitname]['gml:identifier codeSpace=http://unit.lternet.edu']='';
- Exclude checks
Missing function doc comment Open
function deims_variable_convert_select_to_options_element(array &$element) {
- Exclude checks
Array indentation error, expected 20 spaces but found 21 Open
'gfc:definition' => array('gco:CharacterString' => $value),
- Exclude checks
Array indentation error, expected 20 spaces but found 21 Open
'gfc:label' => array('gco:CharacterString' => $key),
- Exclude checks
Whitespace found at end of line Open
$attribute['gfc:FC_FeatureAttribute'] = array();
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
$unitname = "gml:unitDefinition gml:id=" . $item['data']['unit'];
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
$attribute['attrlabl'] = !empty($item['label']) ? $item['label'] : $item['name'];
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
- Exclude checks
Whitespace found at end of line Open
}
- Exclude checks
Whitespace found at end of line Open
- Exclude checks