librenms/librenms

View on GitHub
includes/html/print-map.inc.php

Summary

Maintainability
D
2 days
Test Coverage

File print-map.inc.php has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * LibreNMS
 *
Severity: Minor
Found in includes/html/print-map.inc.php - About 4 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (($items['remote_disabled'] != '0') && ($items['local_disabled'] != '0')) {
            $link_style = $edge_disabled_style;
        } elseif (($items['remote_status'] == '0') && ($items['local_status'] == '0')) {
            $link_style = $edge_down_style;
        } elseif (($items['remote_status'] == '1' && $items['remote_ifoperstatus'] == 'down') || ($items['local_status'] == '1' && $items['local_ifoperstatus'] == 'down')) {
    Severity: Major
    Found in includes/html/print-map.inc.php - About 40 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if (! array_key_exists($local_device_id, $devices_by_id)) {
              $devices_by_id[$local_device_id] = [
                  'id'=>$local_device_id,
                  'label'=>shorthost(format_hostname($local_device), 1),
                  'title'=>generate_device_link($local_device, '', [], '', '', '', 0),
      Severity: Major
      Found in includes/html/print-map.inc.php and 1 other location - About 6 hrs to fix
      includes/html/print-map.inc.php on lines 261..272

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 211.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if (! array_key_exists($remote_device_id, $devices_by_id)) {
              $devices_by_id[$remote_device_id] = ['id'=>$remote_device_id, 'label'=>shorthost(format_hostname($remote_device), 1), 'title'=>generate_device_link($remote_device, '', [], '', '', '', 0), 'shape'=>'box'];
              if ($items['remote_disabled'] != '0') {
                  $devices_by_id[$remote_device_id] = array_merge($devices_by_id[$remote_device_id], $node_disabled_style);
              } elseif ($items['remote_status'] == '0') {
      Severity: Major
      Found in includes/html/print-map.inc.php and 1 other location - About 6 hrs to fix
      includes/html/print-map.inc.php on lines 242..258

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 211.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Closing brace indented incorrectly; expected 0 spaces, found 4
      Open

          }

      Line indented incorrectly; expected 0 spaces, found 4
      Open

          }

      There are no issues that match your filters.

      Category
      Status