rhosocial/yii2-organization

View on GitHub

Showing 816 of 816 total issues

The method setExitAllowWithdrawActively has a boolean flag argument $value, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function setExitAllowWithdrawActively($value = false)
Severity: Minor
Found in Organization.php by phpmd

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

Missing class import via use statement (line '292', column '23').
Open

            throw new \Exception('Failed to set up.');
Severity: Minor
Found in UserOrganizationTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

The method revokeOrganization has a boolean flag argument $revokeIfHasChildren, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function revokeOrganization($organization, $revokeIfHasChildren = true)
Severity: Minor
Found in UserOrganizationTrait.php by phpmd

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

The method role has a boolean flag argument $like, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function role($role = '', $like = false)
Severity: Minor
Found in queries/MemberQuery.php by phpmd

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

The method revokeAdmin has a boolean flag argument $keep, which is a certain sign of a Single Responsibility Principle violation.
Open

    protected function revokeAdmin($org, &$user, $keep = true)

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

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

    public function removeAdministrator(&$member, $keep = true)
    {
        if ($this->getIsNewRecord()) {
            return false;
        }
Severity: Minor
Found in Organization.php - About 25 mins to fix

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

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

    public function assignAdministrator()
    {
        $host = $this->organization;
        /* @var $host Organization */
        if ($this->isCreator()) {
Severity: Minor
Found in Member.php - About 25 mins to fix

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

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

    public function execute($user, $item, $params)
    {
        $class = Yii::$app->user->identityClass;
        if (is_numeric($user) || is_int($user)) {
            $user = $class::find()->id($user)->one();
Severity: Minor
Found in rbac/rules/RevokeDepartmentRule.php - About 25 mins to fix

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

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

    public function run($org, $user, $revoke = '0')
    {
        $organization = Module::getOrganization($org);
        static::checkAccess($organization, Yii::$app->user->identity);

Severity: Minor
Found in web/organization/controllers/my/AssignAdminAction.php - About 25 mins to fix

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

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

    protected function initMessages()
    {
        if (!is_string($this->joinSuccessMessage) || empty($this->joinSuccessMessage)) {
            $this->joinSuccessMessage = Yii::t('organization', 'Joined.');
        }
Severity: Minor
Found in web/organization/controllers/JoinController.php - About 25 mins to fix

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

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

    public function getOrganization($organization)
    {
        if (!$organization) {
            return null;
        }
Severity: Minor
Found in web/user/controllers/OrganizationController.php - About 25 mins to fix

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

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

    public function revokeAdministrator()
    {
        $host = $this->organization;
        /* @var $host Organization */
        if ($this->isCreator()) {
Severity: Minor
Found in Member.php - About 25 mins to fix

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

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

    public function setSetting($item, $value, $unique = false)
    {
        if (empty($this->organizationSettingClass) || !is_string($this->organizationSettingClass)) {
            return null;
        }
Severity: Minor
Found in Organization.php - About 25 mins to fix

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

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

    protected function setUpBaseOrganization($models)
    {
        $model = null;
        $associatedModels = [];
        if (is_array($models)) {
Severity: Minor
Found in UserOrganizationTrait.php - About 25 mins to fix

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

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

    public function execute($user, $item, $params)
    {
        $class = Yii::$app->user->identityClass;
        if (is_numeric($user) || is_int($user)) {
            $user = $class::find()->id($user)->one();
Severity: Minor
Found in rbac/rules/SetUpDepartmentRule.php - About 25 mins to fix

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 '\Yii' in method 'attributeLabels'.
Open

            $this->contentAttribute => Yii::t('organization', 'Limit'),
Severity: Minor
Found in OrganizationLimit.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 '\Yii' in method 'attributeLabels'.
Open

            $this->createdByAttribute => Yii::t('user', 'User GUID'),
Severity: Minor
Found in OrganizationLimit.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 '\Yii' in method 'attributeLabels'.
Open

            $this->parentAttribute => Yii::t('organization', 'Parent'),
Severity: Minor
Found in Organization.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 '\Yii' in method 'addMember'.
Open

                throw new ExcludeOtherMembersException(Yii::t('organization', "The organization does not allow users who have joined other organizations to join."));
Severity: Minor
Found in Organization.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 unused parameters such as '$event'.
Open

    public function onRevokePermissions($event)
Severity: Minor
Found in Organization.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Severity
Category
Status
Source
Language