howardjones/network-weathermap

View on GitHub

Showing 1,091 of 1,093 total issues

Method drawLegendHorizontal has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function drawLegendHorizontal($keyWidth = 400)
    {

        $title = $this->keytitle;

Severity: Major
Found in lib/Weathermap/Core/Legend.php - About 3 hrs to fix

    Function dumpKeywords has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function dumpKeywords()
        {
            $count = 0;
            print "# Complete configuration keyword list\n\n";
            foreach ($this->configKeywords as $scope => $keywords) {
    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

    Function renameNode has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function renameNode($oldName, $newName)
        {
            if (!$this->map->nodeExists($oldName)) {
                return $oldName;
            }
    Severity: Minor
    Found in lib/Weathermap/Editor/Editor.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 getAvailableImages has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getAvailableImages($imageDirectory, $map)
        {
            $imageList = array();
    
            if (is_dir($imageDirectory)) {
    Severity: Minor
    Found in lib/Weathermap/Editor/EditorUI.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 UIBase.php has 295 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Weathermap\UI;
    
    use Weathermap\Core\WeathermapInternalFail;
    Severity: Minor
    Found in lib/Weathermap/UI/UIBase.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 readFromRealRRDtoolWithAggregate has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          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/WeatherMapCactiManagementPlugin.php on lines 229..244

          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

          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

          Method readFromPollerOutput has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function readFromPollerOutput($rrdfile, $cf, $start, $end, $dsnames, &$map, &$item)
              {
                  global $config;
          
                  $pdo = weathermap_get_pdo();
          Severity: Major
          Found in lib/Weathermap/Plugins/Datasources/RRDTool.php - About 3 hrs to fix

            Method showMainPage has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function showMainPage($editor)
                {
                    global $hostPluginURL;
                    global $hostEditorURL;
                    global $hostType;
            Severity: Major
            Found in lib/Weathermap/Editor/EditorUI.php - About 2 hrs to fix

              Function generateOutlines has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function generateOutlines()
                  {
                      MapUtility::debug("Calculating angled-style outline\n");
              
                      foreach ($this->directions as $direction) {
              Severity: Minor
              Found in lib/Weathermap/Core/AngledLinkGeometry.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 initializeDatabase has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function initializeDatabase()
                  {
                      // only bother with all this if it's a new install, a new version, or we're in a development version
                      // - saves a handful of db hits per request!
              
              
              Severity: Minor
              Found in lib/Weathermap/Integrations/MapManager.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 main has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function main($request, $cookies, $fromPlugin = false)
                  {
                      $mapFileName = "";
                      $action = "";
              
              
              Severity: Minor
              Found in lib/Weathermap/Editor/EditorUI.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 drawLegendVertical has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function drawLegendVertical($keyHeight = 400, $inverted = false)
                  {
                      $title = $this->keytitle;
              
                      $nScales = $this->scale->spanCount();
              Severity: Major
              Found in lib/Weathermap/Core/Legend.php - About 2 hrs to fix

                File Runner.php has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace Weathermap\CLI;
                
                use GetOpt\GetOpt;
                Severity: Minor
                Found in lib/Weathermap/CLI/Runner.php - About 2 hrs to fix

                  Method drawLabel has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function drawLabel(&$map, $textPoint, $backgroundColour, $nodeImageRef, $labelBox)
                      {
                          MapUtility::debug("Label colour is $backgroundColour\n");
                  
                          // if there's an icon, then you can choose to have no background
                  Severity: Major
                  Found in lib/Weathermap/Core/MapNode.php - About 2 hrs to fix

                    Function handleInheritance has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function handleInheritance($inheritables, $params)
                        {
                            $defaultLink = $this->map->getLink("DEFAULT");
                            $defaultNode = $this->map->getNode("DEFAULT");
                    
                    
                    Severity: Minor
                    Found in lib/Weathermap/Editor/Editor.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 readData has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

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

                          public function readData($targetString, &$map, &$mapItem)
                          {
                              $this->data[IN] = null;
                              $this->data[OUT] = null;
                      
                      
                      Severity: Major
                      Found in lib/Weathermap/Plugins/Datasources/SNMP2c.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language