Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
[rubocop] autocorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Martinez committed Mar 1, 2017
1 parent f716628 commit 3794b21
Show file tree
Hide file tree
Showing 26 changed files with 162 additions and 155 deletions.
8 changes: 1 addition & 7 deletions .rubocop.yml
@@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.4
Exclude:
- 'bin/**/*'
- 'db/schema.rb'
Expand All @@ -28,12 +28,6 @@ Style/MultilineMethodCallIndentation:
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent

Lint/BlockAlignment:
AlignWith: start_of_block

Lint/EndAlignment:
AlignWith: keyword

Lint/InheritException:
Enabled: false

Expand Down
11 changes: 11 additions & 0 deletions .rubocop_todo.yml
Expand Up @@ -167,6 +167,17 @@ Style/SingleLineBlockParams:
Exclude:
- 'spec/support/helper_functions.rb'

Style/EmptyMethod:
Enabled: false

Metrics/BlockLength:
Exclude:
- Guardfile
- app/admin/**
- config/**/*
- lib/**/*
- spec/**/*

Metrics/LineLength:
Max: 120
Exclude:
Expand Down
108 changes: 54 additions & 54 deletions Gemfile
Expand Up @@ -3,103 +3,103 @@
source 'https://rubygems.org'
ruby '2.4.0'

gem 'rails', '4.2.8'
gem 'rake'
gem 'rails-observers'
gem 'readthis'
gem 'hiredis'
gem 'redis', '>= 3.2.0', require: ['redis', 'redis/connection/hiredis']
gem 'pg'
gem 'jquery-rails'
gem 'selectize-rails' # why not npm?
gem 'aasm'
gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin'
gem 'bcrypt', '~> 3.1.7'
gem 'braintree', '~> 2.54.0'
gem 'browserify-rails', '~> 2.2.0'
gem 'codemirror-rails'
gem 'countries'
gem 'geocoder'
gem 'phony'
gem 'browserify-rails', '~> 2.2.0'
gem 'country_select'
gem 'devise'
gem 'font-awesome-sass'
gem 'money'
gem 'geocoder'
gem 'gocardless_pro'
gem 'google_currency'
gem 'rack-cors', require: 'rack/cors'
gem 'hiredis'
gem 'httparty'
gem 'jbuilder', '~> 2.0'
gem 'braintree', '~> 2.54.0'
gem 'gocardless_pro'
gem 'aasm'
gem 'i18n-js', '>= 3.0.0.rc12'
gem 'rails-i18n', '~> 4.0.0'
gem 'bcrypt', '~> 3.1.7'
gem 'slim-rails', '~> 3.1.1'
gem 'jbuilder', '~> 2.0'
gem 'jquery-rails'
gem 'kaminari'
gem 'liquid'
gem 'remotipart', '~> 1.2' # [Q] Are we using this?
gem 'devise'
gem 'money'
gem 'omniauth-google-oauth2'
gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin'
gem 'country_select'
gem 'kaminari'
gem 'pg'
gem 'phony'
gem 'rack-cors', require: 'rack/cors'
gem 'rails', '4.2.8'
gem 'rails-i18n', '~> 4.0.0'
gem 'rails-observers'
gem 'rake'
gem 'readthis'
gem 'redis', '>= 3.2.0', require: ['redis', 'redis/connection/hiredis']
gem 'remotipart', '~> 1.2' # [Q] Are we using this?
gem 'selectize-rails' # why not npm?
gem 'slim-rails', '~> 3.1.1'

# Use Paper Trail for containing a full history of our edits.
gem 'action_parameter'
gem 'aws-sdk', '~> 2'
gem 'paperclip', '~> 5.0.0'
gem 'paper_trail'
gem 'rmagick' # rmagick for image processing
gem 'paperclip', '~> 5.0.0'
gem 'aws-sdk', '~> 2'
gem 'action_parameter'
# AWS SDK for Rails - makes SES integration easy
gem 'actionkit_connector', git: 'https://github.com/SumOfUs/actionkit_connector', branch: 'master'
gem 'airbrake', '~> 5.7.1'
gem 'aws-sdk-rails'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'browser', '~> 2.0', '>= 2.0.3'
gem 'coffee-rails', '~> 4.1.0'
gem 'compass-rails', '~> 3.0.2' # was using git master branch before
gem 'config'
gem 'envyable', require: 'envyable/rails-now'
gem 'friendly_id'
gem 'jwt'
gem 'logger'
gem 'lograge'
gem 'summernote-rails'
gem 'browser', '~> 2.0', '>= 2.0.3'
gem 'share_progress', git: 'https://github.com/SumOfUs/share_progress', branch: 'master', require: false
gem 'metamagic'
gem 'newrelic_rpm'
gem 'puma', '~> 2.15.3'
gem 'friendly_id'
gem 'config'
gem 'twilio-ruby'
gem 'metamagic'
gem 'jwt'
gem 'actionkit_connector', git: 'https://github.com/SumOfUs/actionkit_connector', branch: 'master'
gem 'airbrake', '~> 5.7.1'
gem 'envyable', require: 'envyable/rails-now'
gem 'webpack-rails'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'sprockets-rails'
gem 'compass-rails', '~> 3.0.2' # was using git master branch before
gem 'sass-rails', '~> 5.0.6'
gem 'share_progress', git: 'https://github.com/SumOfUs/share_progress', branch: 'master', require: false
gem 'sprockets-rails'
gem 'summernote-rails'
gem 'twilio-ruby'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'webpack-rails'

