Function selectRelationshipEntities
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function selectRelationshipEntities(
Params $params, array $entities
)
{
$selected = [];
- 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 canAccessEntities
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function canAccessEntities(Params $params, Collection $entities)
{
$access = NULL;
if (RequestAction::TARGET_RELATIONSHIP === $params->action->target) {
- 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
The class ParamEntityFinder has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13. Open
class ParamEntityFinder
{
const ACCESS_VIEW = 'view',
ACCESS_EDIT = 'edit',
ACCESS_DELETE = 'delete';
- 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
Avoid using static access to class '\GoIntegro\Hateoas\Util\Inflector' in method 'findRelationshipEntities'. Open
$method = 'get' . Util\Inflector::camelize($params->relationship);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$params'. Open
Params $params, array $entities
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid variables with short names like $em. Configured minimum length is 3. Open
private $em;
- 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 $em. Configured minimum length is 3. Open
EntityManagerInterface $em,
- 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 closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Params $params, array $entities
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Open
$access = NULL;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE" Open
return TRUE;
- Exclude checks
There must be one USE keyword per declaration Open
use Doctrine\Common\Collections\Collection,
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Params $params, array $entities
- Exclude checks
There must be one USE keyword per declaration Open
use Symfony\Component\Security\Core\SecurityContextInterface,
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE" Open
return FALSE;
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
(string) $entity->getId(), $params->relationshipIds
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
self::ACCESS_VIEW, $entity
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
self::ACCESS_VIEW, $entity
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
ERROR_ACCESS_CONTROL_FILTER = "Access control voters are not being supported properly by corresponding query filters.";
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks