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

Commit

Permalink
Run rubocop -a on codebase after 2.6 update. New target is 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vincemtnz committed Apr 3, 2019
1 parent f6ae77c commit 27fcf9d
Show file tree
Hide file tree
Showing 244 changed files with 600 additions and 418 deletions.
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
# frozen_string_literal: true

source 'https://rubygems.org'
Expand Down Expand Up @@ -36,10 +35,10 @@ gem 'slim-rails'
## Use Paper Trail for containing a full history of our edits.
gem 'action_parameter'
gem 'aws-sdk-core', '~> 3'
gem 'aws-sdk-dynamodb', '~> 1.21'
gem 'aws-sdk-s3', '~> 1.30'
gem 'aws-sdk-sns', '~> 1.3'
gem 'aws-sdk-sqs', '~> 1.10'
gem 'aws-sdk-dynamodb', '~> 1.21'
gem 'paper_trail', '~> 10.2'
gem 'paperclip', '~> 6.0'
gem 'rmagick' # rmagick for image processing
Expand Down Expand Up @@ -71,6 +70,7 @@ gem 'uglifier'
gem 'webpacker', '~> 3.5'

group :development, :test do
gem 'byebug'
gem 'capybara' # Capybara for integration testing
gem 'database_cleaner'
gem 'factory_bot_rails'
Expand All @@ -80,7 +80,6 @@ group :development, :test do
gem 'rubocop', '~> 0.66', require: false
gem 'spring-commands-rspec'
gem 'vcr'
gem 'byebug'
end

group :development do
Expand All @@ -96,7 +95,7 @@ group :test do
gem 'poltergeist'
gem 'rails-controller-testing'
gem 'rspec-json_expectations'
gem 'rubocop-rspec'
gem 'timecop'
gem 'webmock'
gem 'rubocop-rspec'
end
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('config/application', __dir__)

Rails.application.load_tasks
3 changes: 2 additions & 1 deletion app/admin/action.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveAdmin.register Action do
actions :all, except: [:new, :edit]
actions :all, except: %i[new edit]

index pagination_total: false
config.per_page = 20
Expand Down
1 change: 1 addition & 0 deletions app/admin/call.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Call do
actions :index

Expand Down
1 change: 1 addition & 0 deletions app/admin/campaign.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Campaign do
permit_params :name, :active

Expand Down
3 changes: 2 additions & 1 deletion app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register_page 'Dashboard' do
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }

Expand Down Expand Up @@ -29,5 +30,5 @@
# end
# end
# end
end # content
end
end
3 changes: 2 additions & 1 deletion app/admin/donation_band.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveAdmin.register DonationBand do
actions :all, except: [:new, :edit]
actions :all, except: %i[new edit]

index pagination_total: false
config.per_page = 20
Expand Down
1 change: 1 addition & 0 deletions app/admin/form.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Form do
permit_params :name, :description, :visible, :master

Expand Down
1 change: 1 addition & 0 deletions app/admin/form_element.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register FormElement do
permit_params :label, :data_type, :default_value, :required, :visible, :name, :position

Expand Down
3 changes: 2 additions & 1 deletion app/admin/image.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveAdmin.register Image do
actions :all, except: [:new, :edit, :destroy]
actions :all, except: %i[new edit destroy]

index pagination_total: false
config.per_page = 20
Expand Down
1 change: 1 addition & 0 deletions app/admin/language.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Language do
permit_params :code, :name
config.filters = false
Expand Down
1 change: 1 addition & 0 deletions app/admin/link.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Link do
permit_params :url, :title, :date, :source, :link_id

Expand Down
3 changes: 2 additions & 1 deletion app/admin/liquid_layout.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveAdmin.register LiquidLayout do
actions :all, except: [:new, :edit]
actions :all, except: %i[new edit]

index pagination_total: false
config.per_page = 20
Expand Down
3 changes: 2 additions & 1 deletion app/admin/liquid_partial.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

ActiveAdmin.register LiquidPartial do
actions :all, except: [:new, :edit, :destroy]
actions :all, except: %i[new edit destroy]

filter :title
filter :content
Expand Down
1 change: 1 addition & 0 deletions app/admin/pages_tag.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register PagesTag do
permit_params :page_id, :tag_id

Expand Down
1 change: 1 addition & 0 deletions app/admin/phone_number.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register PhoneNumber do
actions :all

Expand Down
1 change: 1 addition & 0 deletions app/admin/tag.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

ActiveAdmin.register Tag do
permit_params :name, :actionkit_uri

Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/action_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Api::ActionConfirmationsController < ApplicationController

def resend_confirmations
return head :forbidden unless valid_api_key?

PendingActionService::Reminders.send

head :ok
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/analytics_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Api::AnalyticsController < ApplicationController
layout false

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/email_target_emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def index
table_name: Settings.dynamodb_mailer_table
}