group :development, :test do
gem 'rubocop', require: false
gem 'spring'
gem 'rspec-rails'
gem 'capybara' # Capybara for integration testing
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'faker'
gem 'vcr'
gem 'magic_lamp'
gem 'rspec-rails'
gem 'rubocop', require: false
gem 'spring'
gem 'spring-commands-rspec'
gem 'vcr'
end

group :doc do
gem 'sdoc', '~> 0.4.0'
end

group :development do
gem 'guard-rspec', require: false
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'annotate'
gem 'byebug'
gem 'foreman', require: false
gem 'guard-rspec', require: false
gem 'terminal-notifier-guard' # [OSX] brew install terminal-notifier
gem 'web-console', '~> 2.0'
end

group :test do
gem 'webmock'
gem 'timecop'
gem 'coveralls', require: false
gem 'poltergeist'
gem 'timecop'
gem 'webmock'
end

# Rails Assets - reference any Bower components that you need as gems.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/plugins/forms_controller.rb
Expand Up @@ -15,7 +15,7 @@ def create

def show
plugin = Plugins.find_for permitted_params[:plugin_type], permitted_params[:plugin_id]
partial_dir = (plugin.name == 'Survey') ? 'surveys' : 'shared'
partial_dir = plugin.name == 'Survey' ? 'surveys' : 'shared'
render partial: "plugins/#{partial_dir}/preview", locals: { plugin: plugin }
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/layout_select_helper.rb
Expand Up @@ -9,7 +9,7 @@ def construct_layout_select_class(liquid_layout, page, field)
end

