bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

        if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->senderName), $matches)) {
            $dataProvider->query->joinWith(['message' => function ($q) use ($matches) {
                $q->joinWith(['sender' => function ($q) use ($matches) {
                    $q->andFilterWhere(['and',
                        [User::tableName() . '.id' => $matches[2]],
Severity: Major
Found in src/models/MessageReceiver.php and 1 other location - About 1 day to fix
src/models/MessageSearch.php on lines 71..104

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

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 (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->receiverName), $matches)) {
            $dataProvider->query->joinWith(['messageReceivers' => function($q) use ($matches) {
                $q->joinWith(['receiver' => function ($q) use ($matches) {
                    $q->andFilterWhere(['and',
                        [User::tableName() . '.id' => $matches[2]],
Severity: Major
Found in src/models/MessageSearch.php and 1 other location - About 1 day to fix
src/models/MessageReceiver.php on lines 112..145

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

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 markSeen has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    public function markSeen($updateCounters = true)
    {
        if (!Podium::getInstance()->user->isGuest) {
            $transaction = static::getDb()->beginTransaction();
            try {
Severity: Minor
Found in src/models/Post.php - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File User.php has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace bizley\podium\models;

use bizley\podium\db\Query;
Severity: Major
Found in src/models/User.php - About 1 day to fix

    Function actionMoveposts has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
        {
            $thread = (new ThreadVerifier([
                'categoryId' => $cid,
                'forumId' => $fid,
    Severity: Minor
    Found in src/controllers/ForumPostController.php - About 1 day 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 actionForum has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionForum()
        {
            $user = User::findMe();
            $model = Meta::find()->where(['user_id' => $user->id])->limit(1)->one();
            if (empty($model)) {
    Severity: Minor
    Found in src/controllers/ProfileController.php - About 1 day to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File ForumController.php has 516 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace bizley\podium\controllers;
    
    use bizley\podium\db\Query;
    Severity: Major
    Found in src/controllers/ForumController.php - About 1 day to fix

      Method add has 207 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function add(DbManager $authManager)
          {
              $viewThread = $authManager->getPermission(self::PERM_VIEW_THREAD);
              if (!($viewThread instanceof Permission)) {
                  $viewThread = $authManager->createPermission(self::PERM_VIEW_THREAD);
      Severity: Major
      Found in src/rbac/Rbac.php - About 1 day to fix

        File Thread.php has 491 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace bizley\podium\models;
        
        use bizley\podium\log\Log;
        Severity: Minor
        Found in src/models/Thread.php - About 7 hrs to fix

          Function actionNew has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
          Open

              public function actionNew($user = null)
              {
                  $podiumUser = User::findMe();
          
                  if (Message::tooMany($podiumUser->id)) {
          Severity: Minor
          Found in src/controllers/MessagesController.php - About 7 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          File ForumPostController.php has 466 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace bizley\podium\controllers;
          
          use bizley\podium\filters\AccessControl;
          Severity: Minor
          Found in src/controllers/ForumPostController.php - About 7 hrs to fix

            File Post.php has 462 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace bizley\podium\models;
            
            use bizley\podium\db\Query;
            Severity: Minor
            Found in src/models/Post.php - About 7 hrs to fix

              Function actionAdvancedSearch has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function actionAdvancedSearch()
                  {
                      $dataProvider = null;
                      $list = [];
              
              Severity: Minor
              Found in src/controllers/ForumController.php - About 6 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

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

                      [
                          'class' => ActionColumn::className(),
                          'template' => '{view}' . (!Podium::getInstance()->user->isGuest ? ' {pm}' : ''),
                          'buttons' => [
                              'view' => function($url, $model) {
              Severity: Major
              Found in src/views/members/index.php and 1 other location - About 6 hrs to fix
              src/views/members/mods.php on lines 64..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 210.

              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

                      [
                          'class' => ActionColumn::className(),
                          'template' => '{view}' . (!Podium::getInstance()->user->isGuest ? ' {pm}' : ''),
                          'buttons' => [
                              'view' => function($url, $model) {
              Severity: Major
              Found in src/views/members/mods.php and 1 other location - About 6 hrs to fix
              src/views/members/index.php on lines 78..96

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

              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

              User has 40 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class User extends UserActiveRecord
              {
                  /**
                   * Roles.
                   */
              Severity: Minor
              Found in src/models/User.php - About 5 hrs to fix

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

                <?php if (!empty($query) && !empty($author)): ?>
                            <?= Yii::t('podium/view', 'Search for {type} with "{query}" by "{author}"', ['query' => Html::encode($query), 'author' => Html::encode($author), 'type' => $typeName]) ?>
                <?php elseif (!empty($query) && empty($author)): ?>
                            <?= Yii::t('podium/view', 'Search for {type} with "{query}"', ['query' => Html::encode($query), 'type' => $typeName]) ?>
                <?php elseif (empty($query) && !empty($author)): ?>
                Severity: Major
                Found in src/views/elements/search/_forum_search_posts.php and 1 other location - About 5 hrs to fix
                src/views/elements/search/_forum_search_topics.php on lines 18..26

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

                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

                <?php if (!empty($query) && !empty($author)): ?>
                            <?= Yii::t('podium/view', 'Search for {type} with "{query}" by "{author}"', ['query' => Html::encode($query), 'author' => Html::encode($author), 'type' => $typeName]) ?>
                <?php elseif (!empty($query) && empty($author)): ?>
                            <?= Yii::t('podium/view', 'Search for {type} with "{query}"', ['query' => Html::encode($query), 'type' => $typeName]) ?>
                <?php elseif (empty($query) && !empty($author)): ?>
                Severity: Major
                Found in src/views/elements/search/_forum_search_topics.php and 1 other location - About 5 hrs to fix
                src/views/elements/search/_forum_search_posts.php on lines 18..26

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

                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

                    protected function sendReactivationEmail(User $user)
                    {
                        $forum = Podium::getInstance()->podiumConfig->get('name');
                        $email = Content::fill(Content::EMAIL_REACTIVATION);
                        if ($email !== false) {
                Severity: Major
                Found in src/models/forms/ReactivateForm.php and 1 other location - About 5 hrs to fix
                src/models/forms/ResetForm.php on lines 99..114

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

                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

                    protected function sendResetEmail(User $user)
                    {
                        $forum = Podium::getInstance()->podiumConfig->get('name');
                        $email = Content::fill(Content::EMAIL_PASSWORD);
                        if ($email !== false) {
                Severity: Major
                Found in src/models/forms/ResetForm.php and 1 other location - About 5 hrs to fix
                src/models/forms/ReactivateForm.php on lines 99..114

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

                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