modules/custom/deims_variable/deims_variable.field.inc

Summary

Maintainability
Test Coverage

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

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

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':

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'];

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'];

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':

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(

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'];

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':

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'];

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'];

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'];

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) {

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']='';

Case breaking statements must be followed by a single blank line
Open

            break;

Case breaking statements must be followed by a single blank line
Open

            break;

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)

Array closing indentation error, expected 14 spaces but found 15
Open

               ),

Case breaking statements must be followed by a single blank line
Open

            break;

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));

Missing function doc comment
Open

function deims_variable_variable_type_select_callback($form, $form_state) {

Case breaking statements must be followed by a single blank line
Open

            break;

Line indented incorrectly; expected 6 spaces, found 0
Open

//    ISO 19110 is not yet part of ISO19115, it is in the DIS stage (Draft)

Expected 1 space before "="; 0 found
Open

              $attribute['attrdomv']['rdom']['rdommin']= $item['data']['minimum'];

Line indented incorrectly; expected 10 spaces, found 11
Open

           $attribute[] = array(

Array indentation error, expected 16 spaces but found 17
Open

                 'codeExplanation' => $value,

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'])),

Line indented incorrectly; expected 10 spaces, found 12
Open

            $errors[$field['field_name']][$langcode][$delta][] = array(

Case breaking statements must be followed by a single blank line
Open

            break;

Expected 1 space after IF keyword; 0 found
Open

            if( !$unitmetadata) {

Line indented incorrectly; expected 10 spaces, found 12
Open

            );

Line indented incorrectly; expected 10 spaces, found 12
Open

            );

Array indentation error, expected 13 spaces but found 14
Open

              'value' => array(

Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses
Open

  // Sort by weight

Expected 1 space after "="; 2 found
Open

              $unitmetatada['minimum'] =  $item['data']['minimum'];

Line indented incorrectly; expected 10 spaces, found 14
Open

              'error' => 'deims_variable_minimum_error',

Array indentation error, expected 13 spaces but found 14
Open

              'key' => 'missingValueCode',

Line indented incorrectly; expected 10 spaces, found 14
Open

              'error' => 'deims_variable_maximum_error',

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'])),

Case breaking statements must be followed by a single blank line
Open

            break;

Expected 1 space before "="; 0 found
Open

        $attribute['gfc:FC_FeatureAttribute']['gfc:cardinality']['gco:Multiplicity gco:nilreason=unknown']='';

Line indented incorrectly; expected 10 spaces, found 12
Open

            $errors[$field['field_name']][$langcode][$delta][] = array(

Array indentation error, expected 16 spaces but found 17
Open

                 'code' => $key,

Concat operator must be surrounded by a single space
Open

            $attribute['gfc:FC_FeatureAttribute']['gfc:code']['gco:CharacterString'] = 'Date Time Format: '. $item['data']['pattern'];

Missing function doc comment
Open

function deims_variable_convert_options_value_to_array($element, &$form_state) {

There should be no white space after an opening "("
Open

            if( !$unitmetadata) {

Expected 1 space after "="; 0 found
Open

            $attribute['gfc:FC_FeatureAttribute']['gfc:valueMeasurementUnit'][$unitname]['gml:identifier codeSpace=http://unit.lternet.edu']='';

Expected 1 space before "="; 0 found
Open

            $attribute['gfc:FC_FeatureAttribute']['gfc:valueMeasurementUnit'][$unitname]['gml:identifier codeSpace=http://unit.lternet.edu']='';

Missing function doc comment
Open

function deims_variable_convert_select_to_options_element(array &$element) {

Array indentation error, expected 20 spaces but found 21
Open

                     'gfc:definition' => array('gco:CharacterString' => $value),

Array indentation error, expected 20 spaces but found 21
Open

                     'gfc:label' => array('gco:CharacterString' => $key),

Whitespace found at end of line
Open

        $attribute['gfc:FC_FeatureAttribute'] = array();       

Whitespace found at end of line
Open

   

Whitespace found at end of line
Open

            $unitname = "gml:unitDefinition gml:id=" . $item['data']['unit']; 

Whitespace found at end of line
Open

 

Whitespace found at end of line
Open

        $attribute['attrlabl'] = !empty($item['label']) ? $item['label'] : $item['name']; 

Whitespace found at end of line
Open

                     

Whitespace found at end of line
Open

     

Whitespace found at end of line
Open

     

Whitespace found at end of line
Open

      

Whitespace found at end of line
Open

      

Whitespace found at end of line
Open

            } 

Whitespace found at end of line
Open

  

There are no issues that match your filters.

Category
Status