bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

Method process has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process($email, $fromName, $fromEmail, $maxAttempts)
    {
        try {
            if ($this->send($email, $fromName, $fromEmail)) {
                $this
Severity: Minor
Found in src/console/QueueController.php - About 1 hr to fix

    Method send has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method actionSortCategory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

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

                                        <?= $form->field($model, 'newPassword')->passwordInput([
                                            'placeholder'    => Yii::t('podium/view', "Leave empty if you don't want to change it"),
                                            'data-container' => 'body',
                                            'data-toggle'    => 'popover',
                                            'data-placement' => 'right',
        Severity: Major
        Found in src/views/profile/details.php and 1 other location - About 1 hr to fix
        src/views/profile/details.php on lines 62..72

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

        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

                                    <?= $form->field($model, 'new_email')->textInput([
                                        'placeholder'    => Yii::t('podium/view', "Leave empty if you don't want to change it"),
                                        'data-container' => 'body',
                                        'data-toggle'    => 'popover',
                                        'data-placement' => 'right',
        Severity: Major
        Found in src/views/profile/details.php and 1 other location - About 1 hr to fix
        src/views/profile/details.php on lines 78..88

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

        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

        The class Podium has 17 fields. Consider redesigning Podium to keep the number of fields under 15.
        Open

        class Podium extends Module implements BootstrapInterface
        {
            /**
             * @var int Admin account ID if $userComponent is not set to true.
             */
        Severity: Minor
        Found in src/Podium.php by phpmd

        TooManyFields

        Since: 0.1

        Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

        Example

        class Person {
           protected $one;
           private $two;
           private $three;
           [... many more fields ...]
        }

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

        Method actionMods has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionMods($id = null)
            {
                $mod = null;
                $moderators = User::find()->where(['role' => User::ROLE_MODERATOR])->indexBy('id')->all();
                if (is_numeric($id) && $id > 0) {
        Severity: Minor
        Found in src/controllers/AdminController.php - About 1 hr to fix

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

                  if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
                      $this->info(Yii::t('podium/flash', 'This thread is locked.'));
                      return $this->redirect([
                          'forum/thread',
                          'cid' => $post->forum->category->id,
          Severity: Major
          Found in src/controllers/ForumPostController.php and 1 other location - About 1 hr to fix
          src/controllers/ForumPostController.php on lines 59..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 110.

          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

                  if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
                      $this->info(Yii::t('podium/flash', 'This thread is locked.'));
                      return $this->redirect([
                          'forum/thread',
                          'cid' => $post->forum->category->id,
          Severity: Major
          Found in src/controllers/ForumPostController.php and 1 other location - About 1 hr to fix
          src/controllers/ForumPostController.php on lines 179..188

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

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

              public static function lastActive()
              {
                  $last = Podium::getInstance()->podiumCache->get('forum.lastactive');
                  if ($last === false) {
                      $time = time() - 15 * 60;
          Severity: Minor
          Found in src/models/Activity.php - About 1 hr to fix

            Method podiumEdit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function podiumEdit()
                {
                    $transaction = static::getDb()->beginTransaction();
                    try {
                        if (!$this->save()) {
            Severity: Minor
            Found in src/models/Poll.php - About 1 hr to fix

              Method init has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function init()
                  {
                      parent::init();
                      try {
                          if (!empty($this->module->accessChecker)) {
              Severity: Minor
              Found in src/controllers/BaseController.php - About 1 hr to fix

                Method addAdmin has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function addAdmin()
                    {
                        if ($this->module->userComponent !== true) {
                            return $this->addInheritedAdmin();
                        }
                Severity: Minor
                Found in src/maintenance/Installation.php - About 1 hr to fix

                  Method run has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function run()
                      {
                          $url = Yii::$app->request->getUrl();
                  
                          $out = '';
                  Severity: Minor
                  Found in src/widgets/Readers.php - About 1 hr to fix

                    Function podiumDelete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

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

                        public function set($name, $value)
                        {
                            try {
                                if (is_string($name) && (is_string($value) || $value === null)) {
                                    if ($value === null) {
                    Severity: Minor
                    Found in src/PodiumConfig.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 actionEditpoll has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function actionEditpoll($cid = null, $fid = null, $tid = null, $pid = null)
                        {
                            $poll = Poll::find()->joinWith('thread')->where([
                                Poll::tableName() . '.id' => $pid,
                                Poll::tableName() . '.thread_id' => $tid,
                    Severity: Minor
                    Found in src/controllers/ForumController.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 tooMany has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function tooMany($userId)
                        {
                            $sessionKey = 'messages.' . $userId;
                            if (Yii::$app->session->has($sessionKey)) {
                                $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
                    Severity: Minor
                    Found in src/models/Message.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 matchRole has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function matchRole($user)
                        {
                            if (empty($this->roles)) {
                                return true;
                            }
                    Severity: Minor
                    Found in src/filters/PodiumRoleRule.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 upgradeCheck has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function upgradeCheck($warnings)
                        {
                            if (!User::can(Rbac::ROLE_ADMIN)) {
                                return false;
                            }
                    Severity: Minor
                    Found in src/controllers/BaseController.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

                    Severity
                    Category
                    Status
                    Source
                    Language