howardjones/network-weathermap

View on GitHub
lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php

Summary

Maintainability
F
1 wk
Test Coverage

File WeatherMapCactiManagementPlugin.php has 1237 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Weathermap\Integrations\Cacti;

require_once dirname(__FILE__) . "/database.php";
Severity: Major
Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 3 days to fix

    Function addmapPicker has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addmapPicker(
            $showAllFiles = false
        ) {
            $loaded = array();
            $flags = array();
    Severity: Minor
    Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 1 day 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 maplist has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function maplist()
        {
            \html_start_box(
                __('Weathermaps'),
                '100%',
    Severity: Major
    Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 7 hrs to fix

      WeatherMapCactiManagementPlugin has 49 functions (exceeds 20 allowed). Consider refactoring.
      Open

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

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

          Method mapSettings has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function mapSettings(
                  $id
              ) {
                  if ($id == 0) {
                      $title = __('Additional settings for ALL maps');
          Severity: Major
          Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 3 hrs to fix

            Method permissionsList has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function permissionsList(
                    $id
                ) {
                    $map = $this->manager->getMap($id);
                    $title = $map->titlecache;
            Severity: Major
            Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 2 hrs to fix

              Method handleGroupSelect has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function handleGroupSelect(
                      $request,
                      $appObject
                  ) {
                      $this->cactiHeader();
              Severity: Major
              Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 2 hrs to fix

                Method handleMapGroupChangeForm has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function handleMapGroupChangeForm(
                        $request,
                        $appObject
                    ) {
                        $this->cactiHeader();
                Severity: Major
                Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 2 hrs to fix

                  Function getMapFileList has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getMapFileList()
                      {
                          $files = array();
                          $valid_files = array();
                  
                  
                  Severity: Minor
                  Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 2 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 handleGroupSelect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleGroupSelect(
                          $request,
                          $appObject
                      ) {
                          $this->cactiHeader();
                  Severity: Minor
                  Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 2 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 maplistWarnings has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function maplistWarnings()
                      {
                          if (!MapUtility::moduleChecks()) {
                              print '<div align="center" class="wm_warning"><p>';
                  
                  

                    Function mapSettings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function mapSettings(
                            $id
                        ) {
                            if ($id == 0) {
                                $title = __('Additional settings for ALL maps');

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

                        public function permissionsList(
                            $id
                        ) {
                            $map = $this->manager->getMap($id);
                            $title = $map->titlecache;

                    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 getMapFileList has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function getMapFileList()
                        {
                            $files = array();
                            $valid_files = array();
                    
                    

                      Method handleMapSettingsSave has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function handleMapSettingsSave(
                              $request,
                              $appObject
                          ) {
                              $mapid = null;

                        Method mapReadOnlySettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function mapReadOnlySettings(
                                $id,
                                $title = ''
                            ) {
                                if ($title == '') {

                          Function maplistWarnings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function maplistWarnings()
                              {
                                  if (!MapUtility::moduleChecks()) {
                                      print '<div align="center" class="wm_warning"><p>';
                          
                          
                          Severity: Minor
                          Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 55 mins 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 mapReadOnlySettings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function mapReadOnlySettings(
                                  $id,
                                  $title = ''
                              ) {
                                  if ($title == '') {
                          Severity: Minor
                          Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 45 mins 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 previewConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function previewConfig(
                                  $file
                              ) {
                                  chdir($this->configPath);
                          
                          
                          Severity: Minor
                          Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 35 mins 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 handleMapSettingsSave has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function handleMapSettingsSave(
                                  $request,
                                  $appObject
                              ) {
                                  $mapid = null;
                          Severity: Minor
                          Found in lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php - About 35 mins 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

                          Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                          Open

                              public function handleGroupSelect(

                          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                          See

                          Class "WeatherMapCactiManagementPlugin" has 49 methods, which is greater than 20 authorized. Split it into smaller classes.
                          Open

                          class WeatherMapCactiManagementPlugin extends UIBase

                          A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

                          Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                          Open

                              private function getMapFileList()

                          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                          See

                          Refactor this function to reduce its Cognitive Complexity from 55 to the 15 allowed.
                          Open

                              protected function addmapPicker(

                          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                          See

                          This function "maplist" has 209 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
                          Open

                              protected function maplist()

                          A function that grows too large tends to aggregate too many responsibilities.

                          Such functions inevitably become harder to understand and therefore harder to maintain.

                          Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.

                          Those smaller functions will not only be easier to understand, but also probably easier to test.

                          Refactor this function to reduce its Cognitive Complexity from 32 to the 15 allowed.
                          Open

                              protected function maplist()

                          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                          See

                          Define a constant instead of duplicating this literal "<tr><td>" 4 times.</td></tr>
                          Open

                                              print '<tr><td>' . __('No files were found in the configs directory.') . '</td></tr>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 4 times.
                          Open

                                      print '<div align="center">' . __('Last Completed Run: %s', $lastStats) . '</div>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "<div align="center" class="wm_warning"><p>" 4 times.</p></div>
                          Open

                                      print '<div align="center" class="wm_warning"><p>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "gname" 3 times.
                          Open

                                  if (isset($request['gname']) && (strlen($request['gname']) > 0)) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "groupadmin" 5 times.
                          Open

                                  header("Location: " . $this->makeURL(array("action" => "groupadmin", "header" => "false")));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "false" 15 times.
                          Open

                                  header("Location: " . $this->makeURL(array("action" => "groupadmin", "header" => "false")));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "handler" 10 times.
                          Open

                                  ':: DEFAULT ::' => array('handler' => 'handleManagementMainScreen', 'args' => array()),

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" class="hyperLink" href="" 3 times.
                          Open

                                          print '<td><a title="' . __('Click to change group') . '" class="hyperLink" href="' . $this->makeURL(

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "">" 6 times.
                          Open

                                              print '" title="' . __('Move Group Up') . '"></span>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "map_settings" 5 times.
                          Open

                                  header("Location: " . $this->makeURL(array("action" => "map_settings", "id" => 0)));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "action" 41 times.
                          Open

                                  if (isset($request['action'])) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "map_id" 3 times.
                          Open

                                  if (isset($request['map_id']) && is_numeric($request['map_id'])) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "Content-type: application/json" 7 times.
                          Open

                                  header('Content-type: application/json');

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "result" 4 times.
                          Open

                                  $data = array("result" => "OK");

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 4 times.
                          Open

                                      print '</p></div>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "order" 10 times.
                          Open

                                      isset($request['order']) && is_numeric($request['order'])

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "mapid" 17 times.
                          Open

                                  if (isset($request['mapid']) && is_numeric($request['mapid'])) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "value" 3 times.
                          Open

                                  if (isset($request['value']) && $request['value']) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Merge this if statement with the enclosing one.
                          Open

                                      if (($lastStarted != $lastFinished) && ($lastStarted != '')) {

                          Merging collapsible if statements increases the code's readability.

                          Noncompliant Code Example

                          if (condition1) {
                            if (condition2) {
                              ...
                            }
                          }
                          

                          Compliant Solution

                          if (condition1 && condition2) {
                            ...
                          }
                          

                          Define a constant instead of duplicating this literal "" 5 times.
                          Open

                                      print '</td></tr>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "<td></td>" 4 times.
                          Open

                                      print '<td></td>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Remove this commented out code.
                          Open

                                      // print '$file_dir != $weathermap_confdir';

                          Programmers should not comment out code as it bloats programs and reduces readability.

                          Unused code should be deleted and can be retrieved from source control history if required.

                          See

                          • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                          • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                          • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                          • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

                          Define a constant instead of duplicating this literal "userid" 7 times.
                          Open

                                      && isset($request['userid']) && is_numeric($request['userid'])

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "standard" 3 times.
                          Open

                                                  print __('standard');

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" title="" 8 times.
                          Open

                                              print '" title="' . __('Move Group Up') . '"></span>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "center" 12 times.
                          Open

                                      'center',

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "Settings" 4 times.
                          Open

                                  \html_header(array(__('Actions'), __('Group Name'), __('Settings'), __('Sort Order')), 2);

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 5 times.
                          Open

                                          ) . '">' . htmlspecialchars($map->groupname) . '</a></td>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "new_group" 3 times.
                          Open

                                  if (isset($request['new_group']) && is_numeric($request['new_group'])) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 3 times.
                          Open

                                      print '<tr><td colspan="4"><em>' . __('No Weathermaps Configured') . '</em></td></tr>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "<td><a class="hyperLink" href="" times.></a></td>
                          Open

                                      print '<td><a class="hyperLink" href="' . $this->makeURL(

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "addmap_picker" 3 times.
                          Open

                                      $this->makeURL(array("action" => "addmap_picker"))

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "header" 15 times.
                          Open

                                  header("Location: " . $this->makeURL(array("action" => "groupadmin", "header" => "false")));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 11 times.
                          Open

                                              print '</tr>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "Location: " 17 times.
                          Open

                                  header("Location: " . $this->makeURL(array("action" => "map_settings", "id" => 0)));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "show_all" 3 times.
                          Open

                                  if (isset($request['show_all']) && $request['show_all'] == 1) {

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Remove this commented out code.
                          Open

                                      // wmGenerateFooterLinks();

                          Programmers should not comment out code as it bloats programs and reduces readability.

                          Unused code should be deleted and can be retrieved from source control history if required.

                          See

                          • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
                          • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
                          • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
                          • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

                          Define a constant instead of duplicating this literal "success" 4 times.
                          Open

                                  $data = array("success" => false);

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "" 20 times.
                          Open

                                              print '<td>' . htmlspecialchars($group->name) . '</td>';

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

                          Define a constant instead of duplicating this literal "perms_edit" 3 times.
                          Open

                                      header("Location: " . $this->makeURL(array("action" => "perms_edit", "id" => $request['mapid'])));

                          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                          Noncompliant Code Example

                          With the default threshold of 3:

                          function run() {
                            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                            execute('action1');
                            release('action1');
                          }
                          

                          Compliant Solution

                          ACTION_1 = 'action1';
                          
                          function run() {
                            prepare(ACTION_1);
                            execute(ACTION_1);
                            release(ACTION_1);
                          }
                          

                          Exceptions

                          To prevent generating some false-positives, literals having less than 5 characters are excluded.

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

                              public function makeURL($params, $altURL = "")
                              {
                                  $baseURL = $this->myURL;
                                  if ($altURL != "") {
                                      $baseURL = $altURL;
                          lib/Weathermap/Integrations/Cacti/WeatherMapCactiUserPlugin.php on lines 100..115

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

                          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

                              protected function handleMapDisableAPI(
                                  $request,
                                  $appObject
                              ) {
                                  $data = array("success" => false);
                          lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php on lines 350..362

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

                          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

                              protected function handleMapEnableAPI(
                                  $request,
                                  $appObject
                              ) {
                                  $data = array("success" => false);
                          lib/Weathermap/Integrations/Cacti/WeatherMapCactiManagementPlugin.php on lines 364..376

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

                          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