gdbots/pbjc-php

View on GitHub

Showing 579 of 579 total issues

The method getSchemas() has 112 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function getSchemas()
    {
        return [
            [
                'schema' => new SchemaDescriptor(
Severity: Minor
Found in tests/Generator/PhpGeneratorTest.php by phpmd

Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddDir'.
Open

        $this->assertCount(1, SchemaStore::getDirs());
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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

The method validate() has 154 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function validate(SchemaDescriptor $a, SchemaDescriptor $b /* ignored */)
    {
        /** @var FieldDescriptor[] $currentFields */
        /** @var FieldDescriptor[] $inheritedFields */
        $currentFields = $a->getFields();

The method getSchemas() has 196 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function getSchemas()
    {
        return [
            [
                'schema' => new SchemaDescriptor(

Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'.
Open

        SchemaStore::addSchema($schema100->getId(), $schema100);
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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 assigning values to variables in if clauses and the like (line '62', column '41').
Open

    public function validate(SchemaDescriptor $a, SchemaDescriptor $b /* ignored */)
    {
        /** @var FieldDescriptor[] $currentFields */
        /** @var FieldDescriptor[] $inheritedFields */
        $currentFields = $a->getFields();

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

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

                } else {
                    $config[$key] = $value;
                }
Severity: Minor
Found in src/Util/XmlUtils.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

Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'setUp'.
Open

        SchemaStore::addSchema(
            SchemaId::fromString('pbj:vendor2:package2:category2:message2:1-0-0'),
            new SchemaDescriptor(
                'pbj:vendor2:package2:category2:message2:1-0-0',
                [
Severity: Minor
Found in tests/SchemaDescriptorTest.php by phpmd

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 assigning values to variables in if clauses and the like (line '56', column '13').
Open

    public function validate(SchemaDescriptor $schema)
    {
        if ($prevSchema = SchemaStore::getPreviousSchema($schema->getId())) {
            if (!$prevSchema instanceof SchemaDescriptor) {
                throw new \RuntimeException(sprintf(
Severity: Minor
Found in src/SchemaValidator.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid assigning values to variables in if clauses and the like (line '16', column '17').
Open

    public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
    {
        foreach ($a->getMixins() as $mixin) {
            if ($m = $b->getMixin($mixin->getId()->getCurieWithMajorRev())) {
                if (!$m->isMixinSchema()) {

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'.
Open

        $this->assertEquals(SchemaStore::getOtherSchemaMajorRev($schema101->getId()), [$schema101, $schema200]);
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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 using static access to class '\Gdbots\Common\Util\StringUtils' in method 'getClassName'.
Open

            StringUtils::toCamelFromSlug($schema->getId()->getPackage()),

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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'.
Open

        $this->assertTrue(SchemaStore::hasOtherSchemaMajorRev($schema100->getId()));
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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 using static access to class '\Gdbots\Common\Util\StringUtils' in method 'getClassName'.
Open

            StringUtils::toCamelFromSlug($schema->getId()->getMessage()),

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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'.
Open

        SchemaStore::addSchema($schema101->getId(), $schema101);
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddEnum'.
Open

        $this->assertEquals(SchemaStore::getEnumById('vendor:package:number'), $enum);
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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 assigning values to variables in if clauses and the like (line '75', column '41').
Open

    public function validate(SchemaDescriptor $a, SchemaDescriptor $b /* ignored */)
    {
        /** @var FieldDescriptor[] $currentFields */
        /** @var FieldDescriptor[] $inheritedFields */
        $currentFields = $a->getFields();

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

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

                                            } else {
                                                eval(sprintf('class %s extends %s {};', $class, array_values($classes)[$i - 1]));
                                            }

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

Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testConstruct'.
Open

        $found = preg_grep('/pbj:acme:*/', array_keys(SchemaStore::getSchemas()));
Severity: Minor
Found in tests/CompilerTest.php by phpmd

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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddEnum'.
Open

        SchemaStore::addEnum($enum->getId(), $enum);
Severity: Minor
Found in tests/SchemaStoreTest.php by phpmd

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

Severity
Category
Status
Source
Language