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(
- Exclude checks
Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddDir'. Open
$this->assertCount(1, SchemaStore::getDirs());
- 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
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();
- Exclude checks
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(
- Exclude checks
Avoid using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'. Open
SchemaStore::addSchema($schema100->getId(), $schema100);
- 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 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();
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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',
[
- 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 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(
- Read upRead up
- Exclude checks
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()) {
- Read upRead up
- Exclude checks
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]);
- 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 using static access to class '\Gdbots\Common\Util\StringUtils' in method 'getClassName'. Open
StringUtils::toCamelFromSlug($schema->getId()->getPackage()),
- 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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'. Open
$this->assertTrue(SchemaStore::hasOtherSchemaMajorRev($schema100->getId()));
- 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 using static access to class '\Gdbots\Common\Util\StringUtils' in method 'getClassName'. Open
StringUtils::toCamelFromSlug($schema->getId()->getMessage()),
- 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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddSchema'. Open
SchemaStore::addSchema($schema101->getId(), $schema101);
- 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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddEnum'. Open
$this->assertEquals(SchemaStore::getEnumById('vendor:package:number'), $enum);
- 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 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();
- Read upRead up
- Exclude checks
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]));
}
- Read upRead up
- Exclude checks
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()));
- 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 using static access to class '\Gdbots\Pbjc\SchemaStore' in method 'testAddEnum'. Open
SchemaStore::addEnum($enum->getId(), $enum);
- 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();
}
}