Showing 289 of 291 total issues
Function ip_address
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
public static function ip_address($proxy_ips = [])
{
if (self::$ip_address) {
return self::$ip_address;
}
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
public function group($shared, $list)
{
$middleware = null;
$sharedPath = '';
$sharedNamespace = '';
- 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 232.
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
public function group($shared, $list)
{
$middleware = null;
$sharedPath = '';
$sharedNamespace = '';
- 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 232.
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
Function seekRouteByTreeForKeychain
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
protected function seekRouteByTreeForKeychain($tree, $keychain, $method, &$params = [])
{
if ($this->debug) {
echo __METHOD__ .
' tree nodes: ' . json_encode(array_keys($tree)) .
- 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 buildHTML
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildHTML($content, $components)
{
$autoURLBase = $this->getURLRootString();
$title = $this->wikiTitle;
$navigator = "";
Function executeCurl
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public static function executeCurl($method, $url, $data = null, $headers = [], $cookies = [], $bodyAsJson = false, $logger = null)
{
//$logger = $this->getFileLogger();
$ch = curl_init();
- 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 LibPDO.php
has 314 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Created by PhpStorm.
* User: Sinri
* Date: 2017/7/14
File LibRequest.php
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Created by PhpStorm.
* User: Sinri
* Date: 2017/5/9
Function loadController
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function loadController($basePath, $controllerClass, $middleware = null)
{
$method_list = get_class_methods($controllerClass);
$reflector = new \ReflectionClass($controllerClass);
foreach ($method_list as $method) {
- 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
LibPDO
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class LibPDO
{
/**
* @var \PDO
*/
The class Adah has an overall complexity of 60 which is very high. The configured complexity threshold is 50. Open
class Adah extends RouterInterface
{
const ROUTE_PARAM_METHOD = "METHOD";
const ROUTE_PARAM_PATH = "PATH";
const ROUTE_PARAM_CALLBACK = "CALLBACK";
- Exclude checks
LibRequest
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class LibRequest
{
const METHOD_ANY = "ANY";//since v2.1.3 for TreeRouter
const METHOD_HEAD = "HEAD";//since v1.3.0
The class Zillah has an overall complexity of 77 which is very high. The configured complexity threshold is 50. Open
class Zillah extends RouterInterface
{
const ROUTE_PARAM_METHOD = "METHOD";
const ROUTE_PARAM_PATH = "PATH";
const ROUTE_PARAM_CALLBACK = "CALLBACK";
- Exclude checks
The class LibPDO has an overall complexity of 69 which is very high. The configured complexity threshold is 50. Open
class LibPDO
{
/**
* @var \PDO
*/
- Exclude checks
The class Lamech has an overall complexity of 57 which is very high. The configured complexity threshold is 50. Open
class Lamech
{
protected $gateway = "index.php";
protected $session_dir;
protected $router;
- Exclude checks
The class LibRequest has an overall complexity of 78 which is very high. The configured complexity threshold is 50. Open
class LibRequest
{
const METHOD_ANY = "ANY";//since v2.1.3 for TreeRouter
const METHOD_HEAD = "HEAD";//since v1.3.0
- Exclude checks
The class CommonHelper has an overall complexity of 53 which is very high. The configured complexity threshold is 50. Open
class CommonHelper
{
/**
* 按照PSR-0规范,不过PSR-4看起来也是支持的
* @since 2.0.0 turn to static
- Exclude checks
Function loadAllControllersInDirectoryAsCI
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function loadAllControllersInDirectoryAsCI($directory, $urlBase = '', $controllerNamespaceBase = '', $middleware = '')
{
if (!file_exists($directory) || !is_dir($directory)) {
if ($this->debug) {
echo __METHOD__ . " warning: this is not a direcoty: " . $directory . PHP_EOL;
- 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 seekRouteByTreeForKeychain
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function seekRouteByTreeForKeychain($tree, $keychain, $method, &$params = [])
{
if ($this->debug) {
echo __METHOD__ .
' tree nodes: ' . json_encode(array_keys($tree)) .
Function buildCondition
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected final function buildCondition($conditions, $glue = 'AND')
{
$condition_sql = "";
if (is_string($conditions)) {
$condition_sql = $conditions;
- 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"