sitepress/sitepress

View on GitHub

Showing 5 of 23 total issues

Method compile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def compile
        before_compile
        each do |resource, *args, **kwargs|
          if resource.renderable?
            render_resource(resource, *args, **kwargs)
Severity: Minor
Found in sitepress-rails/lib/sitepress/compiler.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 resolve_layout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def resolve_layout
          return resource.data.fetch("layout") if resource.data.key? "layout"
          return layout unless has_layout_conditions?

          clause, formats = layout_conditions.first
Severity: Minor
Found in sitepress-rails/lib/sitepress/renderers/controller.rb - About 45 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 request_filename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def request_filename
      if node.root? and node.default_format == format
        ""
      elsif node.root? and format
        "#{node.default_name}.#{format}"
Severity: Minor
Found in sitepress-core/lib/sitepress/resource.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 parse_basename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_basename
        base = basename
        filename, extname = split_filename(base)

        # This is a root path, so we have to treat it a little differently
Severity: Minor
Found in sitepress-core/lib/sitepress/path.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 controller_layout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def controller_layout(resource)
      private_layout_method = self.method(:_layout)
      layout =
        if Rails.version >= "6"
          private_layout_method.call lookup_context, resource_rails_formats(resource)
Severity: Minor
Found in sitepress-rails/rails/app/controllers/concerns/sitepress/site_pages.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

Severity
Category
Status
Source
Language