bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

class ForumPostController extends ForumThreadController
{
    /**
     * @inheritdoc
     */

The class AdminForumController has 16 public methods. Consider refactoring AdminForumController to keep number of public methods under 10.
Open

class AdminForumController extends BaseController
{
    /**
     * @inheritdoc
     */

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 AdminForumController has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
Open

class AdminForumController extends BaseController
{
    /**
     * @inheritdoc
     */

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

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

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

abstract class UserActiveRecord extends ActiveRecord implements IdentityInterface
{
    /**
     * Statuses.
     */
Severity: Minor
Found in src/models/db/UserActiveRecord.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 Helper has 14 public methods. Consider refactoring Helper to keep number of public methods under 10.
Open

class Helper
{
    /**
     * Prepares content for categories administration.
     * @param mixed $category
Severity: Minor
Found in src/helpers/Helper.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 an overall complexity of 88 which is very high. The configured complexity threshold is 50.
Open

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

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

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

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

class SchemaOperation extends Component
{
    const TYPE_SUCCESS = 0;
    const TYPE_WARNING = 1;
    const TYPE_ERROR = 2;
Severity: Minor
Found in src/maintenance/SchemaOperation.php by phpmd

File AdminForumController.php has 305 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/AdminForumController.php - About 3 hrs to fix

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

        public static function roleLabel($role = null)
        {
            switch ($role) {
                case User::ROLE_ADMIN:
                    $label = 'danger';
    Severity: Major
    Found in src/helpers/Helper.php and 1 other location - About 3 hrs to fix
    src/helpers/Helper.php on lines 220..237

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

    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 static function statusLabel($status = null)
        {
            switch ($status) {
                case User::STATUS_ACTIVE:
                    $label = 'info';
    Severity: Major
    Found in src/helpers/Helper.php and 1 other location - About 3 hrs to fix
    src/helpers/Helper.php on lines 176..193

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

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

        public function remove()
        {
            $transaction = static::getDb()->beginTransaction();
            try {
                $clearCache = false;
    Severity: Minor
    Found in src/models/Message.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

    Function actionPost has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionPost($cid = null, $fid = null, $tid = null, $pid = null)
        {
            $thread = Thread::find()->where([
                    'id' => $tid,
                    'category_id' => $cid,
    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

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

                if ($this->isIgnoredBy($member)) {
                    if (!Podium::getInstance()->db->createCommand()->delete('{{%podium_user_ignore}}', [
                            'user_id' => $member,
                            'ignored_id' => $this->id
                        ])->execute()) {
    Severity: Major
    Found in src/models/User.php and 1 other location - About 3 hrs to fix
    src/models/User.php on lines 849..862

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

    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 ($this->isBefriendedBy($friend)) {
                    if (!Podium::getInstance()->db->createCommand()->delete('{{%podium_user_friend}}', [
                            'user_id' => $friend,
                            'friend_id' => $this->id
                        ])->execute()) {
    Severity: Major
    Found in src/models/User.php and 1 other location - About 3 hrs to fix
    src/models/User.php on lines 819..832

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

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

        public function podiumMovePostsTo($target = null, $posts = [], $name = null, $forum = null)
        {
            $transaction = static::getDb()->beginTransaction();
            try {
                if ($target == 0) {
    Severity: Minor
    Found in src/models/Thread.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

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

        protected function dropForeign($name)
        {
            if (empty($name)) {
                return Yii::t('podium/flash', 'Installation aborted! Foreign key 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 279..296

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

    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 dropIndex($name)
        {
            if (empty($name)) {
                return Yii::t('podium/flash', 'Installation aborted! Index 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 255..272

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

    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

    File Installation.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace bizley\podium\maintenance;
    
    use bizley\podium\models\Content;
    Severity: Minor
    Found in src/maintenance/Installation.php - About 2 hrs to fix
      Severity
      Category
      Status
      Source
      Language