Showing 59 of 59 total issues
Function getRows
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function getRows()
{
$rows = [];
$wheres = $this->queryBuilder->wheres ?: [];
- 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 getTableTags
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function getTableTags($tables, $rows)
{
$tags = [];
$type = $this->reflector->getType();
- 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 getTablesFromWhere
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getTablesFromWhere(QueryBuilder $queryBuilder, &$tables) {
if (!isset($queryBuilder->wheres)) {
return;
}
$wheres = $queryBuilder->wheres ?: [];
- 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
Consider simplifying this complex logical expression. Open
if (($type === Reflector::QUERY_TYPE_SELECT && $isSpecific) ||
($type === Reflector::QUERY_TYPE_UPDATE && !$isSpecific) ||
($type === Reflector::QUERY_TYPE_DELETE && !$isSpecific) ||
($type === Reflector::QUERY_TYPE_TRUNCATE)) {
Function tablesCachable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function tablesCachable()
{
$tables = $this->reflector->getTables();
if ($this->isInclusive()) {
- 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 $id. Configured minimum length is 3. Open
public function delete($id = null)
- 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 $as. Configured minimum length is 3. Open
public function selectSub($query, $as)
- 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
The class LadaCacheServiceProvider has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class LadaCacheServiceProvider extends ServiceProvider
{
/**
* The package configuration file.
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
ConnectionInterface $connection,
Grammar $grammar = null,
Processor $processor = null,
QueryHandler $handler,
Model $model = null
Method newPivot
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
Method endMeasuring
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function endMeasuring($type, $hash, $tags, $sql, $parameters)
Expected 1 space after FUNCTION keyword; 0 found Open
$this->app->singleton('command.lada-cache.flush', function() {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$this->app->singleton('command.lada-cache.disable', function() {
- Exclude checks
Blank line found at start of control structure Open
if ($this->writeConfig('active', "env('LADA_CACHE_ACTIVE', true)")) {
- Exclude checks
Blank line found at start of control structure Open
foreach ($joins as $join) {
- Exclude checks
Blank line found at start of control structure Open
foreach ($tables as $table) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$this->app->singleton('lada.invalidator', function($app) {
- Exclude checks
Blank line found at start of control structure Open
($type === Reflector::QUERY_TYPE_TRUNCATE)) {
- Exclude checks
Blank line found at start of control structure Open
foreach ($wheres as $where) {
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$this->app->singleton('lada.handler', function($app) {
- Exclude checks