DaSourcerer/yii2-yiiboard

View on GitHub
controllers/ForumController.php

Summary

Maintainability
F
1 wk
Test Coverage

File ForumController.php has 802 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace app\modules\yboard\controllers;

use Yii;
Severity: Major
Found in controllers/ForumController.php - About 1 day to fix

    Function actionCreateTopic has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionCreateTopic()
        {
            if(!Yii::$app->user->can('app.forum.forum.create-topic'))
                throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
             
    Severity: Minor
    Found in controllers/ForumController.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

    Function actionTopic has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionTopic($id, $nav = null, $postId = null) {
            $topic = YBoardTopic::findOne($id);
            if($topic === null) {
                throw new NotFoundHttpException(YBoard::t('yboard', 'The requested topic does not exist.'));
            }
    Severity: Minor
    Found in controllers/ForumController.php - About 4 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 actionTopic has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionTopic($id, $nav = null, $postId = null) {
            $topic = YBoardTopic::findOne($id);
            if($topic === null) {
                throw new NotFoundHttpException(YBoard::t('yboard', 'The requested topic does not exist.'));
            }
    Severity: Major
    Found in controllers/ForumController.php - About 3 hrs to fix

      Method actionCreateTopic has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionCreateTopic()
          {
              if(!Yii::$app->user->can('app.forum.forum.create-topic'))
                  throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
               
      Severity: Major
      Found in controllers/ForumController.php - About 3 hrs to fix

        ForumController has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ForumController extends \yii\web\Controller
        {
            
            public $poll;
            public $choiceProvider;
        Severity: Minor
        Found in controllers/ForumController.php - About 2 hrs to fix

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

              public function sendNotifications($postModel) 
              {
                  $query = new \yii\db\Query;
                  $rows = $query->select('user_id')
                      ->from('YBoardPost')
          Severity: Major
          Found in controllers/ForumController.php - About 2 hrs to fix

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

                public function actionUpdate($id) {
                    $post = YBoardPost::findOne($id);
                    if($post === null) {
                        throw new NotFoundException(404, YBoard::t('yboard', 'The requested post does not exist.'));
                    }
            Severity: Minor
            Found in controllers/ForumController.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 actionUpdatePoll has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionUpdatePoll($id) {
                    $poll = YBoardPoll::findOne($id);
                    if($poll === null) {
                        throw new NotFoundHttpException(YBoard::t('yboard', 'The requested poll does not exist.'));
                    }
            Severity: Minor
            Found in controllers/ForumController.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 actionQuote has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function actionQuote($id) {
                    if(!Yii::$app->user->can('app.forum.forum.quote'))
                        throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                     
                    $quoted = YBoardPost::findOne($id);
            Severity: Minor
            Found in controllers/ForumController.php - About 1 hr to fix

              Method actionIndex has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionIndex()
                  {  
                      $NumberOfTopics = YBoardSetting::find()->where(['key'=>'latest_topic'])->one();
                      $NumberOfReplies = YBoardSetting::find()->where(['key'=>'latest_reply'])->one();
                      
              Severity: Minor
              Found in controllers/ForumController.php - About 1 hr to fix

                Function actionForum has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function actionForum($id) {
                        $forum = $this->findModel($id);
                    
                        if(Yii::$app->user->isGuest && $forum->public == 0) {
                            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
                Severity: Minor
                Found in controllers/ForumController.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 actionQuote has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function actionQuote($id) {
                        if(!Yii::$app->user->can('app.forum.forum.quote'))
                            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                         
                        $quoted = YBoardPost::findOne($id);
                Severity: Minor
                Found in controllers/ForumController.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 actionReply has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function actionReply($id) {
                        
                        if(!Yii::$app->user->can('app.forum.forum.reply'))
                            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                         
                Severity: Minor
                Found in controllers/ForumController.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 forumIsRead has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function forumIsRead($forum_id) {
                        if(Yii::$app->user->isGuest) {
                            return false;
                        } else { 
                            $models = YBoardTopic::find()
                Severity: Minor
                Found in controllers/ForumController.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 actionForum has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function actionForum($id) {
                        $forum = $this->findModel($id);
                    
                        if(Yii::$app->user->isGuest && $forum->public == 0) {
                            throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
                Severity: Minor
                Found in controllers/ForumController.php - About 1 hr to fix

                  Method actionReply has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function actionReply($id) {
                          
                          if(!Yii::$app->user->can('app.forum.forum.reply'))
                              throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                           
                  Severity: Minor
                  Found in controllers/ForumController.php - About 1 hr to fix

                    Method actionVote has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function actionVote() {
                            if(!Yii::$app->user->can('app.forum.forum.vote'))
                                throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                             
                            $json = [];
                    Severity: Minor
                    Found in controllers/ForumController.php - About 1 hr to fix

                      Method actionUpdate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function actionUpdate($id) {
                              $post = YBoardPost::findOne($id);
                              if($post === null) {
                                  throw new NotFoundException(404, YBoard::t('yboard', 'The requested post does not exist.'));
                              }
                      Severity: Minor
                      Found in controllers/ForumController.php - About 1 hr to fix

                        Function actionVote has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function actionVote() {
                                if(!Yii::$app->user->can('app.forum.forum.vote'))
                                    throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                                 
                                $json = [];
                        Severity: Minor
                        Found in controllers/ForumController.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 actionUpvote has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function actionUpvote() {
                                if(!Yii::$app->user->can('app.forum.forum.upvote'))
                                    throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                                 
                                $json = [];
                        Severity: Minor
                        Found in controllers/ForumController.php - About 1 hr to fix

                          Method actionUpdatePoll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function actionUpdatePoll($id) {
                                  $poll = YBoardPoll::findOne($id);
                                  if($poll === null) {
                                      throw new NotFoundHttpException(YBoard::t('yboard', 'The requested poll does not exist.'));
                                  }
                          Severity: Minor
                          Found in controllers/ForumController.php - About 1 hr to fix

                            Function topicIsRead has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function topicIsRead($topic_id) {
                                    if(Yii::$app->user->isGuest) {
                                        return false;
                                    } else {
                                        $topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic_id]);
                            Severity: Minor
                            Found in controllers/ForumController.php - About 55 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function sendNotifications has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function sendNotifications($postModel) 
                                {
                                    $query = new \yii\db\Query;
                                    $rows = $query->select('user_id')
                                        ->from('YBoardPost')
                            Severity: Minor
                            Found in controllers/ForumController.php - About 55 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

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

                                public function actionIndex()
                                {  
                                    $NumberOfTopics = YBoardSetting::find()->where(['key'=>'latest_topic'])->one();
                                    $NumberOfReplies = YBoardSetting::find()->where(['key'=>'latest_reply'])->one();
                                    
                            Severity: Minor
                            Found in controllers/ForumController.php - About 45 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Avoid too many return statements within this method.
                            Open

                                                return true;
                            Severity: Major
                            Found in controllers/ForumController.php - About 30 mins to fix

                              Function topicIcon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function topicIcon($topic) {
                                      $img = 'topic';
                                      if($this->topicIsRead($topic->id)) {
                                          $img .= '2';
                                      } else {
                              Severity: Minor
                              Found in controllers/ForumController.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function actionUpvote has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public function actionUpvote() {
                                      if(!Yii::$app->user->can('app.forum.forum.upvote'))
                                          throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
                                       
                                      $json = [];
                              Severity: Minor
                              Found in controllers/ForumController.php - About 25 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

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

                                      if($forum->membergroup_id != 0) {
                                          if(Yii::$app->user->isGuest) {
                                              throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to view requested forum.'));
                                          } elseif(!Yii::$app->user->can('moderator')) {
                                              $groupId = YBoardMember::findOne(Yii::$app->user->id)->group_id;
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 192..201

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

                              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($forum->membergroup_id != 0) {
                                          if(Yii::$app->user->isGuest) {
                                              throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no permission to read requested topic.'));
                                          } elseif(!Yii::$app->user->can('moderator')) {
                                              $groupId = YBoardMember::findOne(Yii::$app->user->id)->group_id;
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 126..135

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

                              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(!Yii::$app->user->isGuest) {
                                          $topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic->id]);
                                          if($topicLog === null) {
                                              $topicLog = new YBoardLogTopic;
                                              $topicLog->member_id = Yii::$app->user->id;
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 964..974

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

                              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

                                      foreach($topics as $topic) {
                                          $topicLog = YBoardLogTopic::findOne(['member_id'=>Yii::$app->user->id, 'topic_id'=>$topic->id]);
                                          if($topicLog === null) {
                                              $topicLog = new YBoardLogTopic;
                                              $topicLog->member_id = Yii::$app->user->id;
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 258..268

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

                              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->approved) {
                                                  $forum->updateCounters(['num_posts'=>1]);                    
                                                  $topic->updateCounters(['num_replies'=>1]);
                                                                      
                                                  $topic->updateAttributes(['last_post_id'=>$post->id]);
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 477..487

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

                              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->approved) {
                                                  $forum->updateCounters(['num_posts'=>1]);
                                                  
                                                  $topic->updateCounters(['num_replies'=>1]);
                                                  
                              Severity: Major
                              Found in controllers/ForumController.php and 1 other location - About 1 hr to fix
                              controllers/ForumController.php on lines 720..728

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

                              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

                                      } else {
                                          $html = Html::button(YBoard::t('yboard', 'Upvote').' <span class="glyphicon glyphicon-chevron-up"></span>', ['class'=>'btn btn-sm btn-default', 'title'=>YBoard::t('yboard', 'Appreciate this post'), 'id'=>'upvote_'.$post_id, 'style'=>'cursor:pointer;', 'onclick'=>'upvotePost(' . $post_id . ','  . $post->user_id . ',"' . $url . '")']);
                                      }
                              Severity: Minor
                              Found in controllers/ForumController.php and 1 other location - About 55 mins to fix
                              controllers/ForumController.php on lines 951..955

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

                              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($upvoted>0) {
                                          $html = Html::button(YBoard::t('yboard', 'Downvote').' <span class="glyphicon glyphicon-chevron-down"></span>', ['class'=>'btn btn-sm btn-default', 'title'=>YBoard::t('yboard', 'Remove your appreciation'), 'id'=>'upvote_'.$post_id, 'style'=>'cursor:pointer;', 'onclick'=>'upvotePost(' . $post_id . ','  . $post->user_id .  ',"' . $url . '")']);
                                      } else {
                                          $html = Html::button(YBoard::t('yboard', 'Upvote').' <span class="glyphicon glyphicon-chevron-up"></span>', ['class'=>'btn btn-sm btn-default', 'title'=>YBoard::t('yboard', 'Appreciate this post'), 'id'=>'upvote_'.$post_id, 'style'=>'cursor:pointer;', 'onclick'=>'upvotePost(' . $post_id . ','  . $post->user_id . ',"' . $url . '")']);
                                      }
                              Severity: Minor
                              Found in controllers/ForumController.php and 1 other location - About 55 mins to fix
                              controllers/ForumController.php on lines 953..955

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

                              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