Showing 1,937 of 1,937 total issues
Method has too many lines. [11/10] Open
def call(*args)
Houston.async(invoke_async?) do
begin
block.call(*args)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method mail
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def mail(options={})
options[:from] = format_email_addresses(options[:from]) if options.key?(:from)
options[:to] = format_email_addresses(options[:to]).uniq if options.key?(:to)
options[:cc] = format_email_addresses(options[:cc]).uniq if options.key?(:cc)
options[:bcc] = format_email_addresses(options[:bcc]).uniq if options.key?(:bcc)
- 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 define_methods!
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def define_methods!
concern = ProjectAdapter.const_set(concern_name, Module.new)
concern.extend ActiveSupport::Concern
class_methods = concern.const_set(:ClassMethods, Module.new)
Assignment Branch Condition size for format_duration is too high. [15.81/15] Open
def format_duration(seconds)
if seconds.nil?
return "—".html_safe
elsif seconds < 1
"#{(seconds * 1000).floor}ms"
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for create is too high. [15.43/15] Open
def create
@user = User.new(user_params)
if params[:send_invitation]
User.invite!(params[:user])
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Block has too many lines. [37/25] Open
Houston.config do
# Required
# ---------------------------------------------------------------------------
#
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method try
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.try(options, *rescue_from)
options = { max_tries: options } if options.is_a?(Fixnum)
options = {} unless options.is_a?(Hash)
max_tries = options.fetch :max_tries, 3
base = options.fetch :base, 2
- 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 pack
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pack(object)
case object
when Array
object.map { |item| pack(item) }
when Hash
Method run!
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run!
exception = nil
Houston.reconnect do
touch :started_at
Method root
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def root(*args)
if args.any?
@root = args.first
# Keep structure.sql in instances' db directory
- 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 debug
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def debug(colored: true)
format_subject = ->(s) { s.is_a?(User) ? s.first_name : s.is_a?(Project) ? s.slug : "" }
includes(:subject).reorder("taken_at ASC, subject_type ASC, subject_id ASC, name ASC").map { |m|
line = [ m.taken_on.strftime("%-m/%-d").rjust(5),
m.taken_at.strftime("%H:%M:%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 policies
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def policies
ext = File.extname(params[:name])
unique_file_name = params.values_at(:name, :size, :type).join(".")
filename = Digest::SHA1.hexdigest(unique_file_name) + ext
object_name = "uploads/#{current_user.id}/#{filename}"
Method add_to_project_features
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_to_project_features(slug)
raise ArgumentError, "Project Feature must supply name, but #{slug.inspect} doesn't" unless @name
raise ArgumentError, "Project Feature must supply path lambda, but #{slug.inspect} doesn't" unless @path_block
Houston.project_features.add(slug, &@path_block).tap do |feature|
- 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 _format_time_ago
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _format_time_ago(time)
duration = (Time.now - time).to_i
return "#{duration} seconds ago" if duration < 90.seconds
return "#{duration / 60} minutes ago" if duration < 90.minutes
return "%.1f hours ago" % (duration / 3600.0) if duration < 20.hours
- 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 has_adapter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def has_adapter(*adapter_namespaces)
adapter_namespaces.each do |adapter_namespace|
adapter_module = Houston::Adapters[adapter_namespace]
raise ArgumentError, "#{adapter_module} should respond to `adapters`" unless adapter_module.respond_to?(:adapters)
raise ArgumentError, "#{adapter_module} should respond to `adapter`" unless adapter_module.respond_to?(:adapter)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
if user
# Owners can do everything
- 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 unpack
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def unpack(object)
if object.is_a?(Array)
object.map { |item| unpack(item) }
elsif object.is_a?(Hash)
object = object.each_with_object({}) { |(key, value), new_object| new_object[key] = unpack(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 format_time
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_time(time, options={})
if time.nil?
date, time = ["", "Never"]
elsif time.to_date == Date.today
date, time = [options[:today] ? "Today" : "", time.strftime("%l:%M %p")]
- 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
Avoid too many return
statements within this method. Open
return ">1 year ago" if days < 730
Avoid too many return
statements within this method. Open
return "#{days / 7} weeks ago" if days < 63