Showing 662 of 662 total issues
Avoid excessively long variable names like $paginationLinksSerializer. Keep variable name length under 20. Open
private $paginationLinksSerializer;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $topLevelLinkSerializer. Keep variable name length under 20. Open
Serializer\TopLevelLinksSerializer $topLevelLinkSerializer,
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Function setRelationships
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function setRelationships(
\ReflectionClass $class,
ResourceEntityInterface $entity,
array $relationships
)
- 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 hydrate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function hydrate(Params $params, array &$resourceObject)
{
if (empty($resourceObject[self::LINKS])) {
return;
} elseif (!is_array($resourceObject[self::LINKS])) {
- 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 mergeLinkedResources
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function mergeLinkedResources(array &$champion, array $challenger)
{
static $key = 'linked';
if (isset($champion[$key]) || isset($challenger[$key])) {
- 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 serializeTransationObject
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function serializeTransationObject(array $resourceTranslations)
{
$translations = [];
foreach (
- 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 mergeResourceMeta
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function mergeResourceMeta(array &$champion, array $challenger)
{
static $key = 'meta';
if (isset($champion[$key]) || isset($challenger[$key])) {
- 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 serialize
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function serialize()
{
$metadata = $this->resource->getMetadata();
$json = [
'id' => $this->resource->id,
Method parse
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse(Request $request)
{
$content = $request->getContent();
if (!empty($content) && self::HTTP_DELETE == $request->getMethod()) {
The class Params has 16 fields. Consider redesigning Params to keep the number of fields under 15. Open
class Params
{
const ASCENDING_ORDER = Criteria::ASC,
DESCENDING_ORDER = Criteria::DESC,
DEFAULT_PAGE_OFFSET = 0,
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method processToManyRelationship
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processToManyRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
Method parse
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse(Request $request, Params $params, array $body)
{
$entityData = [];
if (empty($body[$params->primaryType])) {
Function parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function parse(Request $request, Params $params, array $body)
{
$translations = [];
if (
- 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 parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function parse(Request $request, Params $params, array $body)
{
$entityData = [];
if (empty($body[$params->primaryType])) {
- 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 hydrate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function hydrate(Params $params, array &$resourceObject)
{
if (empty($resourceObject[self::LINKS])) {
return;
} elseif (!is_array($resourceObject[self::LINKS])) {
Method processToOneRelationship
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processToOneRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
Function serialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function serialize()
{
$metadata = $this->resource->getMetadata();
$json = [
'id' => $this->resource->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 serialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function serialize(JsonApi\Document $document)
{
$json = [];
if ($document->i18n) {
- 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 __construct
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
ResourceEntityMapper $resourceEntityMapper,
DocNavigator $docNavigator,
FilterParser $filterParser,
PaginationParser $paginationParser,
BodyParser $bodyParser,
Method parse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse(Request $request, Params $params, array $body)
{
$translations = [];
if (