Showing 158 of 214 total issues
Method create_migration
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_migration
validate_namespace name
self.destination_root = options[:root]
if in_app_root?
self.behavior = :revoke if options[:destroy]
- 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 singularize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def singularize(s)
s = s.to_s
return s.singularize if s.respond_to?(:singularize)
result = s.dup
Inflections.singulars.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
- 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 allowed?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def allowed?(account=nil, path=nil)
path = "/" if path.nil? || path.empty?
role = account.role.to_sym rescue nil
authorizations = @authorizations.find_all { |auth| auth.roles.include?(:any) }
allowed_paths = authorizations.map(&:allowed).flatten.uniq
- 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 pluralize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def pluralize(s)
s = s.to_s
return s.pluralize if s.respond_to?(:pluralize)
result = s.dup
Inflections.plurals.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
- 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 error_html_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def error_html_attributes(options)
[:id, :class, :style].each_with_object({}) do |key,all|
if options.include?(key)
value = options[key]
all[key] = value if value
- 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 rebase_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rebase_url(url)
if url.start_with?('/')
new_url = ''
new_url << conform_uri(ENV['RACK_BASE_URI']) if ENV['RACK_BASE_URI']
new_url << conform_uri(uri_root) if defined?(uri_root)
- 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 load_boot
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def load_boot
begin
ENV['PADRINO_LOG_LEVEL'] ||= 'test'
ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root]
boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
- 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 button_to
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def button_to(*args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
name, url = *args
options['data-remote'] = 'true' if options.delete(:remote)
submit_options = options.delete(:submit_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 create_mailer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_mailer
validate_namespace name
self.destination_root = options[:root]
if in_app_root?
app = options[:app]
- 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 provides_format?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def provides_format?(types, format)
if ([:any, format] & types).empty?
# Per rfc2616-sec14:
# Answer with 406 if accept is given but types to not match any provided type.
halt 406 if settings.respond_to?(:treat_format_as_accept) && settings.treat_format_as_accept
- 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 drop_database
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def drop_database(config)
case config[:adapter]
when 'mysql', 'mysql2', 'em_mysql2', 'jdbcmysql'
ActiveRecord::Base.establish_connection(config)
ActiveRecord::Base.connection.drop_database config[:database]
- 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_csrf_protection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_csrf_protection(builder)
check_csrf_protection_dependency
if protect_from_csrf?
options = options_for_csrf_protection_setup
- 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 expand
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def expand(params)
params = @default_values.merge(params) if @default_values.is_a?(Hash)
params, query = params.each_with_object([{}, {}]) do |(key, val), parts|
parts[handler.names.include?(key.to_s) ? 0 : 1][key] = val
end
- 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 list_app_routes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def list_app_routes(app, args)
app_routes = app.named_routes
app_routes.reject! { |r| r.identifier.to_s !~ /#{args.query}/ } if args.query && !args.query.empty?
app_routes.map! { |r| [r.verb, r.name, r.path] }
return if app_routes.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 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 create_task
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_task
validate_namespace name
self.destination_root = options[:root]
if in_app_root?
app = options[:app]
- 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 registered
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def registered(app)
app.register Padrino::Admin unless app.extensions.include?(Padrino::Admin)
app.set :session_id, "_padrino_#{Padrino.env}_#{app.app_name}" unless app.respond_to?(:session_id)
app.set :admin_model, 'Account' unless app.respond_to?(:admin_model)
app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
- 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 deep_dup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def deep_dup(object)
case object
when Array
object.map{ |value| deep_dup(value) }
when Hash
- 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_default_middleware
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_default_middleware(builder)
setup_sessions builder
builder.use Sinatra::ExtendedRack if defined?(EventMachine)
builder.use Padrino::ShowExceptions if show_exceptions?
builder.use Padrino::Logger::Rack, uri_root if Padrino.logger && logging?
- 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 prepare
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def prepare(task)
if options.help?
help(task.to_s)
exit
end
- 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"