bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

Function init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function init()
    {
        parent::init();
        try {
            if (!empty($this->module->accessChecker)) {
Severity: Minor
Found in src/controllers/BaseController.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

Method actionThumb has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    Method markSeen has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

      <?php if (User::can(Rbac::PERM_LOCK_THREAD, ['item' => $thread])): ?>
                          <li>
                              <a href="<?= Url::to(['forum/lock', 'cid' => $thread->category_id, 'fid' => $thread->forum_id, 'id' => $thread->id, 'slug' => $thread->slug]) ?>" class="btn btn-primary btn-xs">
                                  <span class="glyphicon glyphicon-lock"></span>
                                  <?php if ($thread->locked): ?>
      Severity: Major
      Found in src/views/forum/thread.php and 1 other location - About 2 hrs to fix
      src/views/forum/thread.php on lines 41..54

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

      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 if (User::can(Rbac::PERM_PIN_THREAD, ['item' => $thread])): ?>
                          <li>
                              <a href="<?= Url::to(['forum/pin', 'cid' => $thread->category_id, 'fid' => $thread->forum_id, 'id' => $thread->id, 'slug' => $thread->slug]) ?>" class="btn btn-primary btn-xs">
                                  <span class="glyphicon glyphicon-pushpin"></span>
                                  <?php if ($thread->pinned): ?>
      Severity: Major
      Found in src/views/forum/thread.php and 1 other location - About 2 hrs to fix
      src/views/forum/thread.php on lines 55..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 137.

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

          public function podiumMovePostsTo($target = null, $posts = [], $name = null, $forum = null)
          {
              $transaction = static::getDb()->beginTransaction();
              try {
                  if ($target == 0) {
      Severity: Major
      Found in src/models/Thread.php - About 2 hrs to fix

        Function export has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function export()
            {
                $tableName = Podium::getInstance()->db->quoteTableName($this->logTable);
                $sql = "INSERT INTO $tableName ([[level]], [[category]], [[log_time]], [[ip]], [[message]], [[model]], [[user]])
                        VALUES (:level, :category, :log_time, :ip, :message, :model, :user)";
        Severity: Minor
        Found in src/log/DbTarget.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 prepareQuery has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function prepareQuery($query, $topics = false)
            {
                $field = $topics
                        ? Thread::tableName() . '.created_at'
                        : Post::tableName() . '.updated_at';
        Severity: Minor
        Found in src/models/forms/SearchForm.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 actionDetails has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionDetails()
            {
                $model = User::findMe();
                if (empty($model)) {
                    return $this->redirect(['account/login']);
        Severity: Minor
        Found in src/controllers/ProfileController.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 podiumEdit has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function podiumEdit()
            {
                $transaction = static::getDb()->beginTransaction();
                try {
                    if (!$this->save()) {
        Severity: Minor
        Found in src/models/Poll.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 actionMove has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

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

        Method search has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function search($params)
            {
                $subquery = (new Query())
                            ->select(['m2.replyto'])
                            ->from(['m1' => Message::tableName()])
        Severity: Major
        Found in src/models/MessageReceiver.php - About 2 hrs to fix

          File SchemaOperation.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace bizley\podium\maintenance;
          
          use bizley\podium\Podium;
          Severity: Minor
          Found in src/maintenance/SchemaOperation.php - About 2 hrs to fix

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

                            if ($thread->podiumDeletePosts($posts)) {
                                $this->success(Yii::t('podium/flash', 'Posts have been deleted.'));
                                if (Thread::find()->where(['id' => $thread->id])->exists()) {
                                    return $this->redirect([
                                        'forum/thread',
            Severity: Major
            Found in src/controllers/ForumPostController.php and 1 other location - About 2 hrs to fix
            src/controllers/ForumPostController.php on lines 270..287

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

            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 ($thread->podiumMovePostsTo($newthread, $posts, $newname, $newforum)) {
                                            $this->success(Yii::t('podium/flash', 'Posts have been moved.'));
                                            if (Thread::find()->where(['id' => $thread->id])->exists()) {
                                                return $this->redirect([
                                                    'forum/thread',
            Severity: Major
            Found in src/controllers/ForumPostController.php and 1 other location - About 2 hrs to fix
            src/controllers/ForumPostController.php on lines 135..152

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

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

                public function getDescription()
                {
                    $description = Yii::t('podium/view', 'No New Posts');
                    $append = false;
            
            Severity: Minor
            Found in src/models/Thread.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 notify has a Cognitive Complexity of 19 (exceeds 5 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 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 actionLoad has a Cognitive Complexity of 19 (exceeds 5 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 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 actionPoll has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

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

            Method behaviors has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function behaviors()
                {
                    return [
                        'access' => [
                            'class' => AccessControl::className(),
            Severity: Major
            Found in src/controllers/AdminController.php - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language