Showing 48 of 144 total issues
Complex method ActiveAdminAbility#initialize (77.9) Open
def initialize(user)
if user.present? && user.admin?
can :manage, :all
elsif user.present?
# Achtung! Keine Blocks benutzen, sondern immer die
- 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 CallbacksController#all (55.4) 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
- 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#<=> (51.7) Open
def <=>(other)
if (self.occurrence.year != other.occurrence.year) || (self.occurrence.month != other.occurrence.month) || (self.occurrence.day != other.occurrence.day)
# not on same day
return self.occurrence <=> other.occurrence
elsif self.full_day
- 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 main#create (49.4) Open
def create
create! do |success, failure|
success.html do
redirect_to admin_event_path(params[:event_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
Method reset_pk_sequence!
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. 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
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 main#reconstruct_start_time (44.0) Open
def reconstruct_start_time
params[:event]["start_time"] = Time.zone.local(
params[:event].delete("start_time(1i)").to_i,
params[:event].delete("start_time(2i)").to_i,
params[:event].delete("start_time(3i)").to_i,
- 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
Class Event
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ActiveRecord::Base
include TwitterHashTagFixer
validates_presence_of :name
validates_presence_of :category
Complex method SingleEvent::search (43.6) Open
def self.search(search)
search.strip!
# Name + Description in Single Event
sevents = today_or_in_future.name_or_description_like("%#{search}%")
- 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
Class User
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable
Complex method TwitterFollower#event_twitter_handles (39.0) Open
def event_twitter_handles
(
Event.select(:twitter).uniq.map(&:twitter) +
SingleEvent.select("single_events.twitter").uniq.map(&:twitter)
).compact.uniq.map(&:downcase).delete_if(&:blank?) - ["hacken_in"]
- 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 main#update (38.6) Open
def update
params[:event][:schedule_rules] = JSON.parse(params[:event][:schedule_rules]) if params[:event][:schedule_rules]
params[:event][:excluded_times] = JSON.parse(params[:event][:excluded_times]) if params[:event][:excluded_times]
reconstruct_start_time
update! do |success|
- 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#schedule_rules (37.5) Open
def schedule_rules
schedule.recurrence_rules.map do |rule|
hash = {}
if rule.class == IceCube::MonthlyRule
hash["type"] = 'monthly'
- 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 update_with_password_pass
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def update_with_password_pass(params={})
if params[:password].blank? and params[:email] == self.email
params.delete(:current_password)
params.delete(:password)
- 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::Ical#parse_event (34.7) Open
def parse_event(event)
result = {
id: event.start.to_s,
url: event.url.to_s,
title: (event.summary || "").force_encoding("utf-8"),
- 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#is_for_user? (31.6) 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
- 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 <=>
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
if (self.occurrence.year != other.occurrence.year) || (self.occurrence.month != other.occurrence.month) || (self.occurrence.day != other.occurrence.day)
# not on same day
return self.occurrence <=> other.occurrence
elsif self.full_day
- 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 User#update_with_password_pass (30.8) Open
def update_with_password_pass(params={})
if params[:password].blank? and params[:email] == self.email
params.delete(:current_password)
params.delete(:password)
- 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 initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
if user.present? && user.admin?
can :manage, :all
elsif user.present?
# Achtung! Keine Blocks benutzen, sondern immer die
- 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 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
if user.present? && user.admin?
can :manage, :all
elsif user.present?
# Achtung! Keine Blocks benutzen, sondern immer die
Complex method main#permitted_params (28.6) Open
def permitted_params
params.permit(venue: [
:location,
:street,
:zipcode,
- 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