rhosocial/yii2-organization

View on GitHub

Showing 816 of 816 total issues

Member has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Member extends BaseBlameableModel
{
    public $createdByAttribute = 'organization_guid';
    public $updatedByAttribute = false;
    public $hostClass = Organization::class;
Severity: Minor
Found in Member.php - About 3 hrs to fix

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

            } elseif ($revoke == '0') {
                if ($this->assignAdmin($organization, $user)) {
                    Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
                    Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, $this->assignAdminSuccessMessage);
                    return $this->controller->redirect(['member', 'org' => $org]);
    Severity: Major
    Found in web/organization/controllers/my/AssignAdminAction.php and 1 other location - About 3 hrs to fix
    web/organization/controllers/my/AssignAdminAction.php on lines 133..151

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

    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

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

            if ($revoke == '1') {
                if ($this->revokeAdmin($organization, $user)) {
                    Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
                    Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, $this->revokeAdminSuccessMessage);
                    return $this->controller->redirect(['member', 'org' => $org]);
    Severity: Major
    Found in web/organization/controllers/my/AssignAdminAction.php and 1 other location - About 3 hrs to fix
    web/organization/controllers/my/AssignAdminAction.php on lines 142..151

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

    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

    Function addMember has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addMember(&$member)
        {
            if ($this->getIsNewRecord()) {
                return false;
            }
    Severity: Minor
    Found in Organization.php - About 2 hrs 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

    File Member.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     *  _   __ __ _____ _____ ___  ____  _____
     * | | / // // ___//_  _//   ||  __||_   _|
    Severity: Minor
    Found in Member.php - About 2 hrs to fix

      Method search has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function search($params)
          {
              $query = $this->query;
              $dataProvider = new ActiveDataProvider([
                  'query' => $query,
      Severity: Major
      Found in MemberSearch.php - About 2 hrs to fix

        File UserOrganizationTrait.php has 270 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        /**
         *  _   __ __ _____ _____ ___  ____  _____
         * | | / // // ___//_  _//   ||  __||_   _|
        Severity: Minor
        Found in UserOrganizationTrait.php - About 2 hrs to fix

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

                  'user_id' => [
                      'class' => DataColumn::class,
                      'attribute' => 'id',
                      'label' => Yii::t('user', 'User ID'),
                      'content' => function ($model, $key, $index, $column) {
          Severity: Major
          Found in widgets/views/member-list.php and 1 other location - About 2 hrs to fix
          widgets/views/zh-CN/member-list.php on lines 35..49

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

          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

                  'user_id' => [
                      'class' => DataColumn::class,
                      'attribute' => 'id',
                      'label' => Yii::t('user', 'User ID'),
                      'content' => function ($model, $key, $index, $column) {
          Severity: Major
          Found in widgets/views/zh-CN/member-list.php and 1 other location - About 2 hrs to fix
          widgets/views/member-list.php on lines 35..49

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

          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

          Method search has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function search($params)
              {
                  $query = $this->query;
                  $dataProvider = new ActiveDataProvider([
                      'query' => $query,
          Severity: Major
          Found in OrganizationSearch.php - About 2 hrs to fix

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

                    try {
                        if ($organization->addMember($user)) {
                            Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
                            Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, $this->joinSuccessMessage);
                        } else {
            Severity: Major
            Found in web/organization/controllers/JoinController.php and 1 other location - About 2 hrs to fix
            web/organization/controllers/JoinController.php on lines 183..193

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

            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

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

                    try {
                        if ($organization->removeMember($user)) {
                            Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
                            Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, $this->exitSuccessMessage);
                        } else {
            Severity: Major
            Found in web/organization/controllers/JoinController.php and 1 other location - About 2 hrs to fix
            web/organization/controllers/JoinController.php on lines 156..166

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

            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

            Function actionAssignSetUpOrganization has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionAssignSetUpOrganization($user, $limit = 1)
                {
                    $user = $this->getUser($user);
                    $permission = new SetUpOrganization();
                    $limit = is_numeric($limit) ? (int) $limit : 1;
            Severity: Minor
            Found in console/controllers/OrganizationController.php - About 2 hrs 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

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

                    'role' => [
                        'class' => DataColumn::class,
                        'attribute' => 'role',
                        'label' => Yii::t('organization', 'Role'),
                        'content' => function ($model, $key, $index, $column) {
            Severity: Major
            Found in widgets/views/zh-CN/member-list.php and 1 other location - About 2 hrs to fix
            widgets/views/member-list.php on lines 62..76

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

            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

                    'role' => [
                        'class' => DataColumn::class,
                        'attribute' => 'role',
                        'label' => Yii::t('organization', 'Role'),
                        'content' => function ($model, $key, $index, $column) {
            Severity: Major
            Found in widgets/views/member-list.php and 1 other location - About 2 hrs to fix
            widgets/views/zh-CN/member-list.php on lines 62..76

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

            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

            Method addMember has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function addMember(&$member)
                {
                    if ($this->getIsNewRecord()) {
                        return false;
                    }
            Severity: Minor
            Found in Organization.php - About 1 hr to fix

              Function submit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function submit()
                  {
                      try {
                          if ($this->organization->isOrganization()) {
                              if ($this->exclude_other_members != ($this->organization->isExcludeOtherMembers ? '1' : '0')) {
              Severity: Minor
              Found in forms/SettingsForm.php - About 1 hr 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 actionAssignSetUpOrganization has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionAssignSetUpOrganization($user, $limit = 1)
                  {
                      $user = $this->getUser($user);
                      $permission = new SetUpOrganization();
                      $limit = is_numeric($limit) ? (int) $limit : 1;
              Severity: Minor
              Found in console/controllers/OrganizationController.php - About 1 hr to fix

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

                    protected function getOrganization($organization)
                    {
                        $organizationClass = $this->checkOrganizationClass();
                        if (is_numeric($organization)) {
                            $organization = $organizationClass::find()->id($organization)->one();
                Severity: Major
                Found in console/controllers/OrganizationController.php and 1 other location - About 1 hr to fix
                console/controllers/OrganizationController.php on lines 58..70

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

                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

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

                    protected function getUser($user)
                    {
                        $userClass = $this->checkUserClass();
                        if (is_numeric($user)) {
                            $user = $userClass::find()->id($user)->one();
                Severity: Major
                Found in console/controllers/OrganizationController.php and 1 other location - About 1 hr to fix
                console/controllers/OrganizationController.php on lines 95..107

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

                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

                Severity
                Category
                Status
                Source
                Language