howardjones/network-weathermap

View on GitHub

Showing 463 of 1,093 total issues

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

    private function resolveRelativePositions()
Severity: Critical
Found in lib/Weathermap/Core/Map.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 21 to the 15 allowed.
Open

    protected function generateOutlines()

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

    private function ping(&$item, $targetAddress, $pingCount)

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

    public function generateSortedImagemap($imagemapname)
Severity: Critical
Found in lib/Weathermap/Core/Map.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 init(&$map)

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

    public function calculateImagemap()
Severity: Critical
Found in lib/Weathermap/Core/Map.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 54 to the 15 allowed.
Open

    public function getConfig()
Severity: Critical
Found in lib/Weathermap/Core/MapLink.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

    private function readFromRealRRDtoolWithAggregate(

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 asString($format = 'RGB(%d,%d,%d)')
Severity: Major
Found in lib/Weathermap/Core/Colour.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;
}

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

    private function processStringFindReferredObject(&$context, $itemname, $type)
Severity: Major
Found in lib/Weathermap/Core/Map.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 28 to the 15 allowed.
Open

    public function init(&$map)

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 processString($input, &$context, $includeNotes = true, $multiline = false)
Severity: Major
Found in lib/Weathermap/Core/Map.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;
}

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

    public static function testCronPart($value, $checkstring)
Severity: Major
Found in lib/Weathermap/Core/Utility.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;
}

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

    public function readData($targetString, &$map, &$mapItem)

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

    public function getConfig()
Severity: Critical
Found in lib/Weathermap/Core/Map.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 49 to the 15 allowed.
Open

    private function readFromPollerOutput($rrdfile, $cf, $start, $end, $dsnames, &$map, &$item)

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

    private function readFromRealRRDtool($rrdfile, $cf, $start, $end, $dsnames, &$map, &$item)

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

    public function readData($targetString, &$map, &$mapItem)

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

    public function colourFromValue($value, $itemName = '', $isPercentage = true, $showScaleWarnings = true)
Severity: Critical
Found in lib/Weathermap/Core/MapScale.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 readFromRealRRDtoolWithAggregate(
        $rrdfile,
        $cf,
        $aggregatefn,
        $start,

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