librenms/librenms

View on GitHub
includes/discovery/sensors/state/cisco.inc.php

Summary

Maintainability
F
1 wk
Test Coverage

Consider simplifying this complex logical expression.
Open

                if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState' || $state_name == 'cRFCfgRedundancyOperMode' || $state_name == 'cswRingRedundant') {
                    $descr = $tablevalue['descr'];
                } elseif ($state_name == 'cswSwitchRole') {
                    $swrolenumber++;
                    $descr = $tablevalue['descr'] . $swrolenumber;
Severity: Critical
Found in includes/discovery/sensors/state/cisco.inc.php - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if (($tablevalue['oid'] == 'cswGlobals' || $tablevalue['oid'] == 'cswSwitchRole' || $tablevalue['oid'] == 'cswSwitchState' || $tablevalue['oid'] == 'cswStackPortOperStatus') && $redundant_data == 'false' && count($role_data) == 1) {
            continue;
        }
    Severity: Major
    Found in includes/discovery/sensors/state/cisco.inc.php - About 40 mins to fix

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

              if ($state_name == 'cRFStatusUnitState' || $state_name == 'cRFStatusPeerUnitState') {
                  $states = [
                      ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'notKnown'],
                      ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'disabled'],
                      ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'initialization'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 1 other location - About 1 day to fix
      includes/discovery/sensors/state/dell.inc.php on lines 75..94

      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 393.

      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

              } elseif ($state_name == 'cefcFRUPowerOperStatus') {
                  $states = [
                      ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'off (other)'],
                      ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'on'],
                      ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'off (admin)'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 1 other location - About 1 day to fix
      includes/discovery/sensors/state/cisco.inc.php on lines 133..148

      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 304.

      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

              } elseif ($state_name == 'c3gGsmCurrentBand') {
                  $states = [
                      ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
                      ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'invalid'],
                      ['value' => 3, 'generic' => 3, 'graph' => 0, 'descr' => 'none'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 1 other location - About 1 day to fix
      includes/discovery/sensors/state/cisco.inc.php on lines 111..126

      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 304.

      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 3 locations. Consider refactoring.
      Open

                  $states = [
                      ['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'waiting'],
                      ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'progressing'],
                      ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'added'],
                      ['value' => 4, 'generic' => 0, 'graph' => 0, 'descr' => 'ready'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 2 other locations - About 1 day to fix
      includes/discovery/sensors/state/printer.inc.php on lines 45..58
      includes/polling/sensors/state/printer.inc.php on lines 5..18

      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 272.

      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 3 locations. Consider refactoring.
      Open

              } elseif ($state_name == 'c3gGsmPacketService') {
                  $states = [
                      ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
                      ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'none'],
                      ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'gprs'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 2 other locations - About 1 day to fix
      includes/discovery/sensors/state/drac.inc.php on lines 30..72
      includes/discovery/sensors/state/drac.inc.php on lines 59..72

      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 249.

      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

              } elseif ($state_name == 'cRFCfgRedundancyOperMode') {
                  $states = [
                      ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'nonRedundant'],
                      ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'staticLoadShareNonRedundant'],
                      ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'dynamicLoadShareNonRedundant'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 1 other location - About 5 hrs to fix
      includes/discovery/sensors/state/quanta.inc.php on lines 25..36

      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 201.

      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 3 locations. Consider refactoring.
      Open

              } else {
                  $states = [
                      ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'],
                      ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'warning'],
                      ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 2 other locations - About 3 hrs to fix
      includes/discovery/sensors/state/dell.inc.php on lines 32..106
      includes/discovery/sensors/state/drac.inc.php on lines 50..59

      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 153.

      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 3 locations. Consider refactoring.
      Open

              } elseif ($state_name == 'cswSwitchRole') {
                  $states = [
                      ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'master'],
                      ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'member'],
                      ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'notMember'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 2 other locations - About 1 hr to fix
      includes/discovery/sensors/state/cisco.inc.php on lines 126..133
      includes/discovery/sensors/state/drac.inc.php on lines 43..50

      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 112.

      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 3 locations. Consider refactoring.
      Open

              } elseif ($state_name == 'c3gModemStatus') {
                  $states = [
                      ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
                      ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'offline'],
                      ['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'online'],
      Severity: Major
      Found in includes/discovery/sensors/state/cisco.inc.php and 2 other locations - About 1 hr to fix
      includes/discovery/sensors/state/cisco.inc.php on lines 90..97
      includes/discovery/sensors/state/drac.inc.php on lines 43..50

      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 112.

      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

      There are no issues that match your filters.

      Category
      Status