Showing 27 of 1,937 total issues
Class Configuration
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
class Configuration
attr_reader :observer, :actions, :timer, :oauth_providers
def initialize
@root = Rails.root
File configuration.rb
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
root = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
require File.join(root, "lib/hash_dsl")
require File.join(root, "lib/core_ext/hash")
require File.join(root, "lib/core_ext/kernel")
require File.join(root, "lib/core_ext/exception")
Method pack
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def pack(object)
case object
when Array
object.map { |item| pack(item) }
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 daemonize
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.daemonize(name)
unless Houston.running_as_web_server? or ENV["HOUSTON_DAEMONS"].to_s.split(",").member?(name)
puts "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m" if Rails.env.development?
Rails.logger.info "\e[94m[daemon:#{name}] Skipping daemon since we're not running as a server\e[0m"
return
- 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 score
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def score(label, value, options={})
score_count_class = Array(options.delete(:score_count_class)) << "score-count"
precision = options.delete(:precision)
css = Array(options.fetch(:class, []))
- 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 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)
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 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 _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 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
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
Avoid too many return
statements within this method. Open
return ">1 year ago" if days < 730