Showing 158 of 214 total issues
Method partial
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def partial(template, options={}, &block)
options = { :layout => false }.update(options)
explicit_engine = options.delete(:engine)
path, _, name = template.to_s.rpartition(File::SEPARATOR)
- 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 convert_ids
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def convert_ids(obj)
if obj.is_a?(String) && obj =~ /^[a-f0-9]{24}$/
defined?(Moped) ? Moped::BSON::ObjectId.from_string(obj) : BSON::ObjectId(obj)
elsif obj.is_a?(Array)
obj.map do |v|
- 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
Consider simplifying this complex logical expression. Open
if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
namespace :dm do
namespace :auto do
desc "Perform auto migration (reset your db data)"
task :migrate => :environment do
Method distance_of_time_in_words
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
distance_in_minutes = (((to_time.to_i - from_time.to_i).abs)/60).round
distance_in_seconds = ((to_time.to_i - from_time.to_i).abs).round
Method setup_test_files
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def setup_test_files
if options[:tiny] && @_components[:test] != :none
test_component = @_components[:test]
test_component = "rspec" if test_component == "cucumber"
uppercase_test_component = test_component.upcase
- 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
Function applyPlacement
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Tooltip.prototype.applyPlacement = function (offset, placement) {
var replace
var $tip = this.tip()
var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight
Method setup_orm
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_orm
dm = DM
db = @project_name.underscore
%w(
dm-core
Method setup_components
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_components
self.destination_root = options[:root]
if in_app_root?
@_components = options.class.new options.select{ |key,_| self.class.component_types.include?(key.to_sym) }
@app_name = (options[:app] || "App").gsub(/\W/, '_').camelize
Method setup_orm
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_orm
ar = MR
db = @project_name.underscore
begin
Method params_for
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def params_for(pattern, others)
data = match(pattern)
params = indifferent_hash
if data.names.empty?
params.merge!(:captures => data.captures) unless data.captures.empty?
- 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 named_routes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def named_routes
return [] unless app_obj.respond_to?(:routes)
app_obj.routes.map { |route|
request_method = route.request_methods.first
- 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 object_sources
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def object_sources(target)
sources = Set.new
target.methods.each do |method_name|
next unless method_name.kind_of?(Symbol)
method_object = target.method(method_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 tag_attributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def tag_attributes(options)
return '' unless options
options.inject('') do |all,(key,value)|
next all unless value
all << ' ' if all.empty?
- 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 setup_orm
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_orm
sequel = SEQUEL
db = @project_name.underscore
require_dependencies 'sequel'
Method create_app
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_app
self.destination_root = options[:root]
underscore_name = name.gsub(/\W/, '_')
@app_folder = underscore_name.underscore
@app_name = underscore_name.camelize
Method setup_orm
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_orm
ar = AR
db = @project_name.underscore
begin
Method setup_project
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_project
valid_constant? name
app = (options[:app] || "App")
@project_name = name.gsub(/\W/, '_').underscore.camelize
Method number_to_human_size
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def number_to_human_size(number, *args)
return nil if number.nil?
options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}
Method cache_object
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def cache_object(key, opts = {})
if settings.caching?
began_at = Time.now
if settings.cache.key?(key.to_s)
value = settings.cache[key.to_s]
- 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 initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(options={})
@buffer = []
@auto_flush = options.has_key?(:auto_flush) ? options[:auto_flush] : true
@level = options[:log_level] ? Padrino::Logger::Levels[options[:log_level]] : Padrino::Logger::Levels[:debug]
@log = options[:stream] || $stdout
- 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"