if params[:next]
opts[:exclusive_start_key] = JSON.parse(params[:next])
end
opts[:exclusive_start_key] = JSON.parse(params[:next]) if params[:next]

resp = dynamodb_client.query(opts)

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/go_cardless_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def payment_options
redirect_flow_id: unsafe_params[:redirect_flow_id],
session_token: session[:go_cardless_session_id]
}.tap do |options|
if unsafe_params[:extra_action_fields].present?
options[:extra_params] = unsafe_params[:extra_action_fields]
end
options[:extra_params] = unsafe_params[:extra_action_fields] if unsafe_params[:extra_action_fields].present?
end
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/members_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Api::MembersController < ApplicationController
skip_before_action :verify_authenticity_token, raise: false

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/payment/braintree_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def payment_options
page_id: unsafe_params[:page_id],
store_in_vault: store_in_vault?
}.tap do |options|
if unsafe_params[:extra_action_fields].present?
options[:extra_params] = unsafe_params[:extra_action_fields]
end
options[:extra_params] = unsafe_params[:extra_action_fields] if unsafe_params[:extra_action_fields].present?
end
end

Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/pension_funds_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Api::PensionFundsController < ApplicationController
rescue_from Errno::ENOENT, with: :funds_not_found

Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/stateless/auth_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
# Api::AuthController allows clients to authenticate and receive a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module Braintree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module Braintree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module Braintree
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module GoCardless
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module GoCardless
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Api
module Stateless
module GoCardless
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/stateless/location_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
def location
@location ||= request.location
raise Api::Exceptions::LocationNotFound unless @location

@location.data
end

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/api/stateless/stateless_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class StatelessController < ApplicationController
# Tries token first then falls back to
def authenticate_request!
raise Exceptions::UnauthorizedError unless current_member

current_member
end

Expand All @@ -29,15 +30,17 @@ def current_member

def authenticate_member_from_token
return nil if request.headers['authorization'].nil?

_, token = request.headers['authorization'].split
payload = decode_jwt(token)
Member.find(payload[:id])
rescue
rescue StandardError
raise Exceptions::UnauthorizedError
end

def authenticate_member_from_cookie
return nil if cookies.encrypted['authorization'].nil?

payload = decode_jwt(cookies.encrypted['authorization'])
Member.find(payload[:id])
end
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/api/survey_responses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Api::SurveyResponsesController < ApplicationController
skip_before_action :verify_authenticity_token, raise: false
before_action :localize_from_page_id, only: :create
Expand All @@ -23,9 +24,9 @@ def session_manager
end

def survey_response_params
params.
to_unsafe_hash.
slice(*form.form_elements.map(&:name), 'akid', 'source', 'referring_akid', 'rid', 'referrer_id')
params
.to_unsafe_hash
.slice(*form.form_elements.map(&:name), 'akid', 'source', 'referring_akid', 'rid', 'referrer_id')
end

def form
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/campaigns_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class CampaignsController < ApplicationController
before_action :authenticate_user!
before_action :find_campaign, only: [:show, :edit, :update, :destroy]
before_action :find_campaign, only: %i[show edit update destroy]

def index
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/clone_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ClonePagesController < ApplicationController
before_action :authenticate_user!
before_action :find_page
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/donation_bands_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class DonationBandsController < ApplicationController
before_action :authenticate_user!
before_action :find_donation_band, only: [:edit, :update]
before_action :find_donation_band, only: %i[edit update]

def new
@donation_band = DonationBand.new
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/email_confirmation_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class EmailConfirmationController < ApplicationController
before_action :find_member

Expand All @@ -18,6 +19,7 @@ def verify

def find_member
raise ActiveRecord::RecordNotFound if params[:email].blank?

@member = Member.find_by_email!(params[:email])
end
end
3 changes: 2 additions & 1 deletion app/controllers/featured_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

class FeaturedPagesController < ApplicationController
before_action :authenticate_user!
before_action :find_page, only: [:create, :destroy]
before_action :find_page, only: %i[create destroy]

def create
@page.update(featured: true)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/forms_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

# TODO: Needs a controller spec
class FormsController < ApplicationController
before_action :authenticate_user!
before_action :find_form, only: [:show, :edit]
before_action :find_form, only: %i[show edit]

def index
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class HomeController < ApplicationController
def index
if user_signed_in?
Expand Down
1 change: 1 addition & 0 deletions app/controllers/images_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ImagesController < ApplicationController
before_action :authenticate_user!
before_action :find_page
Expand Down
1 change: 1 addition & 0 deletions app/controllers/links_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class LinksController < ApplicationController
before_action :authenticate_user!

Expand Down

0 comments on commit 27fcf9d

Please sign in to comment.