writesdown/app-cms

View on GitHub

Showing 233 of 233 total issues

Method actionIndex has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function actionIndex()
    {
        /* @var $post \common\models\Post */

        $query = Post::find()
Severity: Minor
Found in frontend/controllers/SiteController.php - About 1 hr to fix

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

        public function search($params, $mediaId = null)
        {
            $query = MediaCommentModel::find();
            $query->innerJoinWith([
                'commentMedia' => function ($query) {
    Severity: Minor
    Found in common/models/search/MediaComment.php - About 1 hr to fix

      Method actionCreateMenuItem has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function actionCreateMenuItem($id)
          {
              $items = '';
      
              if (Yii::$app->request->post('type') === 'link') {
      Severity: Minor
      Found in backend/controllers/MenuController.php - About 1 hr to fix

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

            public function behaviors()
            {
                return [
                    'access' => [
                        'class' => AccessControl::className(),
        Severity: Major
        Found in backend/controllers/MediaCommentController.php and 2 other locations - About 1 hr to fix
        backend/controllers/MediaBrowserController.php on lines 33..54
        backend/controllers/PostCommentController.php on lines 31..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 110.

        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

            public function behaviors()
            {
                return [
                    'access' => [
                        'class' => AccessControl::className(),
        Severity: Major
        Found in backend/controllers/PostCommentController.php and 2 other locations - About 1 hr to fix
        backend/controllers/MediaBrowserController.php on lines 33..54
        backend/controllers/MediaCommentController.php on lines 30..51

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

        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

            public function behaviors()
            {
                return [
                    'access' => [
                        'class' => AccessControl::className(),
        Severity: Major
        Found in backend/controllers/MediaBrowserController.php and 2 other locations - About 1 hr to fix
        backend/controllers/MediaCommentController.php on lines 30..51
        backend/controllers/PostCommentController.php on lines 31..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 110.

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

            public function actionCreate($type)
            {
                $model = new Post();
                $postType = $this->findPostType($type);
                $model->comment_status = Option::get('default_comment_status');
        Severity: Minor
        Found in backend/controllers/PostController.php - About 1 hr to fix

          Method behaviors has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function behaviors()
              {
                  return [
                      'access' => [
                          'class' => AccessControl::className(),
          Severity: Minor
          Found in backend/controllers/SiteController.php - About 1 hr to fix

            Function actionIndex has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionIndex()
                {
                    /* @var $post \common\models\Post */
            
                    $query = Post::find()
            Severity: Minor
            Found in frontend/controllers/SiteController.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 actionView has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionView($id = null, $slug = null)
                {
                    $render = 'view';
            
                    $comment = new Comment();
            Severity: Minor
            Found in frontend/controllers/MediaController.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 actionBulkAction has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

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

                public function actionView($id = null, $slug = null)
                {
                    $render = 'view';
                    $comment = new Comment();
            
            
            Severity: Minor
            Found in frontend/controllers/PostController.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 actionAjaxCreateHierarchical has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function actionAjaxCreateHierarchical()
                {
                    $item = '';
                    $term = new Term();
                    $termRelationship = new TermRelationship();
            Severity: Minor
            Found in backend/controllers/TermController.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

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

                        var onMoveEvent = function(e)
                        {
                            if (list.dragEl) {
                                e.preventDefault();
                                list.dragMove(e.touches ? e.touches[0] : e);
            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 118..124

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

            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

                        var onEndEvent = function(e)
                        {
                            if (list.dragEl) {
                                e.preventDefault();
                                list.dragStop(e.touches ? e.touches[0] : e);
            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 110..116

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

            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

            <?php
            
            $config = [
                'components' => [
                    'request' => [
            Severity: Major
            Found in environments/dev/frontend/config/main-local.php and 1 other location - About 1 hr to fix
            environments/dev/backend/config/main-local.php on lines 1..25

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

            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

            <?php
            
            $config = [
                'components' => [
                    'request' => [
            Severity: Major
            Found in environments/dev/backend/config/main-local.php and 1 other location - About 1 hr to fix
            environments/dev/frontend/config/main-local.php on lines 1..24

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

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

                public function up()
                {
                    $tableOptions = null;
            
                    if ($this->db->driverName === 'mysql') {
            Severity: Minor
            Found in console/migrations/m000000_000002_user.php - About 1 hr to fix

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

                  public function post($printResponse = self::PRINT_RESPONSE)
                  {
                      if (Yii::$app->request->get('delete') && $id = Yii::$app->request->get('id')) {
                          return $this->delete($id, $printResponse);
                      }
              Severity: Minor
              Found in common/components/MediaUploadHandler.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

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

                      do {
                          if ($(node).hasClass('dropzone')) {
                              found = true;
                              foundDropzone = $(node);
                              break;
              Severity: Major
              Found in public/admin/js/media.js and 1 other location - About 1 hr to fix
              public/admin/js/media.browser.js on lines 119..126

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

              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

              Severity
              Category
              Status
              Source
              Language