howardjones/network-weathermap

View on GitHub

Showing 1,091 of 1,093 total issues

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

function* removeMapSaga(action) {
    console.log(`SAGA will remove map ${action.mapId} from its group`);

    let api = window.wm_api;

Severity: Major
Found in websrc/cacti-mgmt/src/sagas.js and 3 other locations - About 5 hrs to fix
websrc/cacti-mgmt/src/sagas.js on lines 63..77
websrc/cacti-mgmt/src/sagas.js on lines 79..93
websrc/cacti-mgmt/src/sagas.js on lines 127..141

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

function* addGroupSaga(action) {
    console.log(`SAGA will add group ${action.name}`);

    let api = window.wm_api;

Severity: Major
Found in websrc/cacti-mgmt/src/sagas.js and 3 other locations - About 5 hrs to fix
websrc/cacti-mgmt/src/sagas.js on lines 79..93
websrc/cacti-mgmt/src/sagas.js on lines 111..125
websrc/cacti-mgmt/src/sagas.js on lines 127..141

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

function* enableMapSaga(action) {
    console.log(`SAGA will enable map ${action.mapId}`);

    let api = window.wm_api;

Severity: Major
Found in websrc/cacti-mgmt/src/sagas.js and 3 other locations - About 5 hrs to fix
websrc/cacti-mgmt/src/sagas.js on lines 63..77
websrc/cacti-mgmt/src/sagas.js on lines 79..93
websrc/cacti-mgmt/src/sagas.js on lines 111..125

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

function* removeGroupSaga(action) {
    console.log(`SAGA will remove group with id ${action.groupId}`);

    let api = window.wm_api;

Severity: Major
Found in websrc/cacti-mgmt/src/sagas.js and 3 other locations - About 5 hrs to fix
websrc/cacti-mgmt/src/sagas.js on lines 63..77
websrc/cacti-mgmt/src/sagas.js on lines 111..125
websrc/cacti-mgmt/src/sagas.js on lines 127..141

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

Editor has 43 functions (exceeds 20 allowed). Consider refactoring.
Open

class Editor
{
    /** @var Map $map */
    public $map;
    /** @var string $mapFileName */
Severity: Minor
Found in lib/Weathermap/Editor/Editor.php - About 5 hrs to fix

    Function preRender has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public function preRender(&$map)
        {
            if (!$this->drawable) {
                MapUtility::debug('Skipping undrawable %s', $this);
                return;
    Severity: Minor
    Found in lib/Weathermap/Core/MapNode.php - About 5 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 preRender has 141 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function preRender(&$map)
        {
            if (!$this->drawable) {
                MapUtility::debug('Skipping undrawable %s', $this);
                return;
    Severity: Major
    Found in lib/Weathermap/Core/MapNode.php - About 5 hrs to fix

      File MapManagerTest.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Weathermap\Tests;
      
      require_once dirname(__FILE__) . '/../../all.php';
      Severity: Minor
      Found in lib/Weathermap/Tests/MapManagerTest.php - About 5 hrs to fix

        Method getConfig has 137 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/MapLink.php - About 5 hrs to fix

          File EditorTest.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          //
          //require_once dirname(__FILE__) . '/../lib/all.php';
          //require_once dirname(__FILE__) . '/../lib/Editor.php';
          //include_once dirname(__FILE__) . "/WMTestSupport.php";
          Severity: Minor
          Found in lib/Weathermap/Tests/EditorTest.php - About 5 hrs to fix

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

                public function getConfig()
                {
                    if ($this->configOverride != '') {
                        return $this->configOverride . "\n";
                    }
            Severity: Minor
            Found in lib/Weathermap/Core/MapNode.php - About 5 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

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

                    $translations = array(
                        'inscalekey' => $this->scaleKeys[IN],
                        'outscalekey' => $this->scaleKeys[OUT],
                        "inscaletag" => $this->scaleTags[IN],
                        "outscaletag" => $this->scaleTags[OUT],
            Severity: Major
            Found in lib/Weathermap/Core/MapLink.php and 1 other location - About 5 hrs to fix
            lib/Weathermap/Core/MapNode.php on lines 1292..1306

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

            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

                    $translations = array(
                        "inscalekey" => $this->scaleKeys[IN],
                        "outscalekey" => $this->scaleKeys[OUT],
                        "inscaletag" => $this->scaleTags[IN],
                        "outscaletag" => $this->scaleTags[OUT],
            Severity: Major
            Found in lib/Weathermap/Core/MapNode.php and 1 other location - About 5 hrs to fix
            lib/Weathermap/Core/MapLink.php on lines 776..790

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

            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 selfValidate has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                public function selfValidate()
                {
                    $classes = array(
                        'GLOBAL' => 'Weathermap\\Core\\Map',
                        'LINK' => 'Weathermap\\Core\\MapLink',
            Severity: Minor
            Found in lib/Weathermap/Core/ConfigReader.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

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

            function weathermap_page_title($t)
            {
                if (preg_match('/plugins\/weathermap\//', $_SERVER['REQUEST_URI'], $matches)) {
                    $t .= " - Weathermap";
            
            
            Severity: Major
            Found in lib/Weathermap/Integrations/Cacti/cacti10-plugin-hooks.php and 1 other location - About 4 hrs to fix
            lib/Weathermap/Integrations/Cacti/cacti88-plugin-hooks.php on lines 26..53

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

            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 weathermap_page_title($t)
            {
                if (preg_match('/plugins\/weathermap\//', $_SERVER['REQUEST_URI'], $matches)) {
                    $t .= " - Weathermap";
            
            
            Severity: Major
            Found in lib/Weathermap/Integrations/Cacti/cacti88-plugin-hooks.php and 1 other location - About 4 hrs to fix
            lib/Weathermap/Integrations/Cacti/cacti10-plugin-hooks.php on lines 20..47

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

            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 readData has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                public function readData($targetString, &$map, &$mapItem)
                {
                    $this->data[IN] = null;
                    $this->data[OUT] = null;
                    $dsnames = array(IN => "traffic_in", OUT => "traffic_out");
            Severity: Minor
            Found in lib/Weathermap/Plugins/Datasources/RRDTool.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 maplist has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function maplist()
                {
                    \html_start_box(
                        __('Weathermaps'),
                        '100%',
            Severity: Minor
            Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.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 readData has 115 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              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

              Severity
              Category
              Status
              Source
              Language