comfy/comfortable-mexican-sofa

View on GitHub

Showing 135 of 135 total issues

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

  def test_fragment_field_for_file_with_content
    tag = ComfortableMexicanSofa::Content::Tag::File.new(context: @page, params: ["file"])
    actual = @builder.fragment_field(tag, 123)

    attachment = active_storage_attachments(:file)
Severity: Major
Found in test/lib/form_builder_test.rb and 1 other location - About 1 hr to fix
test/lib/form_builder_test.rb on lines 194..221

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

Method render_cms_page has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def render_cms_page(path, options = {}, locals = {}, &block)
    path.gsub!(%r{^/#{@cms_site.path}}, "") if @cms_site.path.present?

    unless (@cms_page = @cms_site.pages.find_by_full_path(path))
      raise ComfortableMexicanSofa::MissingPage, path
Severity: Minor
Found in lib/comfortable_mexican_sofa/render_methods.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 load_cms_site has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def load_cms_site
    @cms_site ||=
      if params[:site_id]
        ::Comfy::Cms::Site.find_by_id(params[:site_id])
      else
Severity: Minor
Found in app/controllers/comfy/cms/base_controller.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

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

  def test_fragment_field_for_files_with_content
    tag = ComfortableMexicanSofa::Content::Tag::Files.new(context: @page, params: ["file"])
    actual = @builder.fragment_field(tag, 123)

    attachment = active_storage_attachments(:file)
Severity: Major
Found in test/lib/form_builder_test.rb and 1 other location - About 1 hr to fix
test/lib/form_builder_test.rb on lines 147..174

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

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 433..454

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

Method content has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def content
    return "" unless layout

    base = ComfortableMexicanSofa.config.public_cms_path || ""
    unless base.ends_with?("/")
Severity: Minor
Found in lib/comfortable_mexican_sofa/content/tags/asset.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 reset_config has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def reset_config
    ComfortableMexicanSofa.configure do |config|
      config.cms_title            = "ComfortableMexicanSofa CMS Engine"
      config.admin_auth           = "ComfortableMexicanSofa::AccessControl::AdminAuthentication"
      config.admin_authorization  = "ComfortableMexicanSofa::AccessControl::AdminAuthorization"
Severity: Minor
Found in test/test_helper.rb - About 1 hr to fix

    Method test_get_public_page_with_sites_with_different_paths has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def test_get_public_page_with_sites_with_different_paths
        Comfy::Cms::Site.delete_all
        site_a = Comfy::Cms::Site.create!(identifier: "site-a", hostname: "www.example.com", path: "")
        site_b = Comfy::Cms::Site.create!(identifier: "site-b", hostname: "www.example.com", path: "path-b")
        site_c = Comfy::Cms::Site.create!(identifier: "site-c", hostname: "www.example.com", path: "path-c/child")
    Severity: Minor
    Found in test/integration/sites_test.rb - About 1 hr to fix

      Method import_layout has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def import_layout(path, parent)
            identifier = path.split("/").last
      
            # reading file content in, resulting in a hash
            content_path = File.join(path, "content.html")
      Severity: Minor
      Found in lib/comfortable_mexican_sofa/seeds/layout/importer.rb - About 1 hr to fix

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

            widget.querySelector('.read button.toggle-cat-edit').addEventListener('click', () => {
              readSection.style.display = 'none';
              editSection.style.display = 'block';
            });
        Severity: Major
        Found in app/assets/javascripts/comfy/admin/cms/categories.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/comfy/admin/cms/categories.js on lines 11..14

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

        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

            widget.querySelector('.editable button.toggle-cat-edit').addEventListener('click', () => {
              editSection.style.display = 'none';
              readSection.style.display = 'block';
            });
        Severity: Major
        Found in app/assets/javascripts/comfy/admin/cms/categories.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/comfy/admin/cms/categories.js on lines 7..10

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

        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

          def show
            @current_content = @record.fragments.each_with_object({}) do |b, c|
              c[b.identifier] = b.content
            end
            @versioned_content = @record.fragments.each_with_object({}) do |b, c|
        app/controllers/comfy/admin/cms/revisions/page_controller.rb on lines 5..14

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

        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

          def show
            @current_content = @record.fragments.each_with_object({}) do |b, c|
              c[b.identifier] = b.content
            end
            @versioned_content = @record.fragments.each_with_object({}) do |b, c|
        app/controllers/comfy/admin/cms/revisions/translation_controller.rb on lines 5..14

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

        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 create has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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

          def test_content_for_js_as_tag
            tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
              context: @page,
              params: ["default", { "type" => "js", "as" => "tag" }]
            )
        Severity: Minor
        Found in test/lib/content/tags/asset_test.rb and 1 other location - About 55 mins to fix
        test/lib/content/tags/asset_test.rb on lines 57..64

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

        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

          def test_content_for_css_as_tag
            tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
              context: @page,
              params: ["default", { "type" => "css", "as" => "tag" }]
            )
        Severity: Minor
        Found in test/lib/content/tags/asset_test.rb and 1 other location - About 55 mins to fix
        test/lib/content/tags/asset_test.rb on lines 86..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 44.

        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

          def preview_page
            if params[:preview]
              layout = @page.layout.app_layout.blank? ? false : @page.layout.app_layout
              @cms_site   = @page.site
              @cms_layout = @page.layout
        Severity: Minor
        Found in app/controllers/comfy/admin/cms/pages_controller.rb and 1 other location - About 50 mins to fix
        app/controllers/comfy/admin/cms/translations_controller.rb on lines 88..104

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

        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

          def preview_translation
            if params[:preview]
              layout = @translation.layout.app_layout.blank? ? false : @translation.layout.app_layout
              @cms_site   = @page.site
              @cms_layout = @translation.layout
        Severity: Minor
        Found in app/controllers/comfy/admin/cms/translations_controller.rb and 1 other location - About 50 mins to fix
        app/controllers/comfy/admin/cms/pages_controller.rb on lines 134..149

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

        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

          def test_content_for_js_with_public_cms_path
            ComfortableMexicanSofa.config.public_cms_path = "/custom"
            tag = ComfortableMexicanSofa::Content::Tag::Asset.new(
              context: @page,
              params: ["default", { "type" => "js" }]
        Severity: Minor
        Found in test/lib/content/tags/asset_test.rb and 1 other location - About 45 mins to fix
        test/lib/content/tags/asset_test.rb on lines 67..74

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

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

          def test_init_with_params
            tag = ComfortableMexicanSofa::Content::Tag::Files.new(
              context: @page,
              params: ["test", {
                "as"      => "image",
        Severity: Major
        Found in test/lib/content/tags/files_test.rb and 3 other locations - About 45 mins to fix
        test/lib/content/tags/file_link_test.rb on lines 22..40
        test/lib/content/tags/file_test.rb on lines 23..39
        test/lib/content/tags/page_file_link_test.rb on lines 22..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 41.

        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