howardjones/network-weathermap

View on GitHub

Showing 463 of 1,093 total issues

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

    public static function testCronPart($value, $checkstring)
Severity: Critical
Found in lib/Weathermap/Core/Utility.php by sonar-php

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 34 to the 15 allowed.
Open

    public static function debug($string)
Severity: Critical
Found in lib/Weathermap/Core/MapUtility.php by sonar-php

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

Reduce the number of returns of this function 4, down to the maximum allowed 3.
Open

    public static function sprintf($format, $value, $kilo = 1000)

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    public function updateNode($nodeName, $params)
Severity: Critical
Found in lib/Weathermap/Editor/Editor.php by sonar-php

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 22 to the 15 allowed.
Open

    public function renameNode($oldName, $newName)
Severity: Critical
Found in lib/Weathermap/Editor/Editor.php by sonar-php

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

Reduce the number of returns of this function 4, down to the maximum allowed 3.
Open

    public function resolveRelativePosition($anchorNode)
Severity: Major
Found in lib/Weathermap/Core/MapNode.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    public function preRender(&$map)
Severity: Critical
Found in lib/Weathermap/Core/MapNode.php by sonar-php

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

Reduce the number of returns of this function 5, down to the maximum allowed 3.
Open

    public static function calculateOffset($offsetstring, $width, $height)

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

Reduce the number of returns of this function 5, down to the maximum allowed 3.
Open

    private function interpretNodeSpec($input)

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

Reduce the number of returns of this function 6, down to the maximum allowed 3.
Open

    public static function simplifyOffset($xOffset, $yOffset)
Severity: Major
Found in lib/Weathermap/Editor/Editor.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    private function calculateAICONColours($labelColour, &$map)
Severity: Critical
Found in lib/Weathermap/Core/MapNode.php by sonar-php

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 "preRender" has 206 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
Open

    public function preRender(&$map)
Severity: Major
Found in lib/Weathermap/Core/MapNode.php by sonar-php

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.

Reduce the number of returns of this function 5, down to the maximum allowed 3.
Open

    public function findIndexNearDistance($targetDistance)
Severity: Major
Found in lib/Weathermap/Core/Spine.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    public function dumpKeywords()
Severity: Critical
Found in lib/Weathermap/Core/ConfigReader.php by sonar-php

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 27 to the 15 allowed.
Open

    public function imagecreatefromfile($filename)
Severity: Critical
Found in lib/Weathermap/Core/ImageLoader.php by sonar-php

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 "ConfigReader" has 30 methods, which is greater than 20 authorized. Split it into smaller classes.
Open

class ConfigReader

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.

Reduce the number of returns of this function 5, down to the maximum allowed 3.
Open

    private function readConfigLine($args, $buffer)

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    private function handleNODES($fullcommand, $args, $matches)
Severity: Critical
Found in lib/Weathermap/Core/ConfigReader.php by sonar-php

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 33 to the 15 allowed.
Open

    public function selfValidate()
Severity: Critical
Found in lib/Weathermap/Core/ConfigReader.php by sonar-php

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 has 8 parameters, which is greater than the 7 authorized.
Open

    private function tidyComplexDimension(
        $boundingBoxA,
        $boundingBoxB,
        $nodeA,
        $nodeB,
Severity: Major
Found in lib/Weathermap/Editor/Editor.php by sonar-php

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

function doSomething($param1, $param2, $param3, $param4, $param5) {
...
}

Compliant Solution

function doSomething($param1, $param2, $param3, $param4) {
...
}
Severity
Category
Status
Source
Language