DaSourcerer/yii2-yiiboard

View on GitHub

Showing 72 of 153 total issues

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

    public function updateOnlineStatus($action) 
    {            
        //Timed JS function
        //fetch current user list and add update statistics
        //js to Update it for a time
Severity: Minor
Found in YBoard.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

File _post.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/* @var $this ForumController */
/* @var $model YBoardPost */
/* @var $postId integer */

Severity: Minor
Found in views/forum/_post.php - About 2 hrs to fix

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

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

                public function updateOnlineStatus($action) 
                {            
                    //Timed JS function
                    //fetch current user list and add update statistics
                    //js to Update it for a time
            Severity: Minor
            Found in YBoard.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 search has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function search($params)
                    {
                        $query = YBoardMember::find();
                
                        $dataProvider = new ActiveDataProvider([
                Severity: Minor
                Found in models/YBoardMemberSearch.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 actionSendReport has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

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

                            public function actionDelete($id) {
                                if(!Yii::$app->user->can('app.forum.moderator.delete-post'))
                                    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.'));
                                
                                if(isset($_GET['id']))
                        Severity: Minor
                        Found in controllers/ModeratorController.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

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

                              public function actionDelete($id) {
                                  if(!Yii::$app->user->can('app.forum.moderator.delete-post'))
                                      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.'));
                                  
                                  if(isset($_GET['id']))
                          Severity: Minor
                          Found in controllers/ModeratorController.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