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)
- Read upRead up
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
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)
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]
- Read upRead up
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
- Read upRead up
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]
- Read upRead up
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)
Method render
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def render(engine, data=nil, options={}, locals={}, &block)
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
- Read upRead up
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
- Read upRead up
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}}"
- Read upRead up
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
- Read upRead up
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"