Showing 21 of 21 total issues
Function retrieveContent
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function retrieveContent($tableName, $mapping, $geometry, $options = array())
{
/*
* Return WKT if specified in config file
- 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 PoliticalTagger.php
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Copyright 2013 Jérôme Gasperi
*
* Licensed under the Apache License, version 2.0 (the "License");
Method tag
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function tag($metadata, $taggers = array())
{
if (!isset($metadata['geometry'])) {
throw new Exception('Missing mandatory geometry', 500);
}
Method retrieveContent
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function retrieveContent($tableName, $mapping, $geometry, $options = array())
{
/*
* Return WKT if specified in config file
Function add
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function add(&$continents, $geometry, $what)
{
$prequery = 'WITH prequery AS (SELECT ' . $this->postgisGeomFromText($geometry) . ' AS corrected_geometry)';
if ($what === PoliticalTagger::COUNTRIES) {
$query = $prequery . ' SELECT name as name, concat(normalize_initcap(name), \'' . iTag::TAG_SEPARATOR . '\', geonameid) as id, continent as continent, normalize_initcap(continent) as continentid, ' . $this->postgisArea($this->postgisIntersection('geom', 'corrected_geometry')) . ' as area, ' . $this->postgisArea('geom') . ' as entityarea FROM prequery, datasources.countries WHERE st_intersects(geom, corrected_geometry) ORDER BY area DESC';
- 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 tag
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function tag($metadata, $taggers = array())
{
if (!isset($metadata['geometry'])) {
throw new Exception('Missing mandatory geometry', 500);
}
- 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 getParams
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function getParams()
{
// Input query
$query = $this->sanitize(filter_input_array(INPUT_GET));
- 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 getParams
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getParams()
{
// Input query
$query = $this->sanitize(filter_input_array(INPUT_GET));
Function mergeRegion
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function mergeRegion(&$regions, $element)
{
if (!isset($element['regionid']) || !$element['regionid']) {
array_push($regions, array(
'states' => array()
- 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 mergeRegion
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function mergeRegion(&$regions, $element)
{
if (!isset($element['regionid']) || !$element['regionid']) {
array_push($regions, array(
'states' => array()
Method addCountriesToContinents
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addCountriesToContinents(&$continents, $element)
{
$index = -1;
for ($i = count($continents); $i--;) {
if ($continents[$i]['name'] === $element['continent']) {
Function mergeRegionsAndStates
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function mergeRegionsAndStates(&$country, $element)
{
$index = -1;
for ($k = count($country['regions']); $k--;) {
if (!$element['regionid'] && !isset($country['regions'][$k]['id'])) {
- 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 retrieveRawLandCover
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function retrieveRawLandCover($geometry)
{
$classes = array();
$prequery = 'WITH prequery AS (SELECT ' . $this->postgisGeomFromText($geometry) . ' AS corrected_geometry)';
if ($this->config['returnGeometries']) {
- 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 addRegionsToCountries
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function addRegionsToCountries(&$continents, $element)
{
for ($i = count($continents); $i--;) {
for ($j = count($continents[$i]['countries']); $j--;) {
$countryName = isset(CountryInfos::$countryNames[$element['isoa3']]) ? CountryInfos::$countryNames[$element['isoa3']] : 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
Function loadPHP
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function loadPHP($folder)
{
global $phps;
$files = glob($folder . "/*");
- 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 getLandCoverDetails
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getLandCoverDetails($rawLandCover)
{
$landCoverDetails = array();
foreach ($rawLandCover as $key => $val) {
if ($val['area'] !== 0) {
- 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 tag
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function tag($metadata, $options = array())
{
/*
* Relative location on earth
- 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 getLocations
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getLocations($geometry, $planet)
{
$locations = array();
foreach ($this->areas as $key => $value) {
- 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 getResults
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getResults($tableName, $mapping, $geometry, $options)
{
$propertyList = array();
$geom = $this->postgisGeomFromText($geometry);
$orderBy = '';
- 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
Avoid too many return
statements within this method. Open
return $str;