bizley/yii2-podium

View on GitHub

Showing 223 of 419 total issues

Method searchPosts has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function searchPosts()
    {
        $query = Vocabulary::find()->select('post_id, thread_id')->joinWith(['posts.author', 'posts.thread'])->andWhere(['is not', 'post_id', null]);
        if (Podium::getInstance()->user->isGuest) {
            $query->joinWith(['posts.forum' => function ($q) {
Severity: Minor
Found in src/models/forms/SearchForm.php - About 1 hr to fix

    Method actionRegister has 35 lines of code (exceeds 25 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 1 hr to fix

      Method getDescription has 34 lines of code (exceeds 25 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 1 hr to fix

        Method actionReply has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionReply($id = null)
            {
                $podiumUser = User::findMe();
        
                if (Message::tooMany($podiumUser->id)) {
        Severity: Minor
        Found in src/controllers/MessagesController.php - About 1 hr to fix

          Method prepareQuery has 34 lines of code (exceeds 25 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 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if (!is_numeric($categoryId) || $categoryId < 1
                            || !is_numeric($forumId) || $forumId < 1
                            || !is_numeric($threadId) || $threadId < 1
                            || !is_numeric($id) || $id < 1) {
                        return null;
            Severity: Critical
            Found in src/models/Post.php - About 1 hr to fix

              Method defaultContent has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function defaultContent($name = null)
                  {
                      $defaults = [
                          self::EMAIL_REACTIVATION => [
                              'topic' => Yii::t('podium/view', '{forum} account reactivation'),
              Severity: Minor
              Found in src/models/Content.php - About 1 hr to fix

                Method searchTopics has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function searchTopics()
                    {
                        $query = Thread::find();
                        if (Podium::getInstance()->user->isGuest) {
                            $query->joinWith(['forum' => function ($q) {
                Severity: Minor
                Found in src/models/forms/SearchForm.php - About 1 hr to fix

                  Method addConfig has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function addConfig()
                      {
                          try {
                              $this->db->createCommand()->batchInsert(
                                      PodiumConfig::tableName(),
                  Severity: Minor
                  Found in src/maintenance/Installation.php - About 1 hr to fix

                    Method clearAfter has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function clearAfter($what)
                        {
                            $cache = new static;
                    
                            switch ($what) {
                    Severity: Minor
                    Found in src/PodiumCache.php - About 1 hr to fix

                      Method nextDrop has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function nextDrop()
                          {
                              $drops = $this->countDrops();
                              if (count($drops)) {
                                  $currentStep = Yii::$app->session->get(self::SESSION_KEY, 0);
                      Severity: Minor
                      Found in src/maintenance/Installation.php - About 1 hr to fix

                        Method actionBan has 33 lines of code (exceeds 25 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

                          Method nextStep has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function nextStep()
                              {
                                  $currentStep = Yii::$app->session->get(self::SESSION_KEY, 0);
                                  if ($currentStep === 0) {
                                      Yii::$app->session->set(self::SESSION_STEPS, count($this->steps));
                          Severity: Minor
                          Found in src/maintenance/Installation.php - About 1 hr to fix

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

                                public function run()
                                {
                                    $user = $this->getUser(User::STATUS_REGISTERED);
                                    if (empty($user)) {
                                        return [
                            Severity: Minor
                            Found in src/models/forms/ReactivateForm.php - About 1 hr to fix

                              Method actionRun has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function actionRun($limit = 0)
                                  {
                                      $version = $this->module->version;
                                      $this->stdout("\nPodium mail queue v{$version}\n");
                                      $this->stdout("------------------------------\n");
                              Severity: Minor
                              Found in src/console/QueueController.php - About 1 hr to fix

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

                                    public function run()
                                    {
                                        $user = $this->user;
                                        if (empty($user)) {
                                            return [
                                Severity: Minor
                                Found in src/models/forms/ResetForm.php - About 1 hr to fix

                                  Method actionShow has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function actionShow($id = null)
                                      {
                                          if (!is_numeric($id) || $id < 1) {
                                              $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
                                              return $this->redirect(['forum/index']);
                                  Severity: Minor
                                  Found in src/controllers/ForumController.php - About 1 hr to fix

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

                                        public function run()
                                        {
                                            $avatar = Html::img(Helper::defaultAvatar(), [
                                                'class' => 'podium-avatar img-circle img-responsive center-block',
                                                'alt' => Yii::t('podium/view', 'user deleted')
                                    Severity: Minor
                                    Found in src/widgets/Avatar.php - About 1 hr to fix

                                      Method actionDelete has 32 lines of code (exceeds 25 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 1 hr to fix

                                        Function updateWords has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            protected function updateWords()
                                            {
                                                try {
                                                    $vocabulary = [];
                                                    $allWords = $this->prepareWords();
                                        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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language