def specify_layout_types(field)
(field == :liquid_layout_id) ? 'primary' : 'follow-up'
field == :liquid_layout_id ? 'primary' : 'follow-up'
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/liquid/champaign_liquid_filters.rb
Expand Up @@ -2,7 +2,7 @@
module ChampaignLiquidFilters
def select_option(tags_string, to_select)
# if one is already selected then leave it
return tags_string if tags_string =~ /selected/
return tags_string if tags_string.match?(/selected/)
tags_string.gsub(/(<option.*?value=["']#{to_select}["'])(.*?)>/, '\1 selected \2>')
end

Expand Down
2 changes: 1 addition & 1 deletion app/liquid/liquid_helper.rb
Expand Up @@ -15,7 +15,7 @@ def country_option_tags(user_country_code = nil)
options = []
names_with_codes = ISO3166::Country.all_names_with_codes(I18n.locale.to_s)
names_with_codes.each do |name, code|
selected = (user_country_code == code) ? "selected='selected'" : ''
selected = user_country_code == code ? "selected='selected'" : ''
options << "<option value='#{code}' #{selected}>#{name}</option>"
end
options.join("\n")
Expand Down
2 changes: 1 addition & 1 deletion app/models/form.rb
Expand Up @@ -34,7 +34,7 @@ class Form < ActiveRecord::Base

after_touch do
formable.try(:page) do |page|
page.touch if page
page&.touch
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/link.rb
Expand Up @@ -26,7 +26,7 @@ class Link < ActiveRecord::Base
private

def url_has_protocol
unless %r{^(https?:)?\/\/}i =~ url
unless %r{^(https?:)?\/\/}i.match?(url)
errors.add(:url, 'must have a protocol (like http://)')
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/page.rb
Expand Up @@ -53,7 +53,7 @@ class Page < ActiveRecord::Base
has_many :images, dependent: :destroy
has_many :links, dependent: :destroy

scope :language, -> (code) { code ? joins(:language).where(languages: { code: code }) : all }
scope :language, ->(code) { code ? joins(:language).where(languages: { code: code }) : all }
scope :featured, -> { where(featured: true) }

validates :title, presence: true
Expand Down Expand Up @@ -139,7 +139,7 @@ def language_code
def switch_plugins
fields = %w(liquid_layout_id follow_up_liquid_layout_id follow_up_plan)
if fields.any? { |f| changed.include?(f) }
secondary = (follow_up_plan == 'with_liquid') ? follow_up_liquid_layout : nil
secondary = follow_up_plan == 'with_liquid' ? follow_up_liquid_layout : nil
PagePluginSwitcher.new(self).switch(liquid_layout, secondary)
end
end
Expand Down
20 changes: 10 additions & 10 deletions app/models/payment/braintree.rb
Expand Up @@ -55,7 +55,7 @@ def build
@customer = Payment::Braintree::Customer.create(customer_attrs)
end

payment_method = Payment::Braintree::PaymentMethod.find_or_create_by!(token: @bt_payment_method.token) do |pm|
payment_method = Payment::Braintree::PaymentMethod.find_or_create_by!(token: @bt_payment_method.token) do |pm|
pm.customer = @customer
pm.store_in_vault = @store_in_vault
end
Expand Down Expand Up @@ -159,15 +159,15 @@ def create_customer
end

def create_payment_method
if payment_method_token.nil? || @bt_result.transaction.nil?
@local_payment_method_id = nil
else
@local_payment_method_id = BraintreeServices::PaymentMethodBuilder.new(
transaction: @bt_result.transaction,
customer: @customer,
store_in_vault: @store_in_vault
).create.id
end
@local_payment_method_id = if payment_method_token.nil? || @bt_result.transaction.nil?
nil
else
BraintreeServices::PaymentMethodBuilder.new(
transaction: @bt_result.transaction,
customer: @customer,
store_in_vault: @store_in_vault
).create.id
end
end

def create_transaction
Expand Down
2 changes: 1 addition & 1 deletion app/models/plugins/has_form.rb
Expand Up @@ -33,7 +33,7 @@ def dup
clone = super
clone.save!

clone.form.form_elements = form.form_elements.map(&:dup) if clone.form
clone.form&.form_elements = form.form_elements.map(&:dup)

clone
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/share/email.rb
Expand Up @@ -20,6 +20,6 @@ class Share::Email < ActiveRecord::Base
validate :has_link

def has_link
errors.add(:body, 'does not contain {LINK}') unless body =~ /\{LINK\}/
errors.add(:body, 'does not contain {LINK}') unless body.match?(/\{LINK\}/)
end
end
2 changes: 1 addition & 1 deletion app/models/share/twitter.rb
Expand Up @@ -20,6 +20,6 @@ class Share::Twitter < ActiveRecord::Base
validate :has_link

def has_link
errors.add(:description, 'does not contain {LINK}') unless description =~ /\{LINK\}/
errors.add(:description, 'does not contain {LINK}') unless description.match?(/\{LINK\}/)
end
end
30 changes: 15 additions & 15 deletions app/services/page_updater.rb
Expand Up @@ -116,21 +116,21 @@ def update_plugin(plugin_params)
end

def update_share(share_params, _name)
if share_params[:id].present?
variant = ShareProgressVariantBuilder.update(
params: without_name(share_params),
variant_type: share_params[:name],
page: @page,
id: share_params[:id]
)
else
variant = ShareProgressVariantBuilder.create(
params: without_name(share_params),
variant_type: share_params[:name],
page: @page,
url: @page_url
)
end
variant = if share_params[:id].present?
ShareProgressVariantBuilder.update(
params: without_name(share_params),
variant_type: share_params[:name],
page: @page,
id: share_params[:id]
)
else
ShareProgressVariantBuilder.create(
params: without_name(share_params),
variant_type: share_params[:name],
page: @page,
url: @page_url
)
end
variant.errors
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/search/page_searcher.rb
Expand Up @@ -37,7 +37,7 @@ def search

def validate_query(query)
# if query is an empty array, nil or an empty string, skip filtering for that query
([[], nil, ''].include? query) ? false : true
[[], nil, ''].include? query ? false : true
end

def combine_collections(collection1, collection2)
Expand Down
2 changes: 1 addition & 1 deletion app/services/share_progress_variant_builder.rb
Expand Up @@ -49,7 +49,7 @@ def create

if sp_button.save
button.update(sp_id: sp_button.id, sp_button_html: sp_button.share_button_html, url: sp_button.page_url)
variant.update(sp_id: sp_button.variants[@variant_type].last[:id])
variant.update(sp_id: sp_button.variants[@variant_type].last[:id])
else
add_sp_errors_to_variant(sp_button, variant)
end
Expand Down

0 comments on commit 3794b21

Please sign in to comment.