Skip to content

Commit

Permalink
Rubocop: if/unless modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 10, 2017
1 parent 1bb7a77 commit db3dfdc
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 46 deletions.
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Expand Up @@ -424,19 +424,6 @@ Style/IdenticalConditionalBranches:
Exclude:
- 'app/helpers/application_helper.rb'

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'app/models/entities/lead.rb'
- 'app/models/entities/opportunity.rb'
- 'app/models/setting.rb'
- 'db/migrate/20100928030620_remove_uuid.rb'
- 'lib/fat_free_crm.rb'
- 'lib/fat_free_crm/mail_processor/base.rb'
- 'lib/tasks/ffcrm/update_data.rake'

# Offense count: 27
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
12 changes: 3 additions & 9 deletions app/models/entities/lead.rb
Expand Up @@ -151,9 +151,7 @@ def reject
# Attach a task to the lead if it hasn't been attached already.
#----------------------------------------------------------------------------
def attach!(task)
unless task_ids.include?(task.id)
tasks << task
end
tasks << task unless task_ids.include?(task.id)
end

# Discard a task from the lead.
Expand All @@ -176,16 +174,12 @@ def full_name(format = nil)

#----------------------------------------------------------------------------
def increment_leads_count
if campaign_id
Campaign.increment_counter(:leads_count, campaign_id)
end
Campaign.increment_counter(:leads_count, campaign_id) if campaign_id
end

#----------------------------------------------------------------------------
def decrement_leads_count
if campaign_id
Campaign.decrement_counter(:leads_count, campaign_id)
end
Campaign.decrement_counter(:leads_count, campaign_id) if campaign_id
end

# Make sure at least one user has been selected if the lead is being shared.
Expand Down
8 changes: 2 additions & 6 deletions app/models/entities/opportunity.rb
Expand Up @@ -175,16 +175,12 @@ def users_for_shared_access

#----------------------------------------------------------------------------
def increment_opportunities_count
if campaign_id
Campaign.increment_counter(:opportunities_count, campaign_id)
end
Campaign.increment_counter(:opportunities_count, campaign_id) if campaign_id
end

#----------------------------------------------------------------------------
def decrement_opportunities_count
if campaign_id
Campaign.decrement_counter(:opportunities_count, campaign_id)
end
Campaign.decrement_counter(:opportunities_count, campaign_id) if campaign_id
end

ActiveSupport.run_load_hooks(:fat_free_crm_opportunity, self)
Expand Down
8 changes: 2 additions & 6 deletions app/models/setting.rb
Expand Up @@ -56,15 +56,11 @@ def [](name)
# Check database
if database_and_table_exists?
if setting = find_by_name(name.to_s)
unless setting.value.nil?
return cache[name] = setting.value
end
return cache[name] = setting.value unless setting.value.nil?
end
end
# Check YAML settings
if yaml_settings.key?(name)
return cache[name] = yaml_settings[name]
end
return cache[name] = yaml_settings[name] if yaml_settings.key?(name)
end

# Set setting value
Expand Down
4 changes: 1 addition & 3 deletions db/migrate/20100928030620_remove_uuid.rb
Expand Up @@ -4,9 +4,7 @@ class RemoveUuid < ActiveRecord::Migration
def self.up
[:users, :accounts, :campaigns, :leads, :contacts, :opportunities, :tasks].each do |table|
remove_column table, :uuid
if self.uuid_configured?
execute("DROP TRIGGER IF EXISTS #{table}_uuid")
end
execute("DROP TRIGGER IF EXISTS #{table}_uuid") if self.uuid_configured?
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/fat_free_crm.rb
Expand Up @@ -26,9 +26,7 @@ def application?
end

# Load Fat Free CRM as a Rails Engine, unless running as a Rails Application
unless defined?(FatFreeCRM::Application)
require 'fat_free_crm/engine'
end
require 'fat_free_crm/engine' unless defined?(FatFreeCRM::Application)

require 'fat_free_crm/load_settings' # register load hook for Setting

Expand Down
4 changes: 1 addition & 3 deletions lib/fat_free_crm/mail_processor/base.rb
Expand Up @@ -82,9 +82,7 @@ def connect!(options = {})
def disconnect!
if @imap
@imap.logout
unless @imap.disconnected?
@imap.disconnect rescue nil
end
@imap.disconnect rescue nil unless @imap.disconnected?
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/tasks/ffcrm/update_data.rake
Expand Up @@ -217,9 +217,7 @@ in a console and continue. This is strongly discouraged. You have been warned!
tmp = Address.where(scope)
tmp.map { |t| t.country = ct[2] }

unless tmp.blank?
addresses_to_update << tmp
end
addresses_to_update << tmp unless tmp.blank?
end

Address.transaction do
Expand Down

0 comments on commit db3dfdc

Please sign in to comment.