DaSourcerer/yii2-yiiboard

View on GitHub

Showing 153 of 153 total issues

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

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

    $items = array(
        ['label'=>YBoard::t('yboard', 'Settings'), 'url'=>array('setting/index')],
        ['label'=>YBoard::t('yboard', 'Manage forums'), 'url'=>array('setting/forum')],
        ['label'=>YBoard::t('yboard', 'Member groups'), 'url'=>array('setting/group')],
        ['label'=>YBoard::t('yboard', 'Moderators'), 'url'=>array('setting/moderator')]
    Severity: Major
    Found in views/setting/spider.php and 1 other location - About 1 hr to fix
    views/moderator/index.php on lines 19..24

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

    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

    $item = [
        ['label'=>YBoard::t('yboard', 'Manage Forum'), 'url'=>['setting/forum']],
        ['label'=>YBoard::t('yboard', 'Member groups'), 'url'=>['setting/group']],
        ['label'=>YBoard::t('yboard', 'Moderators'), 'url'=>['setting/moderator']],
        ['label'=>YBoard::t('yboard', 'Webspiders'), 'url'=>['setting/spider']],
    Severity: Major
    Found in views/moderator/index.php and 1 other location - About 1 hr to fix
    views/setting/spider.php on lines 22..27

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

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method 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

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

                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template'=>'{update}',
                        'buttons' => [
                            'update' => function($url, $model) {
        Severity: Major
        Found in views/setting/group.php and 1 other location - About 1 hr to fix
        views/setting/rank.php on lines 49..62

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

        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

                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template'=>'{update}',
                        'buttons' => [
                            'update' => function($url, $model) {
        Severity: Major
        Found in views/setting/rank.php and 1 other location - About 1 hr to fix
        views/setting/group.php on lines 68..81

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

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method 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

                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

                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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language