bizley/yii2-podium

View on GitHub

Showing 223 of 419 total issues

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

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

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

        public function actionContents($name = '')
        {
            if (empty($name)) {
                $name = Content::TERMS_AND_CONDS;
            }
    Severity: Minor
    Found in src/controllers/AdminForumController.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 nextDrop has a Cognitive Complexity of 9 (exceeds 5 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 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 add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function add()
        {
            try {
                $ip = Yii::$app->request->userIp;
                $url = Yii::$app->request->url;
    Severity: Minor
    Found in src/models/Activity.php - About 45 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 requiredPollAnswers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function requiredPollAnswers()
        {
            if ($this->pollAdded) {
                $this->pollAnswers = array_unique($this->pollAnswers);
                $filtered = [];
    Severity: Minor
    Found in src/models/db/ThreadActiveRecord.php - About 45 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 addNewWords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addNewWords($allWords)
        {
            try {
                $newWords = $allWords;
                $query = (new Query())->from(Vocabulary::tableName())->where(['word' => $allWords]);
    Severity: Minor
    Found in src/models/Post.php - About 45 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

    Avoid deeply nested control flow statements.
    Open

                                if (!$model->image->saveAs($path . DIRECTORY_SEPARATOR . $model->avatar)) {
                                    Log::error('Error while saving avatar image', null, __METHOD__);
                                    $this->error(Yii::t('podium/flash', 'Sorry! There was an error while uploading the avatar image. Contact administrator about this problem.'));
                                }
    Severity: Major
    Found in src/controllers/ProfileController.php - About 45 mins to fix

      Function actionFriend has a Cognitive Complexity of 8 (exceeds 5 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 45 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 searchTopics has a Cognitive Complexity of 8 (exceeds 5 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 45 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

      Avoid deeply nested control flow statements.
      Open

                                  if (!FileHelper::createDirectory($path)) {
                                      $folderExists = false;
                                      Log::error('Error while creating avatars folder', null, __METHOD__);
                                      $this->error(Yii::t('podium/flash', 'Sorry! There was an error while creating the avatars folder. Contact administrator about this problem.'));
                                  }
      Severity: Major
      Found in src/controllers/ProfileController.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (!empty($model->avatar) && file_exists($oldAvatarPath)) {
                                        if (!unlink($oldAvatarPath)) {
                                            Log::error('Error while deleting old avatar image', null, __METHOD__);
                                        }
                                    }
        Severity: Major
        Found in src/controllers/ProfileController.php - About 45 mins to fix

          Function vote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function vote($userId, $answers)
              {
                  $votes = [];
                  $time = time();
                  foreach ($answers as $answer) {
          Severity: Minor
          Found in src/models/Poll.php - About 45 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 addInheritedAdmin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function addInheritedAdmin()
              {
                  if (empty($this->module->adminId)) {
                      $this->type = self::TYPE_WARNING;
                      return Yii::t('podium/flash', 'No administrator privileges have been set!');
          Severity: Minor
          Found in src/maintenance/Installation.php - About 45 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 emailCheck has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function emailCheck($warnings)
              {
                  if ($warnings) {
                      foreach ($warnings as $warning) {
                          if ($warning === static::warnings()['email']) {
          Severity: Minor
          Found in src/controllers/BaseController.php - About 45 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