comfy/comfortable-mexican-sofa

View on GitHub

Showing 135 of 135 total issues

Method find_site has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_site(host, path = nil)
    return Comfy::Cms::Site.first if Comfy::Cms::Site.count == 1
    cms_site = nil

    public_cms_path = ComfortableMexicanSofa.configuration.public_cms_path
Severity: Minor
Found in app/models/comfy/cms/site.rb - About 35 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

Method render_cms_layout has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def render_cms_layout(identifier, options = {}, locals = {}, &block)
    unless (@cms_layout = @cms_site.layouts.find_by_identifier(identifier))
      raise ComfortableMexicanSofa::MissingLayout, identifier
    end

Severity: Minor
Found in lib/comfortable_mexican_sofa/render_methods.rb - About 35 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 4 locations. Consider refactoring.
Open

  def update
    @layout.update!(layout_params)
    flash[:success] = I18n.t("comfy.admin.cms.layouts.updated")
    redirect_to action: :edit, id: @layout
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/layouts_controller.rb and 3 other locations - About 35 mins to fix
app/controllers/comfy/admin/cms/sites_controller.rb on lines 35..42
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 34..41
app/controllers/comfy/admin/cms/translations_controller.rb on lines 30..37

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

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 ComfortableMexicanSofa::Content::Tag::Text < ComfortableMexicanSofa::Content::Tag::Fragment

  def form_field(object_name, view, index)
    name    = "#{object_name}[fragments_attributes][#{index}][content]"
    options = { id: form_field_id, class: "form-control" }
Severity: Minor
Found in lib/comfortable_mexican_sofa/content/tags/text.rb and 1 other location - About 35 mins to fix
lib/comfortable_mexican_sofa/content/tags/number.rb on lines 6..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 34.

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 ComfortableMexicanSofa::Content::Tag::Number < ComfortableMexicanSofa::Content::Tag::Fragment

  def form_field(object_name, view, index)
    name    = "#{object_name}[fragments_attributes][#{index}][content]"
    options = { id: form_field_id, class: "form-control" }
Severity: Minor
Found in lib/comfortable_mexican_sofa/content/tags/number.rb and 1 other location - About 35 mins to fix
lib/comfortable_mexican_sofa/content/tags/text.rb on lines 6..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 34.

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 update
    @translation.update!(translation_params)
    flash[:success] = I18n.t("comfy.admin.cms.translations.updated")
    redirect_to action: :edit, id: @translation
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/translations_controller.rb and 3 other locations - About 35 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 34..41
app/controllers/comfy/admin/cms/sites_controller.rb on lines 35..42
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 34..41

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

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 update
    @site.update!(site_params)
    flash[:success] = I18n.t("comfy.admin.cms.sites.updated")
    redirect_to action: :edit, id: @site
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/sites_controller.rb and 3 other locations - About 35 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 34..41
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 34..41
app/controllers/comfy/admin/cms/translations_controller.rb on lines 30..37

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

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 update
    @snippet.update!(snippet_params)
    flash[:success] = I18n.t("comfy.admin.cms.snippets.updated")
    redirect_to action: :edit, id: @snippet
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/snippets_controller.rb and 3 other locations - About 35 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 34..41
app/controllers/comfy/admin/cms/sites_controller.rb on lines 35..42
app/controllers/comfy/admin/cms/translations_controller.rb on lines 30..37

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

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

  def update
    @page.save!
    flash[:success] = I18n.t("comfy.admin.cms.pages.updated")
    redirect_to action: :edit, id: @page
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/pages_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/pages_controller.rb on lines 39..46
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/translations_controller.rb on lines 21..28

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

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

  def create
    @page.save!
    flash[:success] = I18n.t("comfy.admin.cms.pages.created")
    redirect_to action: :edit, id: @page
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/pages_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/pages_controller.rb on lines 48..55
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/translations_controller.rb on lines 21..28

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

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

  def create
    @layout.save!
    flash[:success] = I18n.t("comfy.admin.cms.layouts.created")
    redirect_to action: :edit, id: @layout
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/layouts_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/comfy/admin/cms/pages_controller.rb on lines 39..46
app/controllers/comfy/admin/cms/pages_controller.rb on lines 48..55
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/translations_controller.rb on lines 21..28

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

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

  def create
    @snippet.save!
    flash[:success] = I18n.t("comfy.admin.cms.snippets.created")
    redirect_to action: :edit, id: @snippet
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/snippets_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/pages_controller.rb on lines 39..46
app/controllers/comfy/admin/cms/pages_controller.rb on lines 48..55
app/controllers/comfy/admin/cms/translations_controller.rb on lines 21..28

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

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

  def create
    @translation.save!
    flash[:success] = I18n.t("comfy.admin.cms.translations.created")
    redirect_to action: :edit, id: @translation
  rescue ActiveRecord::RecordInvalid
