Showing 48 of 144 total issues
Complex method ParticipatesController#update (27.5) Open
def update
@single_event = SingleEvent.find params[:single_event_id]
if push_or_delete(params[:state].to_s)
flash[:notice] = t "single_events.#{params[:state]}.confirmation"
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements#reset_pk_sequence! (27.0) Open
def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc:
unless pk and sequence
default_pk, default_sequence = pk_and_sequence_for(table)
pk ||= default_pk
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method SingleEvent#to_opengraph (26.7) Open
def to_opengraph
ogdata = event.to_opengraph.merge({
"og:title" => name_with_date,
"og:description" => short_description
})
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method LayoutHelper#display_error_messages! (26.4) Open
def display_error_messages!
return "" if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t("errors.messages.not_saved",
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method User::from_omniauth (25.8) Open
def self.from_omniauth(auth)
auth_token = Authorization.where(provider: auth.provider, uid: auth.uid).first
# If we have a token without an associated user (user canceled signup), we delete it and the user has to sign up
if (auth_token && auth_token.user.nil?)
auth_token.destroy
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method namespace(setup)::task#admin (25.3) Open
task admin: :environment do
nick = ENV["user"] || begin
puts "Username:"
STDIN.gets.strip
end
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Radar::Rss#next_events (25.1) Open
def next_events
feed = Feedjira::Feed.parse open(@radar_setting.url, &:read)
entries = feed.entries.sort_by(&:published)
if @radar_setting.last_processed.nil?
entries = entries[1..4]
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method is_for_user?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def is_for_user?(user)
return true unless user
# Let us be a little more verbose than the old code
# !((self.event.tag_list & user.hate_list).length > 0 && self.users.exclude?(user))
hated_tags_event = (self.event.tag_list & user.hate_list)
- 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 all
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def all
# If there is no token, but we are currently logged in
if current_user
@auth = Authorization.create_authorization(request.env["omniauth.auth"], current_user)
- 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
Complex method Radar::Twitter#tweets (24.8) Open
def tweets(client, page_id = nil)
messages = if page_id.nil?
client.user_timeline(twitter_handle, exclude_replies: true)
else
client.user_timeline(twitter_handle, exclude_replies: true, max_id: page_id)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method column#content (23.2) Open
column :content do |entry|
if entry.content
(
"<p><strong>#{entry.content[:title]}</strong></p>" +
"#{sanitize entry.content[:description]}" +
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ApplicationHelper#collect_links (23.1) Open
def collect_links(item)
links = []
if item.url.present?
links << { url: item.url,
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method fix_twitter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fix_twitter
if twitter
if twitter[0] == '@'
self.twitter = twitter[1..-1]
elsif m = twitter.match(/http(?:s)?:\/\/twitter.com\/(.*)/)
- 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
Complex method SingleEvent#update_event (22.7) Open
def update_event
if based_on_rule
event.schedule.add_exception_time occurrence
if event.schedule.rtimes.include? occurrence
event.schedule.remove_recurrence_time occurrence
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ApplicationHelper#avatar_for_user (22.5) Open
def avatar_for_user(user, size = 16, class_name = nil)
if user.gravatar_email.present?
gravatar_image_tag(user.gravatar_email, title: user.nickname, alt: user.nickname, class: class_name, gravatar: { default: :identicon, size: size })
elsif user.email.present?
gravatar_image_tag(user.email, title: user.nickname, alt: user.nickname, class: class_name, gravatar: { default: :identicon, size: size })
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Event#future_single_event_creation (22.2) Open
def future_single_event_creation
self.schedule.next_occurrences(12).each do |occurrence|
if !self.schedule.extimes.map(&:to_i).include? occurrence.to_i
SingleEvent.where(event_id: self.id,
occurrence: occurrence.utc,
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method namespace(deploy)::task#setup (22.2) Open
task :setup do
on roles(:app) do
info "Creating hacken.in environment symlinks"
execute "ln -sf #{current_path}/infrastructure/uberspace/#{fetch(:stage)}/hacken-in-#{fetch(:stage)} ~/bin/"
execute "cd #{release_path}; source ~/hacken-in-#{fetch(:stage)}.secrets; bundle exec rake uberspace:print_htaccess > /var/www/virtual/hacken/#{fetch(:vhost)}/.htaccess"
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Avoid too many return
statements within this method. Open
return self.full_name.downcase <=> other.full_name.downcase
Avoid too many return
statements within this method. Open
return time_comparison
Complex method Radar::Base#fetch (21.7) Open
def fetch(start_time = Time.now)
event_ids = []
begin
next_events.each do |event|
next if event[:time] && event[:time] < start_time
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool