bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

<?php if ($display === false && ($model->author_id == $loggedId || User::can(Rbac::PERM_UPDATE_POST, ['item' => $model->thread]))): ?>
                    <ul class="podium-action-bar list-inline">
                        <li>
                            <a href="<?= Url::to(['forum/editpoll', 'cid' => $model->thread->category_id, 'fid' => $model->thread->forum_id, 'tid' => $model->thread_id, 'pid' => $model->id]) ?>" class="btn btn-info btn-xs <?= $model->votesCount ? 'disabled text-muted' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= Yii::t('podium/view', 'Edit Poll') ?>">
                                <span class="glyphicon glyphicon-edit"></span>
Severity: Major
Found in src/widgets/poll/views/view.php and 1 other location - About 4 hrs to fix
src/widgets/poll/views/view.php on lines 61..74

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

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 ($display === false && ($model->author_id == $loggedId || User::can(Rbac::PERM_UPDATE_POST, ['item' => $model->thread]))): ?>
                    <ul class="podium-action-bar list-inline">
                        <li>
                            <a href="<?= Url::to(['forum/editpoll', 'cid' => $model->thread->category_id, 'fid' => $model->thread->forum_id, 'tid' => $model->thread_id, 'pid' => $model->id]) ?>" class="btn btn-info btn-xs <?= $model->votesCount ? 'disabled text-muted' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= Yii::t('podium/view', 'Edit Poll') ?>">
                                <span class="glyphicon glyphicon-edit"></span>
Severity: Major
Found in src/widgets/poll/views/view.php and 1 other location - About 4 hrs to fix
src/widgets/poll/views/view.php on lines 107..120

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

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

    public function podiumThumb($up = true, $count = 0)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $loggedId = User::loggedId();
Severity: Minor
Found in src/models/Post.php - About 4 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

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

<?php

/**
 * Podium Module
 * Yii 2 Forum Module
Severity: Major
Found in src/views/account/reactivate.php and 1 other location - About 4 hrs to fix
src/views/account/reset.php on lines 1..33

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

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

/**
 * Podium Module
 * Yii 2 Forum Module
Severity: Major
Found in src/views/account/reset.php and 1 other location - About 4 hrs to fix
src/views/account/reactivate.php on lines 1..33

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

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

UserActiveRecord has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class UserActiveRecord extends ActiveRecord implements IdentityInterface
{
    /**
     * Statuses.
     */
Severity: Minor
Found in src/models/db/UserActiveRecord.php - About 4 hrs to fix

    Function add has a Cognitive Complexity of 29 (exceeds 5 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: Minor
    Found in src/rbac/Rbac.php - About 4 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

    Method actionMoveposts has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionMoveposts($cid = null, $fid = null, $id = null, $slug = null)
        {
            $thread = (new ThreadVerifier([
                'categoryId' => $cid,
                'forumId' => $fid,
    Severity: Major
    Found in src/controllers/ForumPostController.php - About 3 hrs to fix

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

              if (!($moderator instanceof Role)) {
                  $moderator = $authManager->createRole(self::ROLE_MODERATOR);
                  $authManager->add($moderator);
                  $authManager->addChild($moderator, $updatePost);
                  $authManager->addChild($moderator, $updateThread);
      Severity: Major
      Found in src/rbac/Rbac.php and 1 other location - About 3 hrs to fix
      src/rbac/Rbac.php on lines 272..285

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

      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 (!($admin instanceof Role)) {
                  $admin = $authManager->createRole(self::ROLE_ADMIN);
                  $authManager->add($admin);
                  $authManager->addChild($admin, $deleteUser);
                  $authManager->addChild($admin, $promoteUser);
      Severity: Major
      Found in src/rbac/Rbac.php and 1 other location - About 3 hrs to fix
      src/rbac/Rbac.php on lines 193..206

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

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

          public function actionPoll()
          {
              if (!Yii::$app->request->isAjax) {
                  return $this->redirect(['forum/index']);
              }
      Severity: Major
      Found in src/controllers/ForumController.php - About 3 hrs to fix

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

            protected function addColumn($col, $type)
            {
                if (empty($col)) {
                    return Yii::t('podium/flash', 'Installation aborted! Column name missing.');
                }
        Severity: Major
        Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
        src/maintenance/SchemaOperation.php on lines 166..182

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

        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 alterColumn($col, $type)
            {
                if (empty($col)) {
                    return Yii::t('podium/flash', 'Installation aborted! Column name missing.');
                }
        Severity: Major
        Found in src/maintenance/SchemaOperation.php and 1 other location - About 3 hrs to fix
        src/maintenance/SchemaOperation.php on lines 75..91

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

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

            public function actionThumb()
            {
                if (!Yii::$app->request->isAjax) {
                    return $this->redirect(['forum/index']);
                }
        Severity: Minor
        Found in src/controllers/ForumPostController.php - About 3 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

        The class UserActiveRecord has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
        Open

        abstract class UserActiveRecord extends ActiveRecord implements IdentityInterface
        {
            /**
             * Statuses.
             */
        Severity: Minor
        Found in src/models/db/UserActiveRecord.php by phpmd

        The class Thread has an overall complexity of 104 which is very high. The configured complexity threshold is 50.
        Open

        class Thread extends ThreadActiveRecord
        {
            /**
             * Color classes.
             */
        Severity: Minor
        Found in src/models/Thread.php by phpmd

        The class User has 23 public methods. Consider refactoring User to keep number of public methods under 10.
        Open

        class User extends UserActiveRecord
        {
            /**
             * Roles.
             */
        Severity: Minor
        Found in src/models/User.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        The class ForumController has 15 public methods. Consider refactoring ForumController to keep number of public methods under 10.
        Open

        class ForumController extends ForumPostController
        {
            /**
             * @inheritdoc
             */
        Severity: Minor
        Found in src/controllers/ForumController.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        The class Post has an overall complexity of 116 which is very high. The configured complexity threshold is 50.
        Open

        class Post extends PostActiveRecord
        {
            /**
             * Returns latest posts for registered users.
             * @param int $limit Number of latest posts.
        Severity: Minor
        Found in src/models/Post.php by phpmd

        The class Thread has 11 public methods. Consider refactoring Thread to keep number of public methods under 10.
        Open

        class Thread extends ThreadActiveRecord
        {
            /**
             * Color classes.
             */
        Severity: Minor
        Found in src/models/Thread.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        Severity
        Category
        Status
        Source
        Language