DaSourcerer/yii2-yiiboard

View on GitHub

Showing 153 of 153 total issues

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

    public function attributeLabels()
    {
        return [
            'id' => YBoard::t('yboard', 'ID'),
            'ip' => YBoard::t('yboard', 'Ip'),
Severity: Major
Found in models/YBoardIpaddress.php and 1 other location - About 1 hr to fix
models/YBoardBan.php on lines 48..59

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

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

    public function attributeLabels()
    {
        return [
            'id' => YBoard::t('yboard', 'ID'),
            'user_id' => YBoard::t('yboard', 'Member'),
Severity: Major
Found in models/YBoardBan.php and 1 other location - About 1 hr to fix
models/YBoardIpaddress.php on lines 71..82

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

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

                    <?php if($model->poster->github!=''): ?>
                        <?= Html::a(Html::img($this->context->module->getSocialImage('github.png'), ['class'=>'round-grey', 'title'=>YBoard::t('yboard', 'Twitter'), 'style'=>'border:0; height:24px;']), strncmp($model->poster->github, 'http', 4)==0 ? $model->poster->github : "http://github.com/{$model->poster->github}") ?> 
                    <?php endif; ?>
Severity: Major
Found in views/forum/_post.php and 1 other location - About 1 hr to fix
views/forum/_post.php on lines 108..110

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

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

                    <?php if($model->poster->twitter!=''): ?>
                        <?= Html::a(Html::img($this->context->module->getSocialImage('twitter.png'), ['class'=>'round-grey', 'title'=>YBoard::t('yboard', 'Twitter'), 'style'=>'border:0; height:24px;']), strncmp($model->poster->twitter, 'http', 4)==0 ? $model->poster->twitter : "http://twitter.com/{$model->poster->twitter}") ?> 
                    <?php endif; ?>
Severity: Major
Found in views/forum/_post.php and 1 other location - About 1 hr to fix
views/forum/_post.php on lines 116..118

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

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

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

    $this->params['breadcrumbs']=[
        ['label'=>YBoard::t('yboard', 'Forums'), 'url'=>['forum/index']], 
        ['label'=>YBoard::t('yboard', 'Outbox') .' ('. $count['outbox'] .')', 'url'=>['message/outbox', 'id'=>Yii::$app->user->id]],
        YBoard::t('yboard', 'Inbox'),
    ];
    Severity: Major
    Found in views/message/inbox.php and 1 other location - About 1 hr to fix
    views/message/outbox.php on lines 15..19

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

    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

    $this->params['breadcrumbs']=[
        ['label'=>YBoard::t('yboard', 'Forums'), 'url'=>['forum/index']], 
        ['label'=>YBoard::t('yboard', 'Inbox') .' ('. $count['inbox'] .')', 'url'=>['message/inbox', 'id'=>Yii::$app->user->id]],
        YBoard::t('yboard', 'Outbox'),
    ];
    Severity: Major
    Found in views/message/outbox.php and 1 other location - About 1 hr to fix
    views/message/inbox.php on lines 14..18

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

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

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

          $this->params['breadcrumbs'] = [
              ['label'=>YBoard::t('yboard', 'Forums'), 'url'=>['forum/index']],
              ['label'=>$forum->name, 'url'=>['/forum/forum/forum', 'id'=>$forum->id]],
              ['label'=>$topic->title, 'url'=>['/forum/forum/forum', 'id'=>$forum->id]],
              YBoard::t('yboard', 'Change'),
          Severity: Major
          Found in views/forum/update.php and 1 other location - About 1 hr to fix
          views/forum/reply.php on lines 11..16

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

          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

          $this->params['breadcrumbs']=[
              ['label'=>YBoard::t('yboard', 'Forums'), 'url'=>['forum/index']],
              ['label'=>$forum->name, 'url'=>['forum/forum', 'id'=>$forum->id]],
              ['label'=>$topic->title, 'url'=>['forum/topic', 'id'=>$topic->id]],    
              YBoard::t('yboard', 'Reply'),
          Severity: Major
          Found in views/forum/reply.php and 1 other location - About 1 hr to fix
          views/forum/update.php on lines 9..14

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

          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

          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

          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

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

                                  $.post(url, request, function(data) {
                                      if(data.success == 'yes') { 
                                          location.reload();
                                      } else {
                                          alert(data.message); 
              Severity: Major
              Found in assets/js/yboard.js and 1 other location - About 1 hr to fix
              assets/js/ybsetting.js on lines 44..50

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

              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

                                  $.post(url, formdata, function(data) {
                                      if(data.success == 'yes') { 
                                          location.reload();
                                      } else {
                                          alert(data.error); 
              Severity: Major
              Found in assets/js/ybsetting.js and 1 other location - About 1 hr to fix
              assets/js/yboard.js on lines 122..128

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

              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 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
                  Severity
                  Category
                  Status
                  Source
                  Language