rhosocial/yii2-organization

View on GitHub

Showing 816 of 816 total issues

Function initUrlCreator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function initUrlCreator()
    {
        if (isset($this->urlCreator)) {
            return;
        }
Severity: Minor
Found in grid/OrganizationListActionColumn.php - About 45 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 actionJoin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionJoin($entrance)
    {
        $organization = static::getOrganization($entrance);
        $user = Yii::$app->user->identity;
        if ($organization->creator->equals($user)) {
Severity: Minor
Found in web/organization/controllers/JoinController.php - About 45 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

Method setUpOrganization has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function setUpOrganization($name, $nickname = '', $gravatar_type = 0, $gravatar = '', $timezone = 'UTC', $description = '')
Severity: Minor
Found in UserOrganizationTrait.php - About 45 mins to fix

    Function revokeOrganization has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function revokeOrganization($organization, $revokeIfHasChildren = true)
        {
            if (!($organization instanceof $this->organizationClass))
            {
                $class = $this->organizationClass;
    Severity: Minor
    Found in UserOrganizationTrait.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run($id)
        {
            $organization = Module::getOrganization($id);
            $user = Yii::$app->user->identity;
            static::checkAccess($organization, $user);
    Severity: Minor
    Found in web/organization/controllers/my/SettingsAction.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run()
        {
            $user = Yii::$app->user->identity;
            if ($user->hasReachedOrganizationLimit()) {
                throw new NumberOfOrganizationsExceededException();
    Severity: Minor
    Found in web/organization/controllers/my/SetUpOrganizationAction.php - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run($parent)
        {
            $model = new SetUpForm(['user' => Yii::$app->user->identity, 'parent' => $parent]);
            if (!$model->getParent()) {
                throw new BadRequestHttpException(Yii::t('organization', 'Parent Organization/Department Not Exist.'));
    Severity: Minor
    Found in web/user/controllers/organization/SetUpDepartmentAction.php - About 45 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

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

    class Organization extends User
    {
        use SelfBlameableTrait;
    
        const TYPE_ORGANIZATION = 1;
    Severity: Minor
    Found in Organization.php by phpmd

    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

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

    class Member extends BaseBlameableModel
    {
        public $createdByAttribute = 'organization_guid';
        public $updatedByAttribute = false;
        public $hostClass = Organization::class;
    Severity: Minor
    Found in Member.php by phpmd

    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

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

        public function run()
        {
            $model = new SetUpForm(['user' => Yii::$app->user->identity]);
            if ($model->load(Yii::$app->request->post())) {
                try {
    Severity: Minor
    Found in web/user/controllers/organization/SetUpOrganizationAction.php - About 35 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 revokeRole has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function revokeRole($role)
        {
            $user = $this->memberUser;
            if (!$user) {
                throw new InvalidValueException('Invalid User');
    Severity: Minor
    Found in Member.php - About 35 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 user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function user($user)
        {
            $model = $this->noInitModel;
            /* @var $model Member */
            if (!is_string($model->memberAttribute) || empty($model->memberAttribute)) {
    Severity: Minor
    Found in queries/MemberQuery.php - About 35 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

    There must be one blank line after the last USE statement; 0 found;
    Open

    use yii\widgets\Pjax;

    Space found before comma in function call
    Open

                $this->organizationSetUpSuccessMessage = Yii::t('organization' ,'Organization Set Up.');

    There must be one blank line after the last USE statement; 0 found;
    Open

    use yii\bootstrap\Alert;

    There must be one blank line after the last USE statement; 0 found;
    Open

    use yii\helpers\Html;

    Space found before comma in function call
    Open

                $this->departmentSetUpSuccessMessage = Yii::t('organization' ,'Department Set Up.');

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

        }

    Expected 1 space after FUNCTION keyword; 0 found
    Open

                'value' => function($model, $widget) use ($member) {

    There must be one blank line after the last USE statement; 0 found;
    Open

    use yii\web\View;
    Severity
    Category
    Status
    Source
    Language