DaSourcerer/yii2-yiiboard

View on GitHub

Showing 72 of 153 total issues

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

        public function beforeAction($action)
        {
            if (parent::beforeAction($action)) {    
                
                //update users online information            
    Severity: Minor
    Found in YBoard.php - About 1 hr to fix

      Method attributeLabels has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function attributeLabels()
          {
              return [
                  'id' => YBoard::t('yboard', 'Member'),
                  'location' => YBoard::t('yboard', 'Location'),
      Severity: Minor
      Found in models/YBoardMember.php - About 1 hr to fix

        Method actionTopic has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionTopic() {
                if(!Yii::$app->user->can('app.forum.moderator.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.'));
                
                $json = [];
        Severity: Minor
        Found in controllers/ModeratorController.php - About 1 hr to fix

          Method resetLastPost has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function resetLastPost() { 
                  $forum = YBoardForum::find()->where(['last_post_id'=>$this->id])->one();
                  $topic = YBoardTopic::find()->where(['last_post_id'=>$this->id])->one();
          
                  if($forum !== null) { 
          Severity: Minor
          Found in models/YBoardPost.php - About 1 hr to fix

            Function actionChangeBanPeriod has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionChangeBanPeriod($id)
                {
                    if(!Yii::$app->user->can('app.forum.moderator.change-ban-period'))
                        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 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 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

              Method actionChangePost has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionChangePost()
                  {
                      if(!Yii::$app->user->can('app.forum.moderator.change-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.'));
                      
              Severity: Minor
              Found in controllers/ModeratorController.php - About 1 hr to fix

                Method actionApprovePost has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function actionApprovePost($id)
                    {
                        if(!Yii::$app->user->can('app.forum.moderator.approve-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.'));
                        
                Severity: Minor
                Found in controllers/ModeratorController.php - About 1 hr to fix

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

                    Method actionChangeBanPeriod has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function actionChangeBanPeriod($id)
                        {
                            if(!Yii::$app->user->can('app.forum.moderator.change-ban-period'))
                                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 1 hr to fix

                      Method actionApproveTopic has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function actionApproveTopic($id)
                          {
                              if(!Yii::$app->user->can('app.forum.moderator.approve-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 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 actionTopic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function actionTopic() {
                                if(!Yii::$app->user->can('app.forum.moderator.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.'));
                                
                                $json = [];
                        Severity: Minor
                        Found in controllers/ModeratorController.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 actionSaveRank has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function actionSaveRank() {
                                if(!Yii::$app->user->can('app.forum.setting.save-rank'))
                                    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/SettingController.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

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

                            static public function userTimestamp($timestamp) {  
                                if(!is_numeric($timestamp))  //skip for unix timestamps      
                                {
                                    $dt = new DateTime($timestamp);
                                    $timestamp = $dt->getTimestamp();
                        Severity: Minor
                        Found in components/DateTimeCalculation.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

                        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

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

                            public function actionSaveMembergroup() {
                                if(!Yii::$app->user->can('app.forum.setting.save-membergroup'))
                                    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/SettingController.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

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

                            public function actionSaveSpider() {
                                if(!Yii::$app->user->can('app.forum.setting.save-spider'))
                                    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/SettingController.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

                        Severity
                        Category
                        Status
                        Source
                        Language