Method getNotSupportedSubjects
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getNotSupportedSubjects()
{
$content = $this->createPhakeContent();
$trashItem = $this->createPhakeTrashItem();
$site = $this->createPhakeSite();
- Create a ticketCreate a ticket
Method testVote
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function testVote($object, $attribute, array $roles, $inPerimeter, $expectedVote, $inProfile = true)
- Create a ticketCreate a ticket
The method testVote has a boolean flag argument $inProfile, which is a certain sign of a Single Responsibility Principle violation. Open
public function testVote($object, $attribute, array $roles, $inPerimeter, $expectedVote, $inProfile = true)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Avoid using static access to class '\Phake' in method 'setUp'. Open
$profileCollection = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowProfileCollectionInterface');
- 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->workflowRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface');
- 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 'testVote'. Open
Phake::when($this->workflowRepository)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- 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
Phake::when($this->group)->getWorkflowProfileCollection(Phake::anyParameters())->thenReturn($profileCollection);
- 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->profile = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowProfileInterface');
- 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 'testVote'. Open
Phake::when($this->profile)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- 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
Call to method when
from undeclared class \Phake
Open
Phake::when($profileCollection)->getProfiles()->thenReturn(array($this->profile));
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Trash Item' => array($trashItem , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Group' => array($group , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Workflow profile' => array($profile , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Trash Restore' => array($node, ContributionActionInterface::TRASH_RESTORE, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_GRANTED
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Ok : Contributor' => array($node, $status, array(ContributionRoleInterface::NODE_CONTRIBUTOR), true , VoterInterface::ACCESS_GRANTED, true),
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$this->profile = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowProfileInterface');
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->workflowRepository)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Api client' => array($client , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Read' => array($node, ContributionActionInterface::READ , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Edit' => array($node, ContributionActionInterface::EDIT , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_DENIED
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Not in perimeter : Contributor' => array($node, $status, array(ContributionRoleInterface::NODE_CONTRIBUTOR), false, VoterInterface::ACCESS_DENIED, false),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Delete' => array($node, ContributionActionInterface::DELETE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->group)->getWorkflowProfileCollection(Phake::anyParameters())->thenReturn($profileCollection);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Site' => array($site , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Content type' => array($contentType, $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($this->profile)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- Create a ticketCreate a ticket
- Exclude checks
Call to method anyParameters
from undeclared class \Phake
Open
Phake::when($this->workflowRepository)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Log' => array($log , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Create' => array($node, ContributionActionInterface::CREATE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Call to method anyParameters
from undeclared class \Phake
Open
Phake::when($this->profile)->hasTransition(Phake::anyParameters())->thenReturn($inProfile);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Keyword' => array($keyword , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_GRANTED
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Ok : Developper' => array($node, $status, array(ContributionRoleInterface::DEVELOPER) , false, VoterInterface::ACCESS_GRANTED, true),
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$this->workflowRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface');
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Content' => array($content , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Call to method mock
from undeclared class \Phake
Open
$profileCollection = Phake::mock('OpenOrchestra\ModelInterface\Model\WorkflowProfileCollectionInterface');
- Create a ticketCreate a ticket
- Exclude checks
Call to method anyParameters
from undeclared class \Phake
Open
Phake::when($this->group)->getWorkflowProfileCollection(Phake::anyParameters())->thenReturn($profileCollection);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : User' => array($user , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Status' => array($status , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad attribute : Trash Purge' => array($node, ContributionActionInterface::TRASH_PURGE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Call to method when
from undeclared class \Phake
Open
Phake::when($node)->getStatus()->thenReturn($status);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ACCESS_ABSTAIN
from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open
'Bad subject : Redirection' => array($redirection, $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace OpenOrchestra\Workflow\Tests\Security\Authorization\Voter;
use OpenOrchestra\Backoffice\Security\ContributionActionInterface;
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 1249.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Line exceeds 120 characters; contains 126 characters Open
$this->workflowRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface');
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Content' => array($content , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Create' => array($node, ContributionActionInterface::CREATE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Trash Item' => array($trashItem , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Redirection' => array($redirection, $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Read' => array($node, ContributionActionInterface::READ , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Trash Purge' => array($node, ContributionActionInterface::TRASH_PURGE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Content type' => array($contentType, $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Delete' => array($node, ContributionActionInterface::DELETE , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : User' => array($user , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
'Ok : Developper' => array($node, $status, array(ContributionRoleInterface::DEVELOPER) , false, VoterInterface::ACCESS_GRANTED, true),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Site' => array($site , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
'Ok : Contributor' => array($node, $status, array(ContributionRoleInterface::NODE_CONTRIBUTOR), true , VoterInterface::ACCESS_GRANTED, true),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Edit' => array($node, ContributionActionInterface::EDIT , array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
'Not in perimeter : Contributor' => array($node, $status, array(ContributionRoleInterface::NODE_CONTRIBUTOR), false, VoterInterface::ACCESS_DENIED, false),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Api client' => array($client , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Workflow profile' => array($profile , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$this->voter = new NodeWorkflowVoter($this->accessDecisionManager, $this->perimeterManager, $this->workflowRepository);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Log' => array($log , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Keyword' => array($keyword , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 187 characters Open
'Bad attribute : Trash Restore' => array($node, ContributionActionInterface::TRASH_RESTORE, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Group' => array($group , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
'Bad subject : Status' => array($status , $status, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),
- Create a ticketCreate a ticket
- Exclude checks