DaSourcerer/yii2-yiiboard

View on GitHub

Showing 153 of 153 total issues

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

function saveMembergroup(url) {
    var formdata = $('#edit-membergroup-form').serialize();
    $.post(url, formdata, function(data) {
        if(data.success == 'yes') {
            $("#dlgEditMembergroup").dialog('close');
Severity: Major
Found in assets/js/ybsetting.js and 1 other location - About 3 hrs to fix
assets/js/ybsetting.js on lines 272..286

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

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

function saveRank(url) {
    var formdata = $('#edit-rank-form').serialize();
    $.post(url, formdata, function(data) {
        if(data.success == 'yes') {
            $("#dlgEditRank").dialog('close');
Severity: Major
Found in assets/js/ybsetting.js and 1 other location - About 3 hrs to fix
assets/js/ybsetting.js on lines 205..219

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

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

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

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

                        'view'=>function ($url, $model) {
                            // return the button HTML code
                            $src = $this->context->module->getRegisteredImage('view.png');
                            return Html::a(Html::img($src, ['alt'=>'view']), '#' , [
                                'style'=>'margin-left:5px;',
    Severity: Major
    Found in views/moderator/report.php and 1 other location - About 2 hrs to fix
    views/message/inbox.php on lines 62..73

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

    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

                        'view'=>function ($url, $model) {
                            // return the button HTML code
                            $src = $this->context->module->getRegisteredImage('view.png');
                            return Html::a(Html::img($src, ['alt'=>'view']), '#' , [
                                'style'=>'margin-left:5px;',
    Severity: Major
    Found in views/message/inbox.php and 1 other location - About 2 hrs to fix
    views/moderator/report.php on lines 57..68

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

    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

    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

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

                    NavBar::begin([
                        'brandLabel' => '<p>'.Html::img($this->context->module->getRegisteredImage('logo.png'), ['class'=>'hidden-xs' ])
                                .Html::img($this->context->module->getRegisteredImage('logo_22.png'), ['class'=>'visible-xs' ])                    
                                .' '.$this->context->module->forumTitle.'</p>',
                        'brandUrl' => ['/'.$this->context->module->id.'/forum/'],
        Severity: Major
        Found in views/layouts/admin.php and 1 other location - About 2 hrs to fix
        views/layouts/forum.php on lines 35..43

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

        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

                    NavBar::begin([
                        'brandLabel' => '<p>'.Html::img($this->context->module->getRegisteredImage('logo.png'), ['class'=>'hidden-xs' ])
                                .Html::img($this->context->module->getRegisteredImage('logo_22.png'), ['class'=>'visible-xs' ])                    
                                .' '.$this->context->module->forumTitle.'</p>',
                        'brandUrl' => ['/'.$this->context->module->id.'/forum/'],
        Severity: Major
        Found in views/layouts/forum.php and 1 other location - About 2 hrs to fix
        views/layouts/admin.php on lines 30..38

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

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

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

          $this->params['adminMenu'] = [
              ['label'=>YBoard::t('yboard', 'Settings'), 'url'=>['setting/index']],
              ['label'=>YBoard::t('yboard', 'Manage forums'), 'url'=>['setting/forum']],
              ['label'=>YBoard::t('yboard', 'Manage Members'), 'url'=>['setting/group']],
              ['label'=>YBoard::t('yboard', 'Webspiders'), 'url'=>['setting/spider']],
          Severity: Major
          Found in views/setting/rank.php and 1 other location - About 2 hrs to fix
          views/setting/forum.php on lines 15..20

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

          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['adminMenu'] = [
              ['label'=>YBoard::t('yboard', 'Settings'), 'url'=>['setting/index']],
              ['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/setting/forum.php and 1 other location - About 2 hrs to fix
          views/setting/rank.php on lines 20..25

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

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

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

                topicApprove: function(id, url) {
                    $.post(url, function(data) {
                        if(data.success == 'yes') { 
                            $('#'+id).remove(); 
                        } else { 
            Severity: Major
            Found in assets/js/yboard.js and 1 other location - About 2 hrs to fix
            assets/js/yboard.js on lines 345..353

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

            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

                postApprove: function(id, url) {
                    $.post(url, function(data) {
                        if(data.success == 'yes') { 
                            $('#'+id).remove(); 
                        } else { 
            Severity: Major
            Found in assets/js/yboard.js and 1 other location - About 2 hrs to fix
            assets/js/yboard.js on lines 257..265

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

            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

            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

              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

              Severity
              Category
              Status
              Source
              Language