padrino/padrino-framework

View on GitHub
padrino-helpers/lib/padrino/rendering.rb

Summary

Maintainability
C
1 day
Test Coverage

Method render_like_sinatra has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def render_like_sinatra(engine, data, options={}, locals={}, &block)
        # merge app-level options
        engine_options = settings.respond_to?(engine) ? settings.send(engine) : {}
        options = engine_options.merge(options)

Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.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

File rendering.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'padrino/core_ext/output_safety'
require 'padrino-support'
require 'pathname'

module Padrino
Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.rb - About 2 hrs to fix

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

          def render_like_sinatra(engine, data, options={}, locals={}, &block)
            # merge app-level options
            engine_options = settings.respond_to?(engine) ? settings.send(engine) : {}
            options = engine_options.merge(options)
    
    
    Severity: Minor
    Found in padrino-helpers/lib/padrino/rendering.rb - About 1 hr to fix

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

            def resolve_template(template_path, options={})
              template_path = template_path.to_s
              controller_key = respond_to?(:request) && request.respond_to?(:controller) && request.controller
              rendering_options = [template_path, content_type || :html, locale]
      
      
      Severity: Minor
      Found in padrino-helpers/lib/padrino/rendering.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 with_layout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def with_layout(options)
              options = options.dup
              layout = options[:layout]
              return options if layout == false
      
      
      Severity: Minor
      Found in padrino-helpers/lib/padrino/rendering.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 cache_template_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def cache_template_path(options)
              began_at = Time.now
              @_cached_templates ||= {}
              logging = defined?(settings) && settings.logging? && defined?(logger)
              if !reload_templates? && path = @_cached_templates[options]
      Severity: Minor
      Found in padrino-helpers/lib/padrino/rendering.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 render_like_sinatra has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def render_like_sinatra(engine, data, options={}, locals={}, &block)
      Severity: Minor
      Found in padrino-helpers/lib/padrino/rendering.rb - About 35 mins to fix

        Method render has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def render(engine, data=nil, options={}, locals={}, &block)
        Severity: Minor
        Found in padrino-helpers/lib/padrino/rendering.rb - About 35 mins to fix

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

                def render(engine, data=nil, options={}, locals={}, &block)
                  # If engine is nil, ignore engine parameter and shift up all arguments
                  # render nil, "index", { :layout => true }, { :localvar => "foo" }
                  engine, data, options = data, options, locals if engine.nil? && data
          
          
          Severity: Minor
          Found in padrino-helpers/lib/padrino/rendering.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 fetch_layout_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def fetch_layout_path(given_layout, layouts_path=views)
                  layout_name = (given_layout || @layout || :application).to_s
                  cache_layout_path(layout_name) do
                    if Pathname.new(layout_name).absolute? && Dir["#{layout_name}.*"].any? || Dir["#{layouts_path}/#{layout_name}.*"].any?
                      layout_name
          Severity: Minor
          Found in padrino-helpers/lib/padrino/rendering.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 glob_templates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def glob_templates(views_path, template_path)
                  parts = []
                  parts << views_path if views_path
                  if respond_to?(:request) && request.respond_to?(:controller) && request.controller && Pathname.new(template_path).relative?
                    parts << "{,#{request.controller}}"
          Severity: Minor
          Found in padrino-helpers/lib/padrino/rendering.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 ensure_rendering_engine has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def ensure_rendering_engine(engine)
                  return true if settings.respond_to?(engine)
                  return nil unless engine == :erb
                  require 'erb'
                rescue LoadError
          Severity: Minor
          Found in padrino-helpers/lib/padrino/rendering.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

          There are no issues that match your filters.

          Category
          Status