writesdown/app-cms

View on GitHub

Showing 233 of 233 total issues

Method up has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
Severity: Major
Found in console/migrations/m000000_000001_option.php - About 2 hrs to fix

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

            {
                li.removeClass(this.options.collapsedClass);
                li.children('[data-action="expand"]').hide();
                li.children('[data-action="collapse"]').show();
                li.children(this.options.listNodeName).show();
    Severity: Major
    Found in public/admin/js/menu.js and 1 other location - About 2 hrs to fix
    public/admin/js/menu.js on lines 210..215

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

    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 (lists.length) {
                    li.addClass(this.options.collapsedClass);
                    li.children('[data-action="collapse"]').hide();
                    li.children('[data-action="expand"]').show();
                    li.children(this.options.listNodeName).hide();
    Severity: Major
    Found in public/admin/js/menu.js and 1 other location - About 2 hrs to fix
    public/admin/js/menu.js on lines 200..205

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

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

        protected function createScaledImage($fileName, $version, $options)
        {
            $success = false;
            $filePath = $this->getFilePath($fileName);
            $image = Image::getImagine()->open($filePath);
    Severity: Major
    Found in common/components/MediaUploadHandler.php - About 2 hrs to fix

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

              if (Yii::$app->request->post('type') === 'taxonomy' && $termIds = Yii::$app->request->post('termIds')) {
                  foreach ($termIds as $termId) {
                      if ($term = $this->findTerm($termId)) {
                          $model = new MenuItem([
                              'menu_id' => $id,
      Severity: Major
      Found in backend/controllers/MenuController.php and 1 other location - About 2 hrs to fix
      backend/controllers/MenuController.php on lines 162..175

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

      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 (Yii::$app->request->post('type') === 'post' && $postIds = Yii::$app->request->post('postIds')) {
                  foreach ($postIds as $postId) {
                      if ($post = $this->findPost($postId)) {
                          $model = new MenuItem([
                              'menu_id' => $id,
      Severity: Major
      Found in backend/controllers/MenuController.php and 1 other location - About 2 hrs to fix
      backend/controllers/MenuController.php on lines 177..190

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

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

          protected function createScaledImage($fileName, $version, $options)
          {
              $success = false;
              $filePath = $this->getFilePath($fileName);
              $image = Image::getImagine()->open($filePath);
      Severity: Minor
      Found in common/components/MediaUploadHandler.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

      File Post.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * @link http://www.writesdown.com/
       * @copyright Copyright (c) 2015 WritesDown
       * @license http://www.writesdown.com/license/
      Severity: Minor
      Found in common/models/Post.php - About 2 hrs to fix

        File discussion.php has 263 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * @link http://www.writesdown.com/
         * @author Agiel K. Saputra <13nightevil@gmail.com>
         * @copyright Copyright (c) 2015 WritesDown
        Severity: Minor
        Found in backend/views/setting/discussion.php - About 2 hrs to fix

          Function setModule has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function setModule($app)
              {
                  foreach (Module::getActiveModules() as $module) {
                      // Get module backend config.
                      if ($config = $module->getFrontendConfig()) {
          Severity: Minor
          Found in common/components/FrontendBootstrap.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 setModule has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function setModule($app)
              {
                  foreach (Module::getActiveModules() as $module) {
                      // Get module backend config.
                      if ($config = $module->getBackendConfig()) {
          Severity: Minor
          Found in common/components/BackendBootstrap.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 actionUpload has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function actionUpload()
              {
                  $errors = [];
                  $model = new DynamicModel(['file']);
                  $model->addRule(['file'], 'required')
          Severity: Major
          Found in backend/controllers/ThemeController.php - About 2 hrs to fix

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

                public function getNextPostLink($title = '{title}', $sameType = true, $sameTerm = false, $options = [])
                {
                    if ($nextPost = $this->getNextPost($sameType, $sameTerm)) {
                        $title = preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) use ($nextPost) {
                            $attribute = $matches[1];
            Severity: Major
            Found in common/models/Post.php and 1 other location - About 2 hrs to fix
            common/models/Post.php on lines 396..409

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

            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

                public function getPrevPostLink($title = '{title}', $sameType = true, $sameTerm = false, $options = [])
                {
                    if ($prevPost = $this->getPrevPost($sameType, $sameTerm)) {
                        $title = preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) use ($prevPost) {
                            $attribute = $matches[1];
            Severity: Major
            Found in common/models/Post.php and 1 other location - About 2 hrs to fix
            common/models/Post.php on lines 340..353

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

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

                protected function displayComment($comment, $depth = 0)
                {
                    echo Html::beginTag('div', [
                        'id' => 'comment-' . $comment->id,
                        'class' => $comment->child ? 'parent depth-' . $depth : 'depth-' . $depth,
            Severity: Minor
            Found in frontend/widgets/comment/BaseComment.php - About 2 hrs to fix

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

                      $adminMenu[30] = [
                          'label' => Yii::t('writesdown', 'Modules'),
                          'icon' => 'fa fa-laptop',
                          'items' => [
                              [
              Severity: Major
              Found in backend/views/layouts/main-sidebar.php and 2 other locations - About 1 hr to fix
              backend/views/layouts/main-sidebar.php on lines 101..117
              backend/views/layouts/main-sidebar.php on lines 118..134

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

              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 3 locations. Consider refactoring.
              Open

                      $adminMenu[50] = [
                          'label' => Yii::t('writesdown', 'Taxonomies'),
                          'icon' => 'fa fa-tags',
                          'items' => [
                              [
              Severity: Major
              Found in backend/views/layouts/main-sidebar.php and 2 other locations - About 1 hr to fix
              backend/views/layouts/main-sidebar.php on lines 84..100
              backend/views/layouts/main-sidebar.php on lines 101..117

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

              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 3 locations. Consider refactoring.
              Open

                      $adminMenu[40] = [
                          'label' => Yii::t('writesdown', 'Post Types'),
                          'icon' => 'fa fa-files-o',
                          'items' => [
                              [
              Severity: Major
              Found in backend/views/layouts/main-sidebar.php and 2 other locations - About 1 hr to fix
              backend/views/layouts/main-sidebar.php on lines 84..100
              backend/views/layouts/main-sidebar.php on lines 118..134

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

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

                  var MediaModal = function (button, options) {
                      this.button = $(button);
              
                      this.settings = $.extend({
                          url: 'index.php?media-browser/index',
              Severity: Minor
              Found in public/admin/js/media.modal.js - About 1 hr to fix

                Function actionBulkAction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function actionBulkAction()
                    {
                        if (Yii::$app->request->post('action') === 'active') {
                            foreach (Yii::$app->request->post('ids', []) as $id) {
                                $model = $this->findModel($id);
                Severity: Minor
                Found in backend/controllers/UserController.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