bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

<?php

/**
 * Podium Module
 * Yii 2 Forum Module
Severity: Major
Found in src/views/layouts/installation.php and 1 other location - About 2 hrs to fix
src/views/layouts/main.php on lines 1..40

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

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

<?php

/**
 * Podium Module
 * Yii 2 Forum Module
Severity: Major
Found in src/views/layouts/main.php and 1 other location - About 2 hrs to fix
src/views/layouts/installation.php on lines 1..40

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

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 actionNew has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionNew($user = null)
    {
        $podiumUser = User::findMe();

        if (Message::tooMany($podiumUser->id)) {
Severity: Major
Found in src/controllers/MessagesController.php - About 2 hrs to fix

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

        public function search($params)
        {
            $subquery = (new Query())
                        ->select(['m2.replyto'])
                        ->from(['m1' => Message::tableName()])
    Severity: Major
    Found in src/models/MessageSearch.php - About 2 hrs to fix

      Method podiumNew has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function podiumNew()
          {
              $transaction = static::getDb()->beginTransaction();
              try {
                  if (!$this->save()) {
      Severity: Major
      Found in src/models/Thread.php - About 2 hrs to fix

        Method actionPost has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionPost($cid = null, $fid = null, $tid = null, $pid = null)
            {
                $thread = Thread::find()->where([
                        'id' => $tid,
                        'category_id' => $cid,
        Severity: Major
        Found in src/controllers/ForumPostController.php - About 2 hrs to fix

          Function podiumNew has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public function podiumNew($previous = null)
              {
                  $transaction = static::getDb()->beginTransaction();
                  try {
                      $id = null;
          Severity: Minor
          Found in src/models/Post.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

          SchemaOperation has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SchemaOperation extends Component
          {
              const TYPE_SUCCESS = 0;
              const TYPE_WARNING = 1;
              const TYPE_ERROR = 2;
          Severity: Minor
          Found in src/maintenance/SchemaOperation.php - About 2 hrs to fix

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

                public function podiumNew($previous = null)
                {
                    $transaction = static::getDb()->beginTransaction();
                    try {
                        $id = null;
            Severity: Major
            Found in src/models/Post.php - About 2 hrs to fix

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

                  public function actionMods($id = null)
                  {
                      $mod = null;
                      $moderators = User::find()->where(['role' => User::ROLE_MODERATOR])->indexBy('id')->all();
                      if (is_numeric($id) && $id > 0) {
              Severity: Minor
              Found in src/controllers/AdminController.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

              Method actionEditpoll has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionEditpoll($cid = null, $fid = null, $tid = null, $pid = null)
                  {
                      $poll = Poll::find()->joinWith('thread')->where([
                          Poll::tableName() . '.id' => $pid,
                          Poll::tableName() . '.thread_id' => $tid,
              Severity: Major
              Found in src/controllers/ForumController.php - About 2 hrs to fix

                Method actionMove has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function actionMove($cid = null, $fid = null, $id = null, $slug = null)
                    {
                        $thread = (new ThreadVerifier([
                            'categoryId' => $cid,
                            'forumId' => $fid,
                Severity: Major
                Found in src/controllers/ForumThreadController.php - About 2 hrs to fix

                  Method behaviors has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function behaviors()
                      {
                          return [
                              'access' => [
                                  'class' => AccessControl::className(),
                  Severity: Major
                  Found in src/controllers/ForumController.php - About 2 hrs to fix

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

                            if ($model->status == User::STATUS_BANNED) {
                                if ($model->unban()) {
                                    $this->module->podiumCache->delete('members.fieldlist');
                                    Log::info('User unbanned', $model->id, __METHOD__);
                                    $this->success(Yii::t('podium/flash', 'User has been unbanned.'));
                    Severity: Major
                    Found in src/controllers/AdminController.php and 1 other location - About 2 hrs to fix
                    src/controllers/AdminController.php on lines 142..152

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

                    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 ($model->status == User::STATUS_ACTIVE) {
                                if ($model->ban()) {
                                    $this->module->podiumCache->delete('members.fieldlist');
                                    Log::info('User banned', $model->id, __METHOD__);
                                    $this->success(Yii::t('podium/flash', 'User has been banned.'));
                    Severity: Major
                    Found in src/controllers/AdminController.php and 1 other location - About 2 hrs to fix
                    src/controllers/AdminController.php on lines 153..163

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

                    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 remove has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function remove()
                        {
                            $transaction = static::getDb()->beginTransaction();
                            try {
                                $clearCache = false;
                    Severity: Major
                    Found in src/models/Message.php - About 2 hrs to fix

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

                                  if ($this->postsCount) {
                                      $this->updateCounters(['posts' => -count($posts)]);
                                      $this->forum->updateCounters(['posts' => -count($posts)]);
                                  } else {
                                      $wholeThread = true;
                      Severity: Major
                      Found in src/models/Thread.php and 1 other location - About 2 hrs to fix
                      src/models/Thread.php on lines 445..454

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

                      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 ($this->postCount) {
                                      $this->updateCounters(['posts' => -count($posts)]);
                                      $this->forum->updateCounters(['posts' => -count($posts)]);
                                  } else {
                                      $wholeThread = true;
                      Severity: Major
                      Found in src/models/Thread.php and 1 other location - About 2 hrs to fix
                      src/models/Thread.php on lines 313..322

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

                      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 actionEdit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function actionEdit($cid = null, $fid = null, $tid = null, $pid = null)
                          {
                              $post = Post::verify($cid, $fid, $tid, $pid);
                              if (empty($post)) {
                                  $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
                      Severity: Minor
                      Found in src/controllers/ForumPostController.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

                      Function actionDeletepost has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function actionDeletepost($cid = null, $fid = null, $tid = null, $pid = null)
                          {
                              $post = Post::verify($cid, $fid, $tid, $pid);
                              if (empty($post)) {
                                  $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
                      Severity: Minor
                      Found in src/controllers/ForumPostController.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

                      Severity
                      Category
                      Status
                      Source
                      Language