writesdown/app-cms

View on GitHub

Showing 233 of 233 total issues

Method actionCreate has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionCreate()
    {
        $errors = [];
        $model = new Module(['scenario' => 'create']);

Severity: Major
Found in backend/controllers/ModuleController.php - About 2 hrs to fix

    Function beforeSave has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function beforeSave($insert)
        {
            if (parent::beforeSave($insert)) {
                if ($this->isNewRecord) {
                    if (!Yii::$app->user->isGuest) {
    Severity: Minor
    Found in common/models/BaseComment.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 actionView has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function actionView($type, $slug, $page = 1)
        {
            /* @var $taxonomy Taxonomy */
            /* @var $postType PostType */
            /* @var $posts Post[] */
    Severity: Minor
    Found in modules/sitemap/frontend/controllers/DefaultController.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 renderToolbar has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function renderToolbar($event)
        {
            /* @var $view View */
            /* @var $urlBack \yii\web\UrlManager */
    
    
    Severity: Major
    Found in modules/toolbar/frontend/Module.php - About 2 hrs to fix

      Method up has 67 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_000011_post.php - About 2 hrs to fix

        User has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class User extends ActiveRecord implements IdentityInterface
        {
            const STATUS_REMOVED = 0;
            const STATUS_NOT_ACTIVE = 5;
            const STATUS_ACTIVE = 10;
        Severity: Minor
        Found in common/models/User.php - About 2 hrs to fix

          Post has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Post extends ActiveRecord
          {
              public $username;
          
              const COMMENT_STATUS_OPEN = 'open';
          Severity: Minor
          Found in common/models/Post.php - About 2 hrs to fix

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

                $.fn.mediabrowser = function (options) {
                    return this.each(function () {
                        var $this = $(this);
            
                        if ($this.data('mediabrowser')) {
            Severity: Major
            Found in public/admin/js/media.browser.js and 1 other location - About 2 hrs to fix
            public/admin/js/media.modal.js on lines 64..76

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

            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

                $.fn.mediamodal = function (options) {
                    return this.each(function() {
                        var element = $(this);
            
                        if (element.data('mediamodal')) {
            Severity: Major
            Found in public/admin/js/media.modal.js and 1 other location - About 2 hrs to fix
            public/admin/js/media.browser.js on lines 349..361

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

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

                public function up()
                {
                    $tableOptions = null;
            
                    if ($this->db->driverName === 'mysql') {
            Severity: Major
            Found in console/migrations/m000000_000020_module.php - About 2 hrs to fix

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

                  public function actionBulkAction()
                  {
                      if (Yii::$app->request->post('action') === MediaComment::STATUS_APPROVED) {
                          foreach (Yii::$app->request->post('ids', []) as $id) {
                              $this->findModel($id)->updateAttributes(['status' => MediaComment::STATUS_APPROVED]);
              Severity: Minor
              Found in backend/controllers/MediaCommentController.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 actionBulkAction has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

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

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

              <?php
              /**
               * @link http://www.writesdown.com/
               * @author Agiel K. Saputra <13nightevil@gmail.com>
               * @copyright Copyright (c) 2015 WritesDown
              Severity: Major
              Found in backend/views/post-comment/_form-reply.php and 1 other location - About 2 hrs to fix
              backend/views/media-comment/_form-reply.php on lines 1..40

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

              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
              /**
               * @link http://www.writesdown.com/
               * @author Agiel K. Saputra <13nightevil@gmail.com>
               * @copyright Copyright (c) 2015 WritesDown
              Severity: Major
              Found in backend/views/media-comment/_form-reply.php and 1 other location - About 2 hrs to fix
              backend/views/post-comment/_form-reply.php on lines 1..39

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

              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
              /**
               * @link http://www.writesdown.com/
               * @author Agiel K. Saputra <13nightevil@gmail.com>
               * @copyright Copyright (c) 2015 WritesDown
              Severity: Major
              Found in backend/views/site/reset-password.php and 1 other location - About 2 hrs to fix
              backend/views/site/request-password-reset-token.php on lines 1..48

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

              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
              /**
               * @link http://www.writesdown.com/
               * @author Agiel K. Saputra <13nightevil@gmail.com>
               * @copyright Copyright (c) 2015 WritesDown
              Severity: Major
              Found in backend/views/site/request-password-reset-token.php and 1 other location - About 2 hrs to fix
              backend/views/site/reset-password.php on lines 1..46

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

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

                      init: function()
                      {
                          var list = this;
              
                          list.reset();
              Severity: Major
              Found in public/admin/js/menu.js - About 2 hrs to fix

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

                if ($seo = $post->getMeta('seo')) {
                    if ($metaDescription = ArrayHelper::getValue($seo, 'description')) {
                        $this->registerMetaTag([
                            'name' => 'description',
                            'content' => $metaDescription,
                Severity: Major
                Found in themes/writesdown/post/view.php and 1 other location - About 2 hrs to fix
                themes/writesdown/post/protected.php on lines 18..36

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

                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 ($seo = $post->getMeta('seo')) {
                    if ($metaDescription = ArrayHelper::getValue($seo, 'description')) {
                        $this->registerMetaTag([
                            'name' => 'description',
                            'content' => $metaDescription,
                Severity: Major
                Found in themes/writesdown/post/protected.php and 1 other location - About 2 hrs to fix
                themes/writesdown/post/view.php on lines 21..39

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

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

                    public function actionCreate()
                    {
                        $errors = [];
                        $model = new Widget(['scenario' => 'upload']);
                
                
                Severity: Major
                Found in backend/controllers/WidgetController.php - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language