Skip to content

Commit

Permalink
Bump Rubocop from 0.35.1 to 0.49.1 and fix failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Crankshaft Robot authored and Nick Campbell committed Sep 1, 2017
1 parent be68ac0 commit a9b50b9
Show file tree
Hide file tree
Showing 55 changed files with 1,555 additions and 1,537 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Layout/DotPosition:
EnforcedStyle: trailing

Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
6 changes: 3 additions & 3 deletions demo.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require_relative 'lib/gocardless_pro'
require_relative 'lib/gocardless_pro'

@client = GoCardlessPro::Client.new(
access_token: ENV["GOCARDLESS_TOKEN"],
access_token: ENV['GOCARDLESS_TOKEN'],
environment: :sandbox
)

puts "Your first customer:"
puts 'Your first customer:'
puts "-> #{@client.customers.list.records.first.inspect}"
10 changes: 5 additions & 5 deletions gocardless_pro.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'gocardless_pro/version'

Gem::Specification.new do |spec|
spec.name = "gocardless_pro"
spec.name = 'gocardless_pro'
spec.version = GoCardlessPro::VERSION
spec.authors = %w(GoCardless)
spec.email = %w([email protected])
spec.summary = %q{A gem for calling the GoCardless Pro API}
spec.homepage = "https://github.com/gocardless/gocardless-pro-ruby"
spec.license = "MIT"
spec.homepage = 'https://github.com/gocardless/gocardless-pro-ruby'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_development_dependency 'rspec', '~> 3.1'
spec.add_development_dependency 'webmock', '~> 1.18'
spec.add_development_dependency 'rubocop', '~> 0.35.1'
spec.add_development_dependency 'rubocop', '~> 0.49.1'
spec.add_development_dependency 'yard', '~> 0.8.7.6'

spec.add_dependency 'faraday', ['>= 0.8.9', '< 0.10']
Expand Down
3 changes: 2 additions & 1 deletion lib/gocardless_pro.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand All @@ -19,7 +20,7 @@ module GoCardlessPro
if File.file? File.expand_path("#{version_file}.rb", File.dirname(__FILE__))
require_relative version_file
else
GoCardlessPro::VERSION = ''
GoCardlessPro::VERSION = ''.freeze
end

require_relative 'gocardless_pro/api_service'
Expand Down
5 changes: 3 additions & 2 deletions lib/gocardless_pro/api_service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down Expand Up @@ -38,7 +39,7 @@ def initialize(url, token, options = {})
# @param path [String] the URL (without the base domain) to make the request to
# @param options [Hash] the options hash
def make_request(method, path, options = {})
fail ArgumentError, 'options must be a hash' unless options.is_a?(Hash)
raise ArgumentError, 'options must be a hash' unless options.is_a?(Hash)
options[:headers] ||= {}
options[:headers] = @headers.merge(options[:headers])
Request.new(@connection, method, @path_prefix + path, options).request
Expand All @@ -50,7 +51,7 @@ def inspect
url.password = 'REDACTED' unless url.password.nil?
"#<GoCardlessPro::Client url=\"#{url}\">"
end
alias_method :to_s, :inspect
alias to_s inspect

private

Expand Down
12 changes: 6 additions & 6 deletions lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def subscriptions
# authentication.
#
def initialize(options)
access_token = options.delete(:access_token) || fail('No Access Token given to GoCardless Client')
access_token = options.delete(:access_token) || raise('No Access Token given to GoCardless Client')
environment = options.delete(:environment) || :live
url = options.delete(:url) || url_for_environment(environment)
options = custom_options(options)
Expand All @@ -94,7 +94,7 @@ def url_for_environment(environment)
elsif environment === :sandbox
'https://api-sandbox.gocardless.com'
else
fail "Unknown environment key: #{environment}"
raise "Unknown environment key: #{environment}"
end
end

Expand All @@ -115,11 +115,11 @@ def default_options
{
default_headers: {
'GoCardless-Version' => '2015-07-06',
'User-Agent' => "#{user_agent}",
'User-Agent' => user_agent.to_s,
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
'GoCardless-Client-Version' => '2.1.0'
}
'GoCardless-Client-Version' => '2.1.0',
},
}
end

Expand All @@ -139,7 +139,7 @@ def user_agent
comment = [
"#{ruby_engine}/#{ruby_version}",
"#{RUBY_ENGINE}/#{interpreter_version}",
"#{RUBY_PLATFORM}"
RUBY_PLATFORM.to_s,
]
comment << "faraday/#{Faraday::VERSION}"
"#{gem_info} #{comment.join(' ')}"
Expand Down
8 changes: 4 additions & 4 deletions lib/gocardless_pro/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Error < StandardError
# intialize a new error
#  @param error the error from the API
def initialize(error)
fail ArgumentError, 'GoCardless errors expect a hash' unless error.is_a?(Hash)
raise ArgumentError, 'GoCardless errors expect a hash' unless error.is_a?(Hash)
@error = error
end

Expand All @@ -22,9 +22,9 @@ def message

def to_s
if errors.any?
errors
.map { |err| "#{err['field']} #{err['message']}" }
.join(', ')
errors.
map { |err| "#{err['field']} #{err['message']}" }.
join(', ')
else
@error['message']
end
Expand Down
8 changes: 4 additions & 4 deletions lib/gocardless_pro/middlewares/raise_gocardless_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class RaiseGoCardlessErrors < Faraday::Response::Middleware

def on_complete(env)
if !json?(env) || API_ERROR_STATUSES.include?(env.status)
fail ApiError, generate_error_data(env)
raise ApiError, generate_error_data(env)
end

if CLIENT_ERROR_STATUSES.include?(env.status)
json_body ||= JSON.parse(env.body) unless env.body.empty?
error_type = json_body['error']['type']
fail(error_class_for_type(error_type), json_body['error'])
raise(error_class_for_type(error_type), json_body['error'])
end
end

Expand All @@ -23,7 +23,7 @@ def error_class_for_type(type)
validation_failed: GoCardlessPro::ValidationError,
gocardless: GoCardlessPro::GoCardlessError,
invalid_api_usage: GoCardlessPro::InvalidApiUsageError,
invalid_state: GoCardlessPro::InvalidStateError
invalid_state: GoCardlessPro::InvalidStateError,
}.fetch(type.to_sym)
end

Expand All @@ -33,7 +33,7 @@ def generate_error_data(env)
"code: #{env.status}\n" \
"headers: #{env.response_headers}\n" \
"body: #{env.body}",
'code' => env.status
'code' => env.status,
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/gocardless_pro/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def make_request
def request_body
if @method == :get
nil
elsif [:post, :put, :delete].include?(@method)
elsif %i[post put delete].include?(@method)
@given_options.fetch(:params, {})
else
fail "Unknown request method #{@method}"
raise "Unknown request method #{@method}"
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/bank_details_lookup.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/creditor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/creditor_bank_account.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/customer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/customer_bank_account.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/mandate.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/mandate_pdf.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/payment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/payout.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/redirect_flow.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/refund.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
1 change: 1 addition & 0 deletions lib/gocardless_pro/resources/subscription.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# encoding: utf-8

#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/services/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def make_request(method, path, options = {})

# Get the envelope key for the given service. Children are expected to implement this method.
def envelope_key
fail NotImplementedError
raise NotImplementedError
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module GoCardlessPro

module GoCardlessPro
# Current version of the GC gem
VERSION = '2.1.0'
VERSION = '2.1.0'.freeze
end
Loading

0 comments on commit a9b50b9

Please sign in to comment.