DaSourcerer/yii2-yiiboard

View on GitHub

Showing 72 of 153 total issues

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

    File ModeratorController.php has 430 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace app\modules\yboard\controllers;
    
    use app\modules\yboard\YBoard;
    Severity: Minor
    Found in controllers/ModeratorController.php - About 6 hrs to fix

      File SettingController.php has 404 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace app\modules\yboard\controllers; 
      
      use app\modules\yboard\YBoard;
      Severity: Minor
      Found in controllers/SettingController.php - About 5 hrs to fix

        File profile.php has 378 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        use yii\helpers\Html;
        use yii\helpers\Url;
        use yii\widgets\DetailView;
        Severity: Minor
        Found in views/member/profile.php - About 5 hrs to fix

          File profile.php has 378 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          use yii\helpers\Html;
          use yii\helpers\Url;
          use yii\widgets\DetailView;
          Severity: Minor
          Found in views/setting/profile.php - About 5 hrs to fix

            Function actionChangeTopic has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionChangeTopic()
                {
                    if(!Yii::$app->user->can('app.forum.moderator.change-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/ModeratorController.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

            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

                File yboard.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                
                function showAppreciation(members)
                { 
                    $("#appreciated-content").html(unescape(members));
                    $("#dlg-appreciated").dialog('open'); 
                Severity: Minor
                Found in assets/js/yboard.js - About 3 hrs to fix

                  Function getForumOptions has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function getForumOptions($isGuest, $uid) {
                          $return = []; 
                          $category = YBoardForum::find()
                                      ->where(['type'=>0])
                                      ->orderBy('sort')
                  Severity: Minor
                  Found in models/YBoardForum.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

                  SettingController has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class SettingController extends \yii\web\Controller
                  {
                      public $layout = "admin";
                      
                      public function init()
                  Severity: Minor
                  Found in controllers/SettingController.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

                      File ybsetting.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /** Sorting function
                       * @param obj HtmlElement Object
                       * @param url string
                      */
                      function Sort(obj, url) {
                      Severity: Minor
                      Found in assets/js/ybsetting.js - About 2 hrs to fix

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

                            public function actionChangeTopic()
                            {
                                if(!Yii::$app->user->can('app.forum.moderator.change-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/ModeratorController.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

                            YBoardMember has 21 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class YBoardMember extends \yii\db\ActiveRecord
                            {
                                /**
                                 * @inheritdoc
                                 */
                            Severity: Minor
                            Found in models/YBoardMember.php - About 2 hrs to fix

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

                                  public function actionCreate()
                                  {
                                      if(!Yii::$app->user->can('app.forum.message.create'))
                                          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/MessageController.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 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

                              Severity
                              Category
                              Status
                              Source
                              Language