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");
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");
Function imagecreatefromfile
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function imagecreatefromfile($filename)
{
$resultImage = null;
$newImage = null;
- Read upRead up
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";
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
ConfigReader
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class ConfigReader
{
private $lineCount = 0;
/** @var MapDataItem $currentObject */
private $currentObject = null;
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
- Read upRead up
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 readFromRealRRDtoolWithAggregate
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
private function readFromRealRRDtoolWithAggregate(
$rrdfile,
$cf,
$aggregatefn,
$start,
- Read upRead up
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;
Method run
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
if (!$this->preChecks()) {
return false;
}
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.");
}
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";
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
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();
- Read upRead up
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.
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) {
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;
Function drawMap
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function drawMap(
$imageFileName = '',
$thumbnailFileName = '',
$thumbnailMaxSize = 250,
$includeNodes = true,
- Read upRead up
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"