writesdown/app-cms

View on GitHub

Showing 233 of 233 total issues

Method setOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setOptions($options = [])
    {
        $this->options = [
            'script_url' => Yii::$app->request->absoluteUrl,
            'upload_dir' => Yii::getAlias('@public/uploads/'),
Severity: Minor
Found in common/components/MediaUploadHandler.php - About 1 hr to fix

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

    <?php
    
    use yii\db\Schema;
    
    /**
    Severity: Major
    Found in console/migrations/m000000_000016_media_meta.php and 1 other location - About 1 hr to fix
    console/migrations/m000000_000013_post_meta.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 118.

    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
    
    use yii\db\Schema;
    
    /**
    Severity: Major
    Found in console/migrations/m000000_000013_post_meta.php and 1 other location - About 1 hr to fix
    console/migrations/m000000_000016_media_meta.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 118.

    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 setMeta($name, $value)
        {
            if (is_array($value) || is_object($value)) {
                $value = Json::encode($value);
            }
    Severity: Major
    Found in common/models/Media.php and 1 other location - About 1 hr to fix
    common/models/Post.php on lines 259..276

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

    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 setMeta($name, $value)
        {
            if (is_array($value) || is_object($value)) {
                $value = Json::encode($value);
            }
    Severity: Major
    Found in common/models/Post.php and 1 other location - About 1 hr to fix
    common/models/Media.php on lines 212..229

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

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

            this.actionUpload = function () {
                this.upload.fileupload({
                        url: this.settings.url.upload,
                        dropZone: this.dropzone,
                        autoUpload: true,
    Severity: Minor
    Found in public/admin/js/media.browser.js - About 1 hr to fix

      Method search has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function search($params)
          {
              $query = MediaModel::find();
              $query->innerJoinWith([
                  'mediaAuthor' => function ($query) {
      Severity: Minor
      Found in common/models/search/Media.php - About 1 hr to fix

        Method actionBulkAction has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionBulkAction()
            {
                if (Yii::$app->request->post('action') === Post::STATUS_PUBLISH) {
                    foreach (Yii::$app->request->post('ids', []) as $id) {
                        $model = $this->findModel($id);
        Severity: Minor
        Found in backend/controllers/PostController.php - About 1 hr to fix

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

              public function actionUpdate($id)
              {
                  $model = $this->findModel($id);
          
                  if ($model->load(Yii::$app->request->post())) {
          Severity: Major
          Found in backend/controllers/PostCommentController.php and 1 other location - About 1 hr to fix
          backend/controllers/MediaCommentController.php on lines 86..100

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

          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

              public function actionUpdate($id)
              {
                  $model = $this->findModel($id);
          
                  if ($model->load(Yii::$app->request->post())) {
          Severity: Major
          Found in backend/controllers/MediaCommentController.php and 1 other location - About 1 hr to fix
          backend/controllers/PostCommentController.php on lines 93..107

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

          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

                  collapseAll: function()
                  {
                      var list = this;
                      list.el.find(list.options.itemNodeName).each(function() {
                          list.collapseItem($(this));
          Severity: Major
          Found in public/admin/js/menu.js and 1 other location - About 1 hr to fix
          public/admin/js/menu.js on lines 218..224

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

          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

                  expandAll: function()
                  {
                      var list = this;
                      list.el.find(list.options.itemNodeName).each(function() {
                          list.expandItem($(this));
          Severity: Major
          Found in public/admin/js/menu.js and 1 other location - About 1 hr to fix
          public/admin/js/menu.js on lines 226..232

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

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

              public function search($params, $type, $user = null)
              {
                  $query = PostModel::find();
                  $query->innerJoinWith(['postAuthor'])->from(['post' => static::tableName()]);
                  $query->andWhere(['type' => $type]);
          Severity: Minor
          Found in common/models/search/Post.php - About 1 hr to fix

            Function slugify has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                $.fn.slugify = function (source, options) {
                    var $target = this;
                    var $source = $(source);
                    var targetIsInput = $target.is('input') || $target.is('textarea');
            
            
            Severity: Minor
            Found in public/admin/js/site.js - About 1 hr to fix

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

                  public function behaviors()
                  {
                      return [
                          'access' => [
                              'class' => AccessControl::className(),
              Severity: Major
              Found in backend/controllers/PostTypeController.php and 1 other location - About 1 hr to fix
              backend/controllers/ThemeController.php on lines 52..73

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

              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 behaviors()
                  {
                      return [
                          'access' => [
                              'class' => AccessControl::className(),
              Severity: Major
              Found in backend/controllers/ThemeController.php and 1 other location - About 1 hr to fix
              backend/controllers/PostTypeController.php on lines 33..54

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

              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 attributeLabels()
                  {
                      return [
                          'id' => Yii::t('writesdown', 'ID'),
                          'taxonomy_id' => Yii::t('writesdown', 'Taxonomy ID'),
              Severity: Major
              Found in common/models/Term.php and 1 other location - About 1 hr to fix
              common/models/Taxonomy.php on lines 82..93

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

              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 attributeLabels()
                  {
                      return [
                          'id' => Yii::t('writesdown', 'ID'),
                          'name' => Yii::t('writesdown', 'Name'),
              Severity: Major
              Found in common/models/Taxonomy.php and 1 other location - About 1 hr to fix
              common/models/Term.php on lines 75..86

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

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

                  public function actionAjaxChangeHierarchical()
                  {
                      if (Yii::$app->request->post('action') === 'addItem') {
                          $model = new TermRelationship();
                          $model->load(Yii::$app->request->post());
              Severity: Minor
              Found in backend/controllers/TermRelationshipController.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 search has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function search($params, $posttype, $post = null)
                  {
                      $query = PostCommentModel::find();
              
                      $query->innerJoinWith([
              Severity: Minor
              Found in common/models/search/PostComment.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language