open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/Security/Authorization/Voter/SiteAdministrationVoterTest.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method getBadRoles has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getBadRoles()
    {
        $actions = array(
            'Read'   => ContributionActionInterface::READ,
            'Edit'   => ContributionActionInterface::EDIT,

Method getOkVotes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getOkVotes()
    {
        $log = $this->createPhakeLog();
        $site = $this->createPhakeSite();
        $redirection = $this->createPhakeRedirection();

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

    protected function getBadRoles()
    {
        $actions = array(
            'Read'   => ContributionActionInterface::READ,
            'Edit'   => ContributionActionInterface::EDIT,

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

The class SiteAdministrationVoterTest has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Open

class SiteAdministrationVoterTest extends AbstractVoterTest
{
    /**
     * Set up the test
     */

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : create site'        => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : create redirection' => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Status'                  => array($status,                               ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Entity type Keyword'     => array(KeywordInterface::ENTITY_TYPE,         ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Delete group'       => array($group,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open

            'entity type site'        => SiteInterface::ENTITY_TYPE,

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : read user'          => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Content type'            => array($contentType,                          ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\KeywordInterface
Open

            'Bad subject : Entity type Keyword'     => array(KeywordInterface::ENTITY_TYPE,         ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Read redirection'   => array($redirection, ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

                    $badRoles[$key1 . $key2 . $label] = array($subject, $action, $role, true, VoterInterface::ACCESS_DENIED);

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open

            'Ok : create site'        => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Read site'          => array($site,        ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Delete site'        => array($site,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open

            'Ok : read site'          => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Node'                    => array($node,                                 ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Trash Item'              => array($trashItem,                            ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Entity type Workflow'    => array(WorkflowProfileInterface::ENTITY_TYPE, ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Delete site'        => array($site,                             ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Delete user'        => array($user,                             ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Entity type Api client'  => array(ApiClientInterface::ENTITY_TYPE,       ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad action : Trash Purge'   => array($site, ContributionActionInterface::TRASH_PURGE,   array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Workflow profile'        => array($profile,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Entity type ContentType' => array(ContentTypeInterface::ENTITY_TYPE,     ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Edit site'          => array($site,        ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

            'entity type user'        => UserInterface::ENTITY_TYPE,

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : create log'         => array(LogInterface::ENTITY_TYPE,         ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : create user'        => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

            'entity type redirection' => RedirectionInterface::ENTITY_TYPE,

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Api client'              => array($client,                               ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Entity type Status'      => array(StatusInterface::ENTITY_TYPE,          ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\BaseApi\Model\ApiClientInterface
Open

            'Bad subject : Entity type Api client'  => array(ApiClientInterface::ENTITY_TYPE,       ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Edit redirection'   => array($redirection, ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Delete redirection' => array($redirection,                      ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Edit group'         => array($group,                            ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

            'Ok : read redirection'   => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad action : Trash Restore' => array($site, ContributionActionInterface::TRASH_RESTORE, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Read group'         => array($group,       ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Edit site'          => array($site,                             ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : read site'          => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : read log'           => array(LogInterface::ENTITY_TYPE,         ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Delete redirection' => array($redirection, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

            'Bad subject : Entity type ContentType' => array(ContentTypeInterface::ENTITY_TYPE,     ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Delete log'         => array($log,                              ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Edit redirection'   => array($redirection,                      ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Delete group'       => array($group,                            ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Content'                 => array($content,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_ABSTAIN from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Bad subject : Keyword'                 => array($keyword,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\WorkflowProfileInterface
Open

            'Bad subject : Entity type Workflow'    => array(WorkflowProfileInterface::ENTITY_TYPE, ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

            'Bad subject : Entity type Status'      => array(StatusInterface::ENTITY_TYPE,          ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Read user'          => array($user,        ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Edit user'          => array($user,        ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Edit user'          => array($user,                             ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : read redirection'   => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Edit group'         => array($group,       ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

            'Ok : create redirection' => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_DENIED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Not in perimeter : Delete user'        => array($user,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : Edit log'           => array($log,                              ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_GRANTED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

            'Ok : read user'          => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

            'Ok : create user'        => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : read group'         => array(GroupInterface::ENTITY_TYPE,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Reference to constant ACCESS_GRANTED from undeclared class \Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
Open

            'Ok : create group'       => array(GroupInterface::ENTITY_TYPE,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    protected function getNotSupportedAttributes()
    {
        $site = $this->createPhakeSite();

        return array(
Backoffice/Tests/Security/Authorization/Voter/ContentVoterTest.php on lines 77..85
Backoffice/Tests/Security/Authorization/Voter/DeveloperToolVoterTest.php on lines 75..83
Backoffice/Tests/Security/Authorization/Voter/NodeNotHydratedVoterTest.php on lines 84..92
Backoffice/Tests/Security/Authorization/Voter/NodeVoterTest.php on lines 82..90
Backoffice/Tests/Security/Authorization/Voter/PlatformAdministrationVoterTest.php on lines 78..86

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 92.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        foreach ($actions as $label => $action) {
            $key1 = 'Bad role (' . $label;

            foreach ($subjects as $label => $subject) {
                $key2 = ' ' . $label . ') : ';
Backoffice/Tests/Security/Authorization/Voter/DeveloperToolVoterTest.php on lines 129..139

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 91.

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

Further Reading

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Node'                    => array($node,                                 ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Entity type Api client'  => array(ApiClientInterface::ENTITY_TYPE,       ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Entity type ContentType' => array(ContentTypeInterface::ENTITY_TYPE,     ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Read site'          => array($site,        ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Edit log'           => array($log,                              ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Edit site'          => array($site,        ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Delete group'       => array($group,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 125 characters
Open

                    $badRoles[$key1 . $key2 . $label] = array($subject, $action, $role, true, VoterInterface::ACCESS_DENIED);

Line exceeds 120 characters; contains 184 characters
Open

            'Bad action : Trash Restore' => array($site, ContributionActionInterface::TRASH_RESTORE, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Delete redirection' => array($redirection, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Delete site'        => array($site,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Edit user'          => array($user,        ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Delete log'         => array($log,                              ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Entity type Workflow'    => array(WorkflowProfileInterface::ENTITY_TYPE, ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Entity type Status'      => array(StatusInterface::ENTITY_TYPE,          ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Read redirection'   => array($redirection, ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Content'                 => array($content,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Content type'            => array($contentType,                          ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Workflow profile'        => array($profile,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Edit user'          => array($user,                             ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : read redirection'   => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : read log'           => array(LogInterface::ENTITY_TYPE,         ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Read group'         => array($group,       ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Trash Item'              => array($trashItem,                            ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Keyword'                 => array($keyword,                              ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Read user'          => array($user,        ContributionActionInterface::READ,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Delete user'        => array($user,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Edit redirection'   => array($redirection,                      ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : read user'          => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 184 characters
Open

            'Bad action : Trash Purge'   => array($site, ContributionActionInterface::TRASH_PURGE,   array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : create group'       => array(GroupInterface::ENTITY_TYPE,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Edit redirection'   => array($redirection, ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : read site'          => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 196 characters
Open

            'Not in perimeter : Edit group'         => array($group,       ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), false, VoterInterface::ACCESS_DENIED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Edit group'         => array($group,                            ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Status'                  => array($status,                               ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Delete group'       => array($group,                            ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : create redirection' => array(RedirectionInterface::ENTITY_TYPE, ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : read group'         => array(GroupInterface::ENTITY_TYPE,       ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Api client'              => array($client,                               ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), true, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Delete redirection' => array($redirection,                      ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : create site'        => array(SiteInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : create user'        => array(UserInterface::ENTITY_TYPE,        ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 218 characters
Open

            'Bad subject : Entity type Keyword'     => array(KeywordInterface::ENTITY_TYPE,         ContributionActionInterface::READ, array(ContributionRoleInterface::DEVELOPER), null, VoterInterface::ACCESS_ABSTAIN),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Edit site'          => array($site,                             ContributionActionInterface::EDIT,   array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Delete site'        => array($site,                             ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : Delete user'        => array($user,                             ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

Line exceeds 120 characters; contains 204 characters
Open

            'Ok : create log'         => array(LogInterface::ENTITY_TYPE,         ContributionActionInterface::DELETE, array(ContributionRoleInterface::SITE_ADMIN), true,  VoterInterface::ACCESS_GRANTED),

There are no issues that match your filters.

Category
Status