bizley/yii2-podium

View on GitHub

Showing 419 of 419 total issues

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

    public static function updateInheritedAccount()
    {
        if (!Podium::getInstance()->user->isGuest) {
            $userNameField = Podium::getInstance()->userNameField;
            if ($userNameField === null) {
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 actionDeletepoll has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function actionDeletepoll($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

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

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

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

        Method nextStep has 30 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->versionSteps));
        Severity: Minor
        Found in src/maintenance/Update.php - About 1 hr to fix

          Avoid using undefined variables such as '$properties' which will lead to PHP notices.
          Open

                  $properties['duration'] = $duration;
          Severity: Minor
          Found in src/PodiumCache.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$properties' which will lead to PHP notices.
          Open

                  $cache = FragmentCache::begin($properties);
          Severity: Minor
          Found in src/PodiumCache.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          The class User has 45 public methods and attributes. Consider reducing the number of public items to less than 45.
          Open

          class User extends UserActiveRecord
          {
              /**
               * Roles.
               */
          Severity: Minor
          Found in src/models/User.php by phpmd

          ExcessivePublicCount

          Since: 0.1

          A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

          Example

          public class Foo {
              public $value;
              public $something;
              public $var;
              // [... more more public attributes ...]
          
              public function doWork() {}
              public function doMoreWork() {}
              public function doWorkAgain() {}
              // [... more more public methods ...]
          }

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

          Avoid using undefined variables such as '$properties' which will lead to PHP notices.
          Open

                  $properties['id'] = $this->_cachePrefix . $key;
          Severity: Minor
          Found in src/PodiumCache.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          Avoid using undefined variables such as '$properties' which will lead to PHP notices.
          Open

                  $properties['view'] = $view;
          Severity: Minor
          Found in src/PodiumCache.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

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

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

            <?php if (empty($items)): ?>
                    <h3><?= Yii::t('podium/view', 'No categories have been added yet.') ?></h3>
            <?php else: ?>
                    <?= Sortable::widget([
                        'showHandle'   => true,
            Severity: Major
            Found in src/views/admin/categories.php and 1 other location - About 1 hr to fix
            src/views/admin/forums.php on lines 58..69

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

            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 (empty($items)): ?>
                    <h3><?= Yii::t('podium/view', 'No forums have been added yet in this category.') ?></h3>
            <?php else: ?>
                    <?= Sortable::widget([
                        'showHandle' => true,
            Severity: Major
            Found in src/views/admin/forums.php and 1 other location - About 1 hr to fix
            src/views/admin/categories.php on lines 41..52

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

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

                public function actionForum($cid = null, $id = null, $slug = null, $toggle = null)
                {
                    $filters = Yii::$app->session->get('forum-filters');
                    if (in_array(strtolower($toggle), ['new', 'edit', 'hot', 'pin', 'lock', 'all'])) {
                        if (strtolower($toggle) == 'all') {
            Severity: Minor
            Found in src/controllers/ForumController.php - About 1 hr to fix

              Method getIcon has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getIcon()
                  {
                      $icon   = self::ICON_NO_NEW;
                      $append = false;
              
              Severity: Minor
              Found in src/models/Thread.php - About 1 hr to fix

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

                    public function update($data)
                    {
                        $validator = new StringValidator();
                        $validator->max = 255;
                
                
                Severity: Minor
                Found in src/models/forms/ConfigForm.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 podiumReport has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function podiumReport($post = null)
                    {
                        try {
                            if (empty($post)) {
                                throw new Exception('Reported post missing');
                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 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 getMods has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getMods()
                    {
                        $mods = Podium::getInstance()->podiumCache->getElement('forum.moderators', $this->id);
                        if ($mods === false) {
                            $mods = [];
                Severity: Minor
                Found in src/models/Forum.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