Showing 1,937 of 1,937 total issues
Cyclomatic complexity for pack is too high. [11/6] Open
def pack(object)
case object
when Array
object.map { |item| pack(item) }
when Hash
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Assignment Branch Condition size for assert_registered_params! is too high. [20.32/15] Open
def assert_registered_params!(event_name, params)
event = Houston.events[event_name]
missing_params = event.params - params.keys.map(&:to_s)
unregistered_params = params.keys.map(&:to_s) - event.params
- 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
Method has too many lines. [15/10] Open
def fire(event, params={})
assert_registered! event
unless params.is_a?(Hash)
raise ArgumentError, "params must be a Hash" unless params.respond_to?(:to_h)
- 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.
Assignment Branch Condition size for trigger is too high. [19.13/15] Open
def trigger
event = "hooks:#{params[:hook]}"
unless Houston.observer.observed?(event)
render plain: "A hook with the slug '#{params[:hook]}' is not defined", status: 404
return
- 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 update is too high. [19.75/15] Open
def update
@user = User.find(params[:id])
@user.role = @role
attributes = user_params
- 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 update is too high. [19.21/15] Open
def update
@project = Project.find_by_slug!(params[:id])
@project.props.merge! project_attributes.delete(:props) if project_attributes.key?(:props)
- 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
Cyclomatic complexity for _format_time_ago is too high. [9/6] 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
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method has too many lines. [13/10] 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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [13/10] Open
def trigger
event = "hooks:#{params[:hook]}"
unless Houston.observer.observed?(event)
render plain: "A hook with the slug '#{params[:hook]}' is not defined", status: 404
return
- 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.
Assignment Branch Condition size for index is too high. [18/15] Open
def index
name = params.fetch :name
start_time = params.fetch :start
end_time = params.fetch :end
measurements = Measurement.named(name).taken_between(start_time, end_time)
- 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
Method has too many lines. [13/10] Open
def pick(*picks)
picks = picks.flatten
mapped_picks = {}
picks.each do |pick|
- 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 has too many lines. [13/10] Open
def percentile(p)
sorted_array = self.sort
rank = (p.to_f / 100) * (self.length + 1)
return nil if self.length == 0
- 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.
Cyclomatic complexity for daemonize is too high. [9/6] 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
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
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
Block has too many lines. [44/25] Open
Gem::Specification.new do |spec|
spec.name = "houston-core"
spec.version = Houston::VERSION
spec.authors = ["Bob Lail"]
spec.email = ["bob.lailfamily@gmail.com"]
- 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 has too many lines. [12/10] Open
def take!(attributes)
required_keys = [:subject_type, :subject_id, :taken_at, :name].freeze
identifying_attributes = attributes.pick(required_keys)
subject = attributes[:subject]
- 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 has too many lines. [12/10] Open
def self.find_or_create_for_exception(exception)
message = exception.message
backtrace = exception.backtrace.join("\n")
sha = Digest::SHA1.hexdigest([message, backtrace].join)
error = create_with(
- 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.
Assignment Branch Condition size for generate is too high. [17.49/15] Open
def generate
css = ["score"].concat Array(@options.fetch(:class, []))
css << "score-giant" if @size == :giant
css << "score-large" if @size == :large
css << "score-medium" if @size == :medium
- 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 subscribed is too high. [17.38/15] Open
def subscribed
events = [params[:event]] if params.key?(:event)
events = params[:events] if params.key?(:events)
events.each do |event|
- 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 show is too high. [17.38/15] Open
def show
authorize! :read, Action
@action_name = params[:slug]
@actions = Action.where(name: @action_name).preload(:error).limit(50)
@actions = @actions.where(Action.arel_table[:created_at].lt(params[:before])) if params[:before]
- 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