comfy/comfortable-mexican-sofa

View on GitHub

Showing 135 of 135 total issues

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

    def import_page(path, parent)
      slug = path.split("/").last

      # setting page record
      page =
Severity: Minor
Found in lib/comfortable_mexican_sofa/seeds/page/importer.rb - About 1 hr to fix

    Method comfy_route_cms_admin has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def comfy_route_cms_admin(path: "admin")
        scope module: :comfy, as: :comfy do
          scope module: :admin do
            namespace :cms, as: :admin_cms, path: path, except: :show do
              get "/", to: "base#jump"
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/routes/cms_admin.rb - About 1 hr to fix

      Method import_page has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def import_page(path, parent)
            slug = path.split("/").last
      
            # setting page record
            page =
      Severity: Minor
      Found in lib/comfortable_mexican_sofa/seeds/page/importer.rb - 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 import! has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def import!
            Dir["#{path}[^_]*"].each do |file_path|
              filename = ::File.basename(file_path)
      
              file = site.files.with_attached_attachment
      Severity: Minor
      Found in lib/comfortable_mexican_sofa/seeds/file/importer.rb - About 1 hr to fix

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

          def test_update_forces_page_content_reload
            layout_a = comfy_cms_layouts(:nested)
            layout_b = comfy_cms_layouts(:child)
            page_a = @site.pages.create!(
              label:        "page_1",
        Severity: Minor
        Found in test/models/layout_test.rb - About 1 hr to fix

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

            def test_creation_with_files
              assert_difference "Comfy::Cms::Page.count" do
                assert_difference "Comfy::Cms::Fragment.count", 3 do
                  assert_difference "ActiveStorage::Attachment.count", 3 do
                    r :post, comfy_admin_cms_site_pages_path(site_id: @site), params: {
          Severity: Minor
          Found in test/controllers/comfy/admin/cms/pages_controller_test.rb - About 1 hr to fix

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

                  assert_equal [
                    { identifier: "boolean",
                      tag:        "checkbox",
                      content:    nil,
                      datetime:   nil,
            Severity: Major
            Found in test/lib/revisions_test.rb and 1 other location - About 1 hr to fix
            test/controllers/comfy/admin/cms/revisions/page_controller_test.rb on lines 59..85

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

            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

                  assert_equal [
                    { identifier: "boolean",
                      tag:        "checkbox",
                      content:    nil,
                      datetime:   nil,
            test/lib/revisions_test.rb on lines 158..184

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

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

              def test_creation_for_page
                assert_difference -> { @page.revisions.count } do
                  @page.update!(
                    fragments_attributes:  [
                      { identifier: "content",
            Severity: Minor
            Found in test/lib/revisions_test.rb - About 1 hr to fix

              Method test_revert has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def test_revert
                  assert_difference -> { @page.revisions.count } do
                    r :patch, revert_comfy_admin_cms_site_page_revision_path(@site, @page, @revision)
                    assert_response :redirect
                    assert_redirected_to edit_comfy_admin_cms_site_page_path(@site, @page)
              Severity: Minor
              Found in test/controllers/comfy/admin/cms/revisions/page_controller_test.rb - About 1 hr to fix

                Function buildRedactorOptions has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const buildRedactorOptions = () => {
                    const fileUploadPath = document.querySelector('meta[name="cms-file-upload-path"]').content;
                    const pagesPath = document.querySelector('meta[name="cms-pages-path"]').content;
                    const csrfParam = Rails.csrfParam();
                    const csrfToken = Rails.csrfToken();
                Severity: Minor
                Found in app/assets/javascripts/comfy/admin/cms/wysiwyg.js - About 1 hr to fix

                  Method test_restore_from_revision_for_page has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def test_restore_from_revision_for_page
                      revision = comfy_cms_revisions(:page)
                  
                      assert_difference -> { @page.revisions.count } do
                        @page.restore_from_revision(revision)
                  Severity: Minor
                  Found in test/lib/revisions_test.rb - About 1 hr to fix

                    Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        categories_scope = @site.categories.of_type("Comfy::Cms::File")
                    
                        if params[:categories]
                          ids = categories_scope.where(label: params[:categories]).pluck(:id)
                    Severity: Minor
                    Found in app/controllers/comfy/admin/cms/files_controller.rb - About 1 hr to fix

                      Method nodes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def nodes(tokens)
                          nodes = [[]]
                          tokens.each do |token|
                            case token
                      
                      
                      Severity: Minor
                      Found in lib/comfortable_mexican_sofa/content/renderer.rb - About 1 hr to fix

                        Method import_translations has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def import_translations(path, page)
                              old_translations = page.translations.pluck(:locale)
                              new_translations = []
                        
                              Dir["#{path}content.*.html"].each do |file_path|
                        Severity: Minor
                        Found in lib/comfortable_mexican_sofa/seeds/page/importer.rb - About 1 hr to fix

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

                          class ContentTagsCheckboxTest < ActiveSupport::TestCase
                          
                            setup do
                              @page = comfy_cms_pages(:default)
                            end
                          Severity: Major
                          Found in test/lib/content/tags/checkbox_test.rb and 1 other location - About 1 hr to fix
                          test/lib/content/tags/date_test.rb on lines 5..20

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

                          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

                          class ContentTagsDateTest < ActiveSupport::TestCase
                          
                            setup do
                              @page = comfy_cms_pages(:default)
                            end
                          Severity: Major
                          Found in test/lib/content/tags/date_test.rb and 1 other location - About 1 hr to fix
                          test/lib/content/tags/checkbox_test.rb on lines 5..20

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

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

                            def test_seeds_enabled
                              ComfortableMexicanSofa.config.enable_seeds = true
                              Comfy::Cms::Layout.destroy_all
                              Comfy::Cms::Page.destroy_all
                              Comfy::Cms::Snippet.destroy_all
                          Severity: Minor
                          Found in test/integration/seeds_test.rb - About 1 hr to fix

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

                              def index
                                files_scope = @site.files.with_attached_attachment
                            
                                case params[:source]
                            
                            
                            Severity: Minor
                            Found in app/controllers/comfy/admin/cms/files_controller.rb - About 1 hr to fix

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

                                  assert_equal [
                                    { identifier: "boolean",
                                      tag:        "checkbox",
                                      content:    nil,
                                      datetime:   nil,
                              Severity: Major
                              Found in test/models/page_test.rb and 1 other location - About 1 hr to fix
                              test/models/page_test.rb on lines 410..431

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

                              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