Severity: Major
Found in app/controllers/comfy/admin/cms/translations_controller.rb and 4 other locations - About 30 mins to fix
app/controllers/comfy/admin/cms/layouts_controller.rb on lines 25..32
app/controllers/comfy/admin/cms/pages_controller.rb on lines 39..46
app/controllers/comfy/admin/cms/pages_controller.rb on lines 48..55
app/controllers/comfy/admin/cms/snippets_controller.rb on lines 25..32

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

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

  def test_implicit_cms_page
    page = comfy_cms_pages(:child)
    page.update(slug: "render-basic")
    get "/render-basic?type=page_implicit"
    assert_response :success
Severity: Minor
Found in test/integration/render_cms_test.rb and 2 other locations - About 25 mins to fix
test/integration/render_cms_test.rb on lines 140..149
test/integration/render_cms_test.rb on lines 152..161

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

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

  def test_explicit_cms_page
    page = comfy_cms_pages(:child)
    page.update(slug: "test-page")
    get "/render-page?type=page_explicit"
    assert_response :success
Severity: Minor
Found in test/integration/render_cms_test.rb and 2 other locations - About 25 mins to fix
test/integration/render_cms_test.rb on lines 120..129
test/integration/render_cms_test.rb on lines 152..161

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

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

  def test_explicit_cms_page_with_status
    page = comfy_cms_pages(:child)
    page.update(slug: "test-page")
    get "/render-page?type=page_explicit_with_status"
    assert_response :not_found
Severity: Minor
Found in test/integration/render_cms_test.rb and 2 other locations - About 25 mins to fix
test/integration/render_cms_test.rb on lines 120..129
test/integration/render_cms_test.rb on lines 140..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 31.

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

  def assign_parent
    return unless site
    self.parent ||= site.pages.root unless self == site.pages.root || site.pages.count.zero?
  end
Severity: Minor
Found in app/models/comfy/cms/page.rb - About 25 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

Method fragments_attributes= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def fragments_attributes=(frag_hashes = [])
    frag_hashes = frag_hashes.values if frag_hashes.is_a?(Hash)

    frag_hashes.each do |frag_attrs|
      unless frag_attrs.is_a?(HashWithIndifferentAccess)
Severity: Minor
Found in app/models/concerns/comfy/cms/with_fragments.rb - About 25 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

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

      r :post, comfy_admin_cms_site_pages_path(site_id: @site), params: {
        preview: "Preview",
        page: {
          label:     "Test Page",
          slug:      "test-page",
Severity: Minor
Found in test/controllers/comfy/admin/cms/pages_controller_test.rb and 1 other location - About 25 mins to fix
test/controllers/comfy/admin/cms/pages_controller_test.rb on lines 429..443

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

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

    %w[/path-c/child /path-c/child/child].each do |path|
      get path
      assert assigns(:cms_site), path
      assert_equal site_c, assigns(:cms_site)
      assert_equal path.gsub(%r{^/path-c/child}, "").gsub(%r{^/}, ""), @controller.params[:cms_path].to_s
Severity: Minor
Found in test/integration/sites_test.rb and 1 other location - About 25 mins to fix
test/integration/sites_test.rb on lines 50..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 30.

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