skqr/hateoas

View on GitHub

Showing 662 of 662 total issues

Missing class import via use statement (line '71', column '41').
Open

            $metadata->reflection = new \ReflectionClass($className);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '121', column '23').
Open

            throw new \ErrorException(self::ERROR_PARAMS_MISSING);
Severity: Minor
Found in JsonApi/DocumentFactory.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '48', column '30').
Open

        $resourceClass = new \ReflectionClass(self::DEFAULT_RESOURCE_CLASS);
Severity: Minor
Found in Metadata/Resource/MetadataMiner.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '45', column '23').
Open

            throw new \ErrorException($message);
Severity: Minor
Found in Entity/Deleter.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '74', column '31').
Open

                    throw new \BadMethodCallException();
Severity: Minor
Found in Http/Url.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '176', column '23').
Open

            throw new \Exception(sprintf(
Severity: Minor
Found in JsonApi/EntityResource.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '23', column '23').
Open

            throw new \InvalidArgumentException(self::ERROR_OBJECT_EXPECTED);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method __construct has a boolean flag argument $i18n, which is a certain sign of a Single Responsibility Principle violation.
Open

        $i18n = FALSE
Severity: Minor
Found in JsonApi/Document.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method camelize has a boolean flag argument $firstToUpper, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function camelize($word, $firstToUpper = FALSE)
Severity: Minor
Found in Util/Inflector.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '66', column '23').
Open

            throw new \InvalidArgumentException(
Severity: Minor
Found in Metadata/Resource/MinerFactory.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '53', column '23').
Open

            throw new \ErrorException($message);
Severity: Minor
Found in Entity/Builder.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '67', column '31').
Open

                    throw new \LogicException(
Severity: Minor
Found in JsonApi/Merge/Blender.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Function mergePrimaryResources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function mergePrimaryResources(array &$champion, array $challenger)
    {
        foreach ($challenger as $key => $value) {
            if (in_array($key, static::$reservedTopLevel)) continue;

Severity: Minor
Found in JsonApi/Merge/Blender.php - About 25 mins to fix

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 findTranslations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function findTranslations(JsonApi\ResourceCollection $resources)
    {
        $allTranslations = [];
        $repository = $this->em->getRepository(
            'Gedmo\\Translatable\\Entity\\Translation'
Severity: Minor
Found in JsonApi/Serializer/TranslationsMetadataSerializer.php - About 25 mins to fix

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) {
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php - About 25 mins to fix

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 getRelationships has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getRelationships($entityClassName, $primaryType)
    {
        $relationships = new ResourceRelationships;
        $metadata = $this->metadataCache->getMapping($entityClassName);
        $class = $this->metadataCache->getReflection($entityClassName);
Severity: Minor
Found in Metadata/Resource/EntityMetadataMiner.php - About 25 mins to fix

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 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function serialize()
    {
        $json = [];

        foreach ($this->error as $field => $value) {
Severity: Minor
Found in JsonApi/ErrorSerializer.php - About 25 mins to fix

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 using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'processToManyRelationship'.
Open

                = EntityResource::normalizeToManyRelation(
                    $collection, $relationshipName
                );

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 local variables such as '$entity'.
Open

            $entity = reset($entities);
Severity: Minor
Found in JsonApi/ResourceCollectionFactory.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The method create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $collection = $this->createPlain();
        }
Severity: Minor
Found in JsonApi/ResourceCollectionFactory.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Severity
Category
Status
Source
Language