bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

Function updateModeratorForMany has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateModeratorForMany($newForums = [], $oldForums = [])
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $add = [];
Severity: Minor
Found in src/models/User.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 timeZones has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function timeZones()
    {
        $timeZones = [];

        $timezone_identifiers = DateTimeZone::listIdentifiers();
Severity: Minor
Found in src/helpers/Helper.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 actionBan has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionBan($id = null)
    {
        $model = User::find()->where(['id' => $id])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
Severity: Minor
Found in src/controllers/AdminController.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 notify has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function notify($thread)
    {
        if (is_numeric($thread) && $thread > 0) {
            $forum = Podium::getInstance()->podiumConfig->get('name');
            $email = Content::fill(Content::EMAIL_SUBSCRIPTION);
Severity: Minor
Found in src/models/Subscription.php - About 1 hr to fix

    Method actionLoad has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function actionLoad()
        {
            if (!Yii::$app->request->isAjax) {
                return $this->redirect(['forum/index']);
            }
    Severity: Minor
    Found in src/controllers/MessagesController.php - About 1 hr to fix

      Method demoteTo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function demoteTo($role)
          {
              $transaction = static::getDb()->beginTransaction();
              try {
                  $this->scenario = 'role';
      Severity: Minor
      Found in src/models/User.php - About 1 hr to fix

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

            public static function findPostsCount($id)
            {
                $cache = Podium::getInstance()->podiumCache->getElement('user.postscount', $id);
                if ($cache === false) {
                    $cache = (new Query)->from(Post::tableName())->where(['author_id' => $id])->count();
        Severity: Major
        Found in src/models/User.php and 1 other location - About 1 hr to fix
        src/models/User.php on lines 265..273

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

        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 findThreadsCount($id)
            {
                $cache = Podium::getInstance()->podiumCache->getElement('user.threadscount', $id);
                if ($cache === false) {
                    $cache = (new Query)->from(Thread::tableName())->where(['author_id' => $id])->count();
        Severity: Major
        Found in src/models/User.php and 1 other location - About 1 hr to fix
        src/models/User.php on lines 241..249

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

        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 (Podium::getInstance()->user->isGuest) {
                    $query->joinWith(['forum' => function ($q) {
                        $q->andWhere([Forum::tableName() . '.visible' => 1])->joinWith(['category' => function ($q) {
                            $q->andWhere([Category::tableName() . '.visible' => 1]);
                        }]);
        Severity: Major
        Found in src/models/forms/SearchForm.php and 1 other location - About 1 hr to fix
        src/models/forms/SearchForm.php on lines 227..233

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

        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 (Podium::getInstance()->user->isGuest) {
                    $query->joinWith(['posts.forum' => function ($q) {
                        $q->andWhere([Forum::tableName() . '.visible' => 1])->joinWith(['category' => function ($q) {
                            $q->andWhere([Category::tableName() . '.visible' => 1]);
                        }]);
        Severity: Major
        Found in src/models/forms/SearchForm.php and 1 other location - About 1 hr to fix
        src/models/forms/SearchForm.php on lines 185..191

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

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

            public function actionFriend($id = null)
            {
                if (Podium::getInstance()->user->isGuest) {
                    return $this->redirect(['forum/index']);
                }
        Severity: Minor
        Found in src/controllers/MembersController.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if (is_numeric($this->categoryId) && $this->categoryId >= 1
                          && is_numeric($this->forumId) && $this->forumId >= 1
                          && is_numeric($this->threadId) && $this->threadId >= 1
                          && !empty($this->threadSlug)) {
                      return true;
          Severity: Major
          Found in src/services/ThreadVerifier.php - About 1 hr to fix

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

                    $actions[] = Html::button(Html::tag('span', '', ['class' => 'glyphicon glyphicon-eye-' . ($category->visible ? 'open' : 'close')]), ['class' => 'btn btn-xs text-muted', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $category->visible ? Yii::t('podium/view', 'Category visible for guests') : Yii::t('podium/view', 'Category hidden for guests')]);
            Severity: Minor
            Found in src/helpers/Helper.php and 1 other location - About 55 mins to fix
            src/helpers/Helper.php on lines 50..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 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

                    $actions[] = Html::button(Html::tag('span', '', ['class' => 'glyphicon glyphicon-eye-' . ($forum->visible ? 'open' : 'close')]), ['class' => 'btn btn-xs text-muted', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $forum->visible ? Yii::t('podium/view', 'Forum visible for guests (if category is visible)') : Yii::t('podium/view', 'Forum hidden for guests')]);
            Severity: Minor
            Found in src/helpers/Helper.php and 1 other location - About 55 mins to fix
            src/helpers/Helper.php on lines 33..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 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

            Function actionImport has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionImport()
                {
                    $result = ['error' => Yii::t('podium/view', 'Error')];
            
                    if (Yii::$app->request->isPost) {
            Severity: Minor
            Found in src/controllers/InstallController.php - About 55 mins 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 actionRegister has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionRegister()
                {
                    if ($this->module->userComponent !== true) {
                        $this->info(Yii::t('podium/flash', "Please use application's Register form to sign up."));
                        return $this->module->goPodium();
            Severity: Minor
            Found in src/controllers/AccountController.php - About 55 mins 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 can has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function can($permissionName, $params = [], $allowCaching = true)
                {
                    if (Podium::getInstance()->userComponent === true) {
                        return Podium::getInstance()->user->can($permissionName, $params, $allowCaching);
                    }
            Severity: Minor
            Found in src/models/User.php - About 55 mins 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 actionMark has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionMark($id = null)
                {
                    $model = Subscription::find()->where(['id' => $id, 'user_id' => User::loggedId()])->limit(1)->one();
                    if (empty($model)) {
                        $this->error(Yii::t('podium/flash', 'Sorry! We can not find Subscription with this ID.'));
            Severity: Minor
            Found in src/controllers/ProfileController.php - About 55 mins 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 actionIgnore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionIgnore($id = null)
                {
                    if (Podium::getInstance()->user->isGuest) {
                        return $this->redirect(['forum/index']);
                    }
            Severity: Minor
            Found in src/controllers/MembersController.php - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionDelete($cid = null, $fid = null, $id = null, $slug = null)
                {
                    $thread = (new ThreadVerifier([
                        'categoryId' => $cid,
                        'forumId' => $fid,
            Severity: Minor
            Found in src/controllers/ForumThreadController.php - About 55 mins 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