Showing 106 of 106 total issues
File SQL.php
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This is Spoof.
* Copyright (C) 2011-2017 Spoof project.
The class ModelList has 12 public methods. Consider refactoring ModelList to keep number of public methods under 10. Open
class ModelList implements IModelList
{
/**
* List of records to iterate over
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class SQL has an overall complexity of 73 which is very high. The configured complexity threshold is 50. Open
class SQL implements ILanguage
{
const SELECT = 'select';
const SELECT_AS = 'as';
const SELECT_FIELD_SEPARATOR = ', ';
- Exclude checks
Method __construct
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($value, $type = null)
{
// validate type and value
if (is_null($type)) {
$type = $this->determineType($value);
Function __construct
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($value, $type = null)
{
// validate type and value
if (is_null($type)) {
$type = $this->determineType($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 getConditionOperator
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function getConditionOperator(IDriver $driver, ICondition $condition)
{
switch ($condition->operator) {
case Condition::OPERATOR_EQUALS:
if ($condition->value2->getType() == Value::TYPE_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 getConditionOperator
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConditionOperator(IDriver $driver, ICondition $condition)
{
switch ($condition->operator) {
case Condition::OPERATOR_EQUALS:
if ($condition->value2->getType() == Value::TYPE_NULL) {
Method getValue
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getValue(IDriver $driver, IValue $value)
{
$query = new Query();
switch ($value->getType()) {
case Value::TYPE_PREPARED:
Method handleRequest
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handleRequest(api\Request $request)
{
$response = new api\Response();
try {
// map request to class and method
Method getJoin
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getJoin(IDriver $driver, IJoin $join)
{
$query = new Query();
$query->setString($driver->tableQuoteStart . $join->tableBase . $driver->tableQuoteEnd);
foreach ($join->tableJoin as $i => $table) {
Function bindValues
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function bindValues(\PDOStatement $sth, array $values = null)
{
if (!is_null($values)) {
foreach ($values as $key => $value) {
$type = \PDO::PARAM_STR;
- 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 getCondition
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function getCondition(array $conditions) {
$conditionGroup = null;
if (count($conditions) == 1) {
foreach ($conditions as $column => $value) {
$conditionGroup = new Condition(
- 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 sendResponse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendResponse(api\Response $response)
{
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ?
$_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
$body = null;
Function get
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function get($type, $name)
{
if (isset(self::$objects[$type]) && isset(self::$objects[$type][$name])) {
$object = self::$objects[$type][$name];
} else {
- 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 getValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getValue(IDriver $driver, IValue $value)
{
$query = new Query();
switch ($value->getType()) {
case Value::TYPE_PREPARED:
- 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 variables with short names like $db. Configured minimum length is 3. Open
public function setDB($db)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = Pool::getByName($this->db);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = Pool::getByName($this->db);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}