bizley/yii2-podium

View on GitHub
src/controllers/ForumPostController.php

Summary

Maintainability
F
1 wk
Test Coverage

Function actionMoveposts has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
    {
        $thread = (new ThreadVerifier([
            'categoryId' => $cid,
            'forumId' => $fid,
Severity: Minor
Found in src/controllers/ForumPostController.php - About 1 day 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 ForumPostController.php has 466 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace bizley\podium\controllers;

use bizley\podium\filters\AccessControl;
Severity: Minor
Found in src/controllers/ForumPostController.php - About 7 hrs to fix

    Method actionMoveposts has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function actionThumb has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function actionThumb()
          {
              if (!Yii::$app->request->isAjax) {
                  return $this->redirect(['forum/index']);
              }
      Severity: Minor
      Found in src/controllers/ForumPostController.php - About 3 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

      The class ForumPostController has an overall complexity of 91 which is very high. The configured complexity threshold is 50.
      Open

      class ForumPostController extends ForumThreadController
      {
          /**
           * @inheritdoc
           */

      Function actionPost has a Cognitive Complexity of 23 (exceeds 5 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: Minor
      Found in src/controllers/ForumPostController.php - About 3 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 actionThumb has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionThumb()
          {
              if (!Yii::$app->request->isAjax) {
                  return $this->redirect(['forum/index']);
              }
      Severity: Major
      Found in src/controllers/ForumPostController.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 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

          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

          Method actionEdit has 49 lines of code (exceeds 25 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 1 hr to fix

            Method actionDeletepost has 46 lines of code (exceeds 25 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 1 hr to fix

              Method actionDeleteposts has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionDeleteposts($cid = null, $fid = null, $id = null, $slug = null)
                  {
                      $thread = (new ThreadVerifier([
                          'categoryId' => $cid,
                          'forumId' => $fid,
              Severity: Minor
              Found in src/controllers/ForumPostController.php - About 1 hr to fix

                Method actionReport has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function actionReport($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 1 hr to fix

                  Function actionDeleteposts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function actionDeleteposts($cid = null, $fid = null, $id = null, $slug = null)
                      {
                          $thread = (new ThreadVerifier([
                              'categoryId' => $cid,
                              'forumId' => $fid,
                  Severity: Minor
                  Found in src/controllers/ForumPostController.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

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

                      public function actionReport($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 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

                  Avoid too many return statements within this method.
                  Open

                          return $this->render('report', ['model' => $model, 'post' => $post]);
                  Severity: Major
                  Found in src/controllers/ForumPostController.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return Json::encode($data);
                    Severity: Major
                    Found in src/controllers/ForumPostController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $this->redirect([
                                              'forum/thread',
                                              'cid' => $post->forum->category->id,
                                              'fid' => $post->forum->id,
                                              'id' => $post->thread->id,
                      Severity: Major
                      Found in src/controllers/ForumPostController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $this->render('deleteposts', [
                                    'model' => $thread,
                                    'dataProvider' => (new Post())->search($thread->forum->id, $thread->id)
                                ]);
                        Severity: Major
                        Found in src/controllers/ForumPostController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return $this->render('post', [
                                      'replyFor' => $replyFor,
                                      'preview' => $preview,
                                      'model' => $model,
                                      'thread' => $thread,
                          Severity: Major
                          Found in src/controllers/ForumPostController.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return $this->render('edit', [
                                        'preview' => $preview,
                                        'model' => $post,
                                        'isFirstPost' => $isFirstPost
                                    ]);
                            Severity: Major
                            Found in src/controllers/ForumPostController.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                      return $this->redirect(['forum/show', 'id' => $model->id]);
                              Severity: Major
                              Found in src/controllers/ForumPostController.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return $this->render('deletepost', ['model' => $post]);
                                Severity: Major
                                Found in src/controllers/ForumPostController.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                          return Json::encode($data);
                                  Severity: Major
                                  Found in src/controllers/ForumPostController.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return $this->render('moveposts', [
                                                'model' => $thread,
                                                'list' => $list,
                                                'options' => $options,
                                                'listforum' => $listforum,
                                    Severity: Major
                                    Found in src/controllers/ForumPostController.php - About 30 mins to fix

                                      The method actionPost() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
                                      Open

                                          public function actionPost($cid = null, $fid = null, $tid = null, $pid = null)
                                          {
                                              $thread = Thread::find()->where([
                                                      'id' => $tid,
                                                      'category_id' => $cid,

                                      NPathComplexity

                                      Since: 0.1

                                      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                      Example

                                      class Foo {
                                          function bar() {
                                              // lots of complicated code
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                      The method actionMoveposts() has 102 lines of code. Current threshold is set to 100. Avoid really long methods.
                                      Open

                                          public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
                                          {
                                              $thread = (new ThreadVerifier([
                                                  'categoryId' => $cid,
                                                  'forumId' => $fid,

                                      The method actionMoveposts() has an NPath complexity of 952. The configured NPath complexity threshold is 200.
                                      Open

                                          public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
                                          {
                                              $thread = (new ThreadVerifier([
                                                  'categoryId' => $cid,
                                                  'forumId' => $fid,

                                      NPathComplexity

                                      Since: 0.1

                                      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                      Example

                                      class Foo {
                                          function bar() {
                                              // lots of complicated code
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                      The method actionDeletepost() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                      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.'));

                                      CyclomaticComplexity

                                      Since: 0.1

                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                      Example

                                      // Cyclomatic Complexity = 11
                                      class Foo {
                                      1   public function example() {
                                      2       if ($a == $b) {
                                      3           if ($a1 == $b1) {
                                                      fiddle();
                                      4           } elseif ($a2 == $b2) {
                                                      fiddle();
                                                  } else {
                                                      fiddle();
                                                  }
                                      5       } elseif ($c == $d) {
                                      6           while ($c == $d) {
                                                      fiddle();
                                                  }
                                      7        } elseif ($e == $f) {
                                      8           for ($n = 0; $n < $h; $n++) {
                                                      fiddle();
                                                  }
                                              } else {
                                                  switch ($z) {
                                      9               case 1:
                                                          fiddle();
                                                          break;
                                      10              case 2:
                                                          fiddle();
                                                          break;
                                      11              case 3:
                                                          fiddle();
                                                          break;
                                                      default:
                                                          fiddle();
                                                          break;
                                                  }
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                      The method actionThumb() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                      Open

                                          public function actionThumb()
                                          {
                                              if (!Yii::$app->request->isAjax) {
                                                  return $this->redirect(['forum/index']);
                                              }

                                      CyclomaticComplexity

                                      Since: 0.1

                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                      Example

                                      // Cyclomatic Complexity = 11
                                      class Foo {
                                      1   public function example() {
                                      2       if ($a == $b) {
                                      3           if ($a1 == $b1) {
                                                      fiddle();
                                      4           } elseif ($a2 == $b2) {
                                                      fiddle();
                                                  } else {
                                                      fiddle();
                                                  }
                                      5       } elseif ($c == $d) {
                                      6           while ($c == $d) {
                                                      fiddle();
                                                  }
                                      7        } elseif ($e == $f) {
                                      8           for ($n = 0; $n < $h; $n++) {
                                                      fiddle();
                                                  }
                                              } else {
                                                  switch ($z) {
                                      9               case 1:
                                                          fiddle();
                                                          break;
                                      10              case 2:
                                                          fiddle();
                                                          break;
                                      11              case 3:
                                                          fiddle();
                                                          break;
                                                      default:
                                                          fiddle();
                                                          break;
                                                  }
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                      The method actionMoveposts() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
                                      Open

                                          public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
                                          {
                                              $thread = (new ThreadVerifier([
                                                  'categoryId' => $cid,
                                                  'forumId' => $fid,

                                      CyclomaticComplexity

                                      Since: 0.1

                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                      Example

                                      // Cyclomatic Complexity = 11
                                      class Foo {
                                      1   public function example() {
                                      2       if ($a == $b) {
                                      3           if ($a1 == $b1) {
                                                      fiddle();
                                      4           } elseif ($a2 == $b2) {
                                                      fiddle();
                                                  } else {
                                                      fiddle();
                                                  }
                                      5       } elseif ($c == $d) {
                                      6           while ($c == $d) {
                                                      fiddle();
                                                  }
                                      7        } elseif ($e == $f) {
                                      8           for ($n = 0; $n < $h; $n++) {
                                                      fiddle();
                                                  }
                                              } else {
                                                  switch ($z) {
                                      9               case 1:
                                                          fiddle();
                                                          break;
                                      10              case 2:
                                                          fiddle();
                                                          break;
                                      11              case 3:
                                                          fiddle();
                                                          break;
                                                      default:
                                                          fiddle();
                                                          break;
                                                  }
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                      The method actionPost() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                                      Open

                                          public function actionPost($cid = null, $fid = null, $tid = null, $pid = null)
                                          {
                                              $thread = Thread::find()->where([
                                                      'id' => $tid,
                                                      'category_id' => $cid,

                                      CyclomaticComplexity

                                      Since: 0.1

                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                      Example

                                      // Cyclomatic Complexity = 11
                                      class Foo {
                                      1   public function example() {
                                      2       if ($a == $b) {
                                      3           if ($a1 == $b1) {
                                                      fiddle();
                                      4           } elseif ($a2 == $b2) {
                                                      fiddle();
                                                  } else {
                                                      fiddle();
                                                  }
                                      5       } elseif ($c == $d) {
                                      6           while ($c == $d) {
                                                      fiddle();
                                                  }
                                      7        } elseif ($e == $f) {
                                      8           for ($n = 0; $n < $h; $n++) {
                                                      fiddle();
                                                  }
                                              } else {
                                                  switch ($z) {
                                      9               case 1:
                                                          fiddle();
                                                          break;
                                      10              case 2:
                                                          fiddle();
                                                          break;
                                      11              case 3:
                                                          fiddle();
                                                          break;
                                                      default:
                                                          fiddle();
                                                          break;
                                                  }
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                      The method actionEdit() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                      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.'));

                                      CyclomaticComplexity

                                      Since: 0.1

                                      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                      Example

                                      // Cyclomatic Complexity = 11
                                      class Foo {
                                      1   public function example() {
                                      2       if ($a == $b) {
                                      3           if ($a1 == $b1) {
                                                      fiddle();
                                      4           } elseif ($a2 == $b2) {
                                                      fiddle();
                                                  } else {
                                                      fiddle();
                                                  }
                                      5       } elseif ($c == $d) {
                                      6           while ($c == $d) {
                                                      fiddle();
                                                  }
                                      7        } elseif ($e == $f) {
                                      8           for ($n = 0; $n < $h; $n++) {
                                                      fiddle();
                                                  }
                                              } else {
                                                  switch ($z) {
                                      9               case 1:
                                                          fiddle();
                                                          break;
                                      10              case 2:
                                                          fiddle();
                                                          break;
                                      11              case 3:
                                                          fiddle();
                                                          break;
                                                      default:
                                                          fiddle();
                                                          break;
                                                  }
                                              }
                                          }
                                      }

                                      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

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

                                      class ForumPostController extends ForumThreadController
                                      {
                                          /**
                                           * @inheritdoc
                                           */

                                      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

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

                                                                  if ($thread->podiumMovePostsTo($newthread, $posts, $newname, $newforum)) {
                                                                      $this->success(Yii::t('podium/flash', 'Posts have been moved.'));
                                                                      if (Thread::find()->where(['id' => $thread->id])->exists()) {
                                                                          return $this->redirect([
                                                                              'forum/thread',
                                      Severity: Major
                                      Found in src/controllers/ForumPostController.php and 1 other location - About 2 hrs to fix
                                      src/controllers/ForumPostController.php on lines 135..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 135.

                                      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 ($thread->podiumDeletePosts($posts)) {
                                                          $this->success(Yii::t('podium/flash', 'Posts have been deleted.'));
                                                          if (Thread::find()->where(['id' => $thread->id])->exists()) {
                                                              return $this->redirect([
                                                                  'forum/thread',
                                      Severity: Major
                                      Found in src/controllers/ForumPostController.php and 1 other location - About 2 hrs to fix
                                      src/controllers/ForumPostController.php on lines 270..287

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

                                      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

                                              if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
                                                  $this->info(Yii::t('podium/flash', 'This thread is locked.'));
                                                  return $this->redirect([
                                                      'forum/thread',
                                                      'cid' => $post->forum->category->id,
                                      Severity: Major
                                      Found in src/controllers/ForumPostController.php and 1 other location - About 1 hr to fix
                                      src/controllers/ForumPostController.php on lines 179..188

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

                                      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

                                              if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
                                                  $this->info(Yii::t('podium/flash', 'This thread is locked.'));
                                                  return $this->redirect([
                                                      'forum/thread',
                                                      'cid' => $post->forum->category->id,
                                      Severity: Major
                                      Found in src/controllers/ForumPostController.php and 1 other location - About 1 hr to fix
                                      src/controllers/ForumPostController.php on lines 59..68

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

                                      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

                                      There are no issues that match your filters.

                                      Category
                                      Status