howardjones/network-weathermap

View on GitHub

Showing 1,091 of 1,093 total issues

Method readData has 96 lines of code (exceeds 25 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: Major
Found in lib/Weathermap/Plugins/Datasources/RRDTool.php - About 3 hrs to fix

    Method drawLegendClassic has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function imagecreatefromfile has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function imagecreatefromfile($filename)
          {
              $resultImage = null;
              $newImage = null;
      
      
      Severity: Minor
      Found in lib/Weathermap/Core/ImageLoader.php - About 3 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

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

          public function getConfig()
          {
              $output = '';
      
              $output .= "# Automatically generated by php-weathermap v" . WEATHERMAP_VERSION . "\n\n";
      Severity: Major
      Found in lib/Weathermap/Core/Map.php - About 3 hrs to fix

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

        if (is_dir($cacti_base) && file_exists($cacti_base . "include/global.php")) {
            // include the cacti-config, so we know about the database
            include_once $cacti_base . "include/global.php";
            $config['base_url'] = (isset($config['url_path']) ? $config['url_path'] : $cacti_url);
            $cacti_found = true;
        Severity: Major
        Found in random-bits/cacti-mapper.php and 1 other location - About 3 hrs to fix
        random-bits/cacti-integrate.php on lines 56..69

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

        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

        if (is_dir($cacti_base) && file_exists($cacti_base . "include/global.php")) {
            // include the cacti-config, so we know about the database
            include_once $cacti_base . "include/global.php";
            $config['base_url'] = (isset($config['url_path']) ? $config['url_path'] : $cacti_url);
            $cacti_found = true;
        Severity: Major
        Found in random-bits/cacti-integrate.php and 1 other location - About 3 hrs to fix
        random-bits/cacti-mapper.php on lines 14..27

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

        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

        MapManagerTest has 30 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class MapManagerTest extends \PHPUnit_Extensions_Database_TestCase
        {
        
            // only instantiate pdo once for test clean-up/fixture load
            static private $pdo = null;
        Severity: Minor
        Found in lib/Weathermap/Tests/MapManagerTest.php - About 3 hrs to fix

          ConfigReader has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ConfigReader
          {
              private $lineCount = 0;
              /** @var MapDataItem $currentObject */
              private $currentObject = null;
          Severity: Minor
          Found in lib/Weathermap/Core/ConfigReader.php - About 3 hrs to fix

            Function readFromRealRRDtoolWithAggregate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                private function readFromRealRRDtoolWithAggregate(
                    $rrdfile,
                    $cf,
                    $aggregatefn,
                    $start,
            Severity: Minor
            Found in lib/Weathermap/Plugins/Datasources/RRDTool.php - About 3 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

            Function parseString has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                public function parseString($input)
                {
                    $output = array(); // Array of Output
                    $cPhraseQuote = null; // Record of the quote that opened the current phrase
                    $sPhrase = null; // Temp storage for the current phrase we are building
            Severity: Minor
            Found in lib/Weathermap/Core/ConfigReader.php - About 3 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

            Method runMaps has 89 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Method run has 87 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run()
                  {
                      if (!$this->preChecks()) {
                          return false;
                      }
              Severity: Major
              Found in lib/Weathermap/Poller/MapRuntime.php - About 3 hrs to fix

                Method moveNode has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function moveNode($nodeName, $newX, $newY)
                    {
                        if (!$this->isLoaded()) {
                            throw new WeathermapInternalFail("Map must be loaded before editing API called.");
                        }
                Severity: Major
                Found in lib/Weathermap/Editor/Editor.php - About 3 hrs to fix

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

                  function weathermap_config_settings()
                  {
                      global $tabs, $settings;
                      $tabs["misc"] = "Misc";
                  
                  
                  Severity: Major
                  Found in lib/Weathermap/Integrations/Cacti/cacti88-plugin-hooks.php - About 3 hrs to fix

                    Method readFromRealRRDtool has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function readFromRealRRDtool($rrdfile, $cf, $start, $end, $dsnames, &$map, &$item)
                        {
                            MapUtility::debug("RRD ReadData: traditional style\n");
                    
                            // we get the last 800 seconds of data - this might be 1 or 2 lines, depending on when in the
                    Severity: Major
                    Found in lib/Weathermap/Plugins/Datasources/RRDTool.php - About 3 hrs to fix

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

                          public function init(&$map)
                          {
                              if ($map->context == 'cacti') {
                                  $pdo = weathermap_get_pdo();
                      
                      
                      Severity: Minor
                      Found in lib/Weathermap/Plugins/Datasources/CactiTholdStatus.php - About 3 hrs to fix

                      Cognitive Complexity

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

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

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

                      Further reading

                      File cacti-integrate.php has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /** cacti-integrate.php
                       *
                       * Auto-fill a basic map file with as much information as possible from the
                       * Cacti database, using interface names and node ip/names as clues.
                      Severity: Minor
                      Found in random-bits/cacti-integrate.php - About 3 hrs to fix

                        Method generateOutlines has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function generateOutlines()
                            {
                                MapUtility::debug("Calculating angled-style outline\n");
                        
                                foreach ($this->directions as $direction) {
                        Severity: Major
                        Found in lib/Weathermap/Core/AngledLinkGeometry.php - About 3 hrs to fix

                          Method drawArtificialIconNINK has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function drawArtificialIconNINK($iconImageRef, $finalInkColour, &$map)
                              {
                                  $xRadius = $this->iconscalew / 2 - 1;
                                  $yRadius = $this->iconscaleh / 2 - 1;
                                  $size = $this->iconscalew;
                          Severity: Major
                          Found in lib/Weathermap/Core/MapNode.php - About 3 hrs to fix

                            Function drawMap has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function drawMap(
                                    $imageFileName = '',
                                    $thumbnailFileName = '',
                                    $thumbnailMaxSize = 250,
                                    $includeNodes = true,
                            Severity: Minor
                            Found in lib/Weathermap/Core/Map.php - About 3 hrs to fix

                            Cognitive Complexity

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

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

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

                            Further reading

                            Severity
                            Category
                            Status
                            Source
                            Language