howardjones/network-weathermap

View on GitHub

Showing 1,091 of 1,093 total issues

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

    removeMap(mapId) {
        const source_url = this.base_url + "delete_map";
        console.log(`API Removing map with id ${mapId} via ${source_url}`);

        const config = {headers: {'Content-Type': 'multipart/form-data', withCredentials: true}};
Severity: Major
Found in websrc/cacti-mgmt/src/services/api.js and 4 other locations - About 4 hrs to fix
websrc/cacti-mgmt/src/services/api.js on lines 29..41
websrc/cacti-mgmt/src/services/api.js on lines 44..56
websrc/cacti-mgmt/src/services/api.js on lines 88..100
websrc/cacti-mgmt/src/services/api.js on lines 102..114

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

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

    enableMap(mapId) {
        const source_url = this.base_url + "enable_map";
        console.log(`API enabling map with id ${mapId} via ${source_url}`);

        const config = {headers: {'Content-Type': 'multipart/form-data', withCredentials: true}};
Severity: Major
Found in websrc/cacti-mgmt/src/services/api.js and 4 other locations - About 4 hrs to fix
websrc/cacti-mgmt/src/services/api.js on lines 29..41
websrc/cacti-mgmt/src/services/api.js on lines 44..56
websrc/cacti-mgmt/src/services/api.js on lines 74..86
websrc/cacti-mgmt/src/services/api.js on lines 102..114

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

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

    disableMap(mapId) {
        const source_url = this.base_url + "disable_map";
        console.log(`API disabling map with id ${mapId} via ${source_url}`);

        const config = {headers: {'Content-Type': 'multipart/form-data', withCredentials: true}};
Severity: Major
Found in websrc/cacti-mgmt/src/services/api.js and 4 other locations - About 4 hrs to fix
websrc/cacti-mgmt/src/services/api.js on lines 29..41
websrc/cacti-mgmt/src/services/api.js on lines 44..56
websrc/cacti-mgmt/src/services/api.js on lines 74..86
websrc/cacti-mgmt/src/services/api.js on lines 88..100

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

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

    addGroup(group_name) {
        const source_url = this.base_url + "group_add";
        console.log(`API Adding ${group_name} via ${source_url}`)

        const config = {headers: {'Content-Type': 'multipart/form-data', withCredentials: true}};
Severity: Major
Found in websrc/cacti-mgmt/src/services/api.js and 4 other locations - About 4 hrs to fix
websrc/cacti-mgmt/src/services/api.js on lines 44..56
websrc/cacti-mgmt/src/services/api.js on lines 74..86
websrc/cacti-mgmt/src/services/api.js on lines 88..100
websrc/cacti-mgmt/src/services/api.js on lines 102..114

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

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

Function generateSortedImagemap has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateSortedImagemap($imagemapname)
    {
        $html = "\n<map name=\"" . $imagemapname . '" id="' . $imagemapname . "\">\n";

        $allLayers = array_keys($this->seenZLayers);
Severity: Minor
Found in lib/Weathermap/Core/Map.php - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getConfig has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    public function getConfig()
    {
        $output = '';

        $output .= "# Automatically generated by php-weathermap v" . WEATHERMAP_VERSION . "\n\n";
Severity: Minor
Found in lib/Weathermap/Core/Map.php - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

WeatherMapCactiUserPlugin has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

class WeatherMapCactiUserPlugin extends UIBase
{
    /** @var MapManager $manager */
    public $manager;
    public $myURL;
Severity: Minor
Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiUserPlugin.php - About 4 hrs to fix

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

    function plugin_init_weathermap()
    {
        global $plugin_hooks;
    
        $plugin_hooks['top_header_tabs']['weathermap'] = 'weathermap_show_tab';
    Severity: Major
    Found in setup88.php and 1 other location - About 4 hrs to fix
    setup10.php on lines 61..78

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

    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

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

    function plugin_init_weathermap()
    {
        global $plugin_hooks;
    
        $plugin_hooks['top_header_tabs']['weathermap'] = 'weathermap_show_tab';
    Severity: Major
    Found in setup10.php and 1 other location - About 4 hrs to fix
    setup88.php on lines 74..91

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

    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

    MapNode has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MapNode extends MapDataItem
    {
        public $drawable;
    
        // Coordinates we're actually going to draw at
    Severity: Minor
    Found in lib/Weathermap/Core/MapNode.php - About 4 hrs to fix

      Method getConfig has 107 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getConfig()
          {
              if ($this->configOverride != '') {
                  return $this->configOverride . "\n";
              }
      Severity: Major
      Found in lib/Weathermap/Core/MapNode.php - About 4 hrs to fix

        File MapDataItem.php has 341 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace Weathermap\Core;
        
        /**
        Severity: Minor
        Found in lib/Weathermap/Core/MapDataItem.php - About 4 hrs to fix

          File check.php has 340 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          $criticalCount = 0;
          $nonCriticalCount = 0;
          
          // This constant was added in PHP 5.2 - since we're actually checking that the version is > 5.3, it might
          Severity: Minor
          Found in check.php - About 4 hrs to fix

            Method readData has 103 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function readData($targetString, &$map, &$mapItem)
                {
                    $this->data[IN] = null;
                    $this->data[OUT] = null;
                    $pdo = weathermap_get_pdo();
            Severity: Major
            Found in lib/Weathermap/Plugins/Datasources/CactiDSStats.php - About 4 hrs to fix

              Function drawLegendClassic has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function drawLegendClassic($useTags = false)
                  {
                      $nScales = $this->scale->spanCount();
              
                      MapUtility::debug("Drawing $nScales colours into SCALE\n");
              Severity: Minor
              Found in lib/Weathermap/Core/Legend.php - About 4 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function init has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function init(&$map)
                  {
                      if ($map->context == 'cacti') {
                          if (!function_exists('db_fetch_assoc')) {
                              MapUtility::debug("ReadData DSStats: Cacti database library not found. [DSSTATS001]\n");
              Severity: Minor
              Found in lib/Weathermap/Plugins/Datasources/CactiDSStats.php - About 4 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method weathermap_poller_output has 101 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function weathermap_poller_output($rrdUpdateArray)
              {
                  global $config;
              
                  $pdo = weathermap_get_pdo();
              Severity: Major
              Found in lib/Weathermap/Integrations/Cacti/cacti-plugin-poller.php - About 4 hrs to fix

                Method weathermap_config_settings has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function weathermap_config_settings()
                {
                    global $tabs, $settings;
                
                    $tabs['weathermap'] = __('Maps', 'weathermap');
                Severity: Major
                Found in lib/Weathermap/Integrations/Cacti/cacti10-plugin-hooks.php - About 4 hrs to fix

                  Method addmapPicker has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function addmapPicker(
                          $showAllFiles = false
                      ) {
                          $loaded = array();
                          $flags = array();
                  Severity: Major
                  Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 3 hrs to fix

                    Function runMaps has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function runMaps($mydir)
                    {
                        global $weathermap_debugging;
                        global $weathermapPollerStartTime;
                    
                    
                    Severity: Minor
                    Found in lib/Weathermap/Poller/poller-common.php - About 3 hrs to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language