locomotivecms/mounter

View on GitHub
lib/locomotive/mounter/writer/api/pages_writer.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method _write has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

          def _write(page, done, already_done = false, with_children = true)
            if self.safely_translated?(page)
              write_page(page) unless already_done
            else
              self.output_resource_op page
Severity: Minor
Found in lib/locomotive/mounter/writer/api/pages_writer.rb - About 2 hrs 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 page_to_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

          def page_to_params(page, safe = false)
            (safe ? page.to_safe_params : page.to_params).tap do |params|
              # raw template
              params[:raw_template] = self.replace_content_assets!(params[:raw_template])

Severity: Minor
Found in lib/locomotive/mounter/writer/api/pages_writer.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 _write_layouts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def _write_layouts(pages, done)
            if pages['layouts']
              _write(pages['layouts'], done, false, false)

              layouts = pages.values.find_all { |page| page.fullpath =~ /^layouts\// }
Severity: Minor
Found in lib/locomotive/mounter/writer/api/pages_writer.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

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

          def write_page(page)
            locale = Locomotive::Mounter.locale

            return unless page.translated_in?(locale)

Severity: Minor
Found in lib/locomotive/mounter/writer/api/pages_writer.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

There are no issues that match your filters.

Category
Status