bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

    public function getIcon()
    {
        $icon   = self::ICON_NO_NEW;
        $append = false;
Severity: Minor
Found in src/models/Thread.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 ProfileController.php has 252 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/ProfileController.php - About 2 hrs to fix

    Method podiumThumb has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function podiumThumb($up = true, $count = 0)
        {
            $transaction = static::getDb()->beginTransaction();
            try {
                $loggedId = User::loggedId();
    Severity: Major
    Found in src/models/Post.php - About 2 hrs to fix

      Method actionAdvancedSearch has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionAdvancedSearch()
          {
              $dataProvider = null;
              $list = [];
      
      Severity: Minor
      Found in src/controllers/ForumController.php - About 2 hrs to fix

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

                    if (!empty($filters['new']) && $filters['new'] == 1 && !Podium::getInstance()->user->isGuest) {
                        $query->joinWith(['threadView tvn' => function ($q) use ($loggedId) {
                            $q->onCondition(['tvn.user_id' => $loggedId]);
                            $q->andWhere(['or',
                                    new Expression('tvn.new_last_seen < new_post_at'),
        Severity: Major
        Found in src/models/Thread.php and 1 other location - About 2 hrs to fix
        src/models/Thread.php on lines 88..96

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

        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 (!empty($filters['edit']) && $filters['edit'] == 1 && !Podium::getInstance()->user->isGuest) {
                        $query->joinWith(['threadView tve' => function ($q) use ($loggedId) {
                            $q->onCondition(['tve.user_id' => $loggedId]);
                            $q->andWhere(['or',
                                    new Expression('tve.edited_last_seen < edited_post_at'),
        Severity: Major
        Found in src/models/Thread.php and 1 other location - About 2 hrs to fix
        src/models/Thread.php on lines 79..87

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

        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 if (!empty($items)): ?>
        <?php Modal::begin([
            'id' => 'podiumModalDelete',
            'header' => Yii::t('podium/view', 'Delete Forum'),
            'footer' => Yii::t('podium/view', 'Delete Forum'),
        Severity: Major
        Found in src/views/admin/forums.php and 1 other location - About 2 hrs to fix
        src/views/admin/categories.php on lines 56..67

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

        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 if (!empty($items)): ?>
        <?php Modal::begin([
            'id' => 'podiumModalDelete',
            'header' => Yii::t('podium/view', 'Delete Category'),
            'footer' => Yii::t('podium/view', 'Delete Category'),
        Severity: Major
        Found in src/views/admin/categories.php and 1 other location - About 2 hrs to fix
        src/views/admin/forums.php on lines 73..84

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

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

            public function podiumReport($post = null)
            {
                try {
                    if (empty($post)) {
                        throw new Exception('Reported post missing');
        Severity: Minor
        Found in src/models/Message.php - About 1 hr to fix

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

              public function actionForum()
              {
                  $user = User::findMe();
                  $model = Meta::find()->where(['user_id' => $user->id])->limit(1)->one();
                  if (empty($model)) {
          Severity: Minor
          Found in src/controllers/ProfileController.php - About 1 hr to fix

            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

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

                  public function podiumNew()
                  {
                      $transaction = static::getDb()->beginTransaction();
                      try {
                          if (!$this->save()) {
              Severity: Minor
              Found in src/models/Thread.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 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 search has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function search($forumId = null, $filters = null)
                    {
                        $query = static::find();
                        if ($forumId) {
                            $query->where(['forum_id' => (int)$forumId]);
                Severity: Minor
                Found in src/models/Thread.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 addContent has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function addContent()
                        {
                            try {
                                $default = Content::defaultContent();
                                $this->db->createCommand()->batchInsert(
                    Severity: Minor
                    Found in src/maintenance/Installation.php - About 1 hr to fix

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

                          public function requiredAnswers()
                          {
                              $this->editAnswers = array_unique($this->editAnswers);
                              $filtered = [];
                              foreach ($this->editAnswers as $answer) {
                      Severity: Major
                      Found in src/models/db/PollActiveRecord.php and 1 other location - About 1 hr to fix
                      src/models/db/ThreadActiveRecord.php on lines 149..161

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

                      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->pollAdded) {
                                  $this->pollAnswers = array_unique($this->pollAnswers);
                                  $filtered = [];
                                  foreach ($this->pollAnswers as $answer) {
                                      if (!empty(trim($answer))) {
                      Severity: Major
                      Found in src/models/db/ThreadActiveRecord.php and 1 other location - About 1 hr to fix
                      src/models/db/PollActiveRecord.php on lines 84..97

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

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

                          public function search($forumId = null, $filters = null)
                          {
                              $query = static::find();
                              if ($forumId) {
                                  $query->where(['forum_id' => (int)$forumId]);
                      Severity: Minor
                      Found in src/models/Thread.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 remove has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function remove()
                          {
                              $transaction = static::getDb()->beginTransaction();
                              try {
                                  $clearCache = false;
                      Severity: Minor
                      Found in src/models/MessageReceiver.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

                      Severity
                      Category
                      Status
                      Source
                      Language