Function assertSameTransitions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function assertSameTransitions(array $expectedTransitions, array $flattenedTransitions)
{
foreach ($expectedTransitions as $transition) {
$flattenedTransition = $transition->getStatusFrom()->getId() . '-' . $transition->getStatusTo()->getId();
$this->assertContains($flattenedTransition, $flattenedTransitions);
- Read upRead up
- Create a ticketCreate a ticket
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 '\Phake' in method 'generateTransition'. Open
$transition = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowTransitionInterface');
- Read upRead up
- Create a ticketCreate a ticket
- 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 '\Phake' in method 'generateStatus'. Open
$status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');
- Read upRead up
- Create a ticketCreate a ticket
- 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 '\Phake' in method 'setUp'. Open
$this->statusRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface');
- Read upRead up
- Create a ticketCreate a ticket
- 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 '\Phake' in method 'setUp'. Open
$transitionFactory = Phake::mock('OpenOrchestra\Workflow\Factory\TransitionFactory');
- Read upRead up
- Create a ticketCreate a ticket
- 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 local variables such as '$transitions'. Open
$transitions = $this->transformer->reverseTransform($flattenedTransitions);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Call to method when
from undeclared class \Phake
Open
Phake::when($transition)->getStatusTo()->thenReturn($statusTo);
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($transition)->getStatusFrom()->thenReturn($statusFrom);
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$this->statusRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface');
- Create a ticketCreate a ticket
- Exclude checks
Return type of generateStatus()
is undeclared type \OpenOrchestra\Workflow\Tests\Form\Type\Phake_IMock
Open
protected function generateStatus($id)
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($status)->getId()->thenReturn($id);
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->statusRepository)->findOneById($transition->getStatusFrom()->getId())
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->statusRepository)->findOneById($transition->getStatusTo()->getId())
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractBaseTestCase
Open
class ProfileTransitionsTransformerTest extends AbstractBaseTestCase
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertContains
Open
$this->assertContains($flattenedTransition, $flattenedTransitions);
- Create a ticketCreate a ticket
- Exclude checks
Return type of generateTransition()
is undeclared type \OpenOrchestra\Workflow\Tests\Form\Type\Phake_IMock
Open
protected function generateTransition($fromId, $toId)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertSame
Open
$this->assertSame($expectedTransitions, $flattenedTransitions);
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$transitionFactory = Phake::mock('OpenOrchestra\Workflow\Factory\TransitionFactory');
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$transition = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowTransitionInterface');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\Workflow\Tests\Form\Type\ProfileTransitionsTransformerTest::assertTrue
Open
$this->assertTrue($transitionOk);
- Create a ticketCreate a ticket
- Exclude checks
Avoid variables with short names like $id. Configured minimum length is 3. Open
protected function generateStatus($id)
- Read upRead up
- Create a ticketCreate a ticket
- 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 variable $transition_1 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_3 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_1 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_2 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_3 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_2 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $transition_1 is not named in camelCase. Open
public function provideTransitions()
{
$transition_1 = $this->generateTransition('from1', 'to2');
$transition_2 = $this->generateTransition('from2', 'to3');
$transition_3 = $this->generateTransition('from3', 'to1');
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}