Skip to content

Commit

Permalink
Upgraded RuboCop to 1.12.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 17, 2023
1 parent 9d42aaa commit 70985a7
Show file tree
Hide file tree
Showing 29 changed files with 238 additions and 35 deletions.
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
AllCops:
NewCops: enable
Exclude:
- vendor/**/*
TargetRubyVersion: 2.4
Expand All @@ -16,7 +17,17 @@ Naming/FileName:
Style/Documentation:
Enabled: false

Style/Lambda:
Enabled: false

Layout/LineLength:
Enabled: false

Metrics:
Enabled: false

inherit_from: .rubocop_todo.yml

require:
- rubocop-rake
- rubocop-rspec
90 changes: 84 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,98 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-07-21 13:04:05 -0500 using RuboCop version 0.75.0.
# on 2023-09-17 09:23:21 UTC using RuboCop version 1.12.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'spec/iex/client_spec.rb'
- 'spec/iex/config/logger_spec.rb'

# Offense count: 65
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/iex/config/logger_spec.rb'
- 'spec/iex/resources/resource_spec.rb'

# Offense count: 29
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 55

# Offense count: 3
RSpec/ExpectInHook:
Exclude:
- 'spec/iex/config/logger_spec.rb'

# Offense count: 23
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Enabled: false

# Offense count: 51
RSpec/MultipleExpectations:
Max: 55

# Offense count: 347
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Enabled: false

# Offense count: 20
RSpec/NestedGroups:
Max: 6

# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/iex/resources/resource_spec.rb'

# Offense count: 1
# Configuration parameters: IgnoredPatterns.
# SupportedStyles: snake_case, camelCase
RSpec/VariableName:
EnforcedStyle: snake_case

# Offense count: 1
# Configuration parameters: AllowedChars.
# AllowedChars: ©
Style/AsciiComments:
Exclude:
- 'lib/iex/resources/quote.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
# Offense count: 4
# Cop supports --auto-correct.
Style/GlobalStdStream:
Exclude:
- 'lib/iex/resources/resource.rb'
- 'lib/iex/logger.rb'
- 'spec/iex/client_spec.rb'
- 'spec/iex/config/client_spec.rb'
- 'spec/iex/config/logger_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/HashTransformValues:
Exclude:
- 'lib/iex/endpoints/ohlc.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 221
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### 2.1.1 (Next)
* [#121](https://github.com/dblock/iex-ruby-client/pull/121): Upgraded rubocop to 1.12 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 2.1.0 (2023-09-17)
Expand Down
4 changes: 3 additions & 1 deletion iex-ruby-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Gem::Specification.new do |s|
s.add_dependency 'money', '~> 6.0'
s.add_development_dependency 'rake', '~> 10'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rubocop', '0.75.0'
s.add_development_dependency 'rubocop', '~> 1.12.0'
s.add_development_dependency 'rubocop-rake'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'vcr'
s.add_development_dependency 'webmock'
end
4 changes: 2 additions & 2 deletions lib/iex/endpoints/ohlc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def ohlc(symbol, options = {})
end

def market(options = {})
Hash[get('stock/market/ohlc', { token: publishable_token }.merge(options)).map do |k, v|
get('stock/market/ohlc', { token: publishable_token }.merge(options)).map do |k, v|
[k, IEX::Resources::OHLC.new(v)]
end]
end.to_h
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/iex/errors/invalid_symbols_list.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module IEX
module Errors
class InvalidSymbolsList < StandardError
attr_reader :symbols
attr_reader :response
attr_reader :symbols, :response

def initialize(symbols, response)
@response = response
Expand Down
3 changes: 1 addition & 2 deletions lib/iex/errors/symbol_not_found_error.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module IEX
module Errors
class SymbolNotFoundError < StandardError
attr_reader :symbol
attr_reader :response
attr_reader :symbol, :response

def initialize(symbol, response)
@response = response
Expand Down
44 changes: 33 additions & 11 deletions spec/iex/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,73 @@
IEX::Api.config.reset!
IEX::Api.logger.reset!
end

context 'with defaults' do
let(:client) { described_class.new }
context '#initialize' do

describe '#initialize' do
it 'implements endpoint' do
expect(client.endpoint).to_not be nil
expect(client.endpoint).not_to be nil
end

it 'includes default http configuration' do
expect(client.user_agent).to eq "IEX Ruby Client/#{IEX::VERSION}"
end

it 'sets user-agent' do
expect(client.user_agent).to eq IEX::Api::Config::Client.user_agent
expect(client.user_agent).to include IEX::VERSION
end

it 'caches the Faraday connection to allow persistent adapters' do
first = client.send(:connection)
second = client.send(:connection)
expect(first).to equal second
end

it 'sets a nil logger' do
expect(client.logger.instance).to be_nil
expect(client.send(:connection).builder.handlers).not_to include(::Faraday::Response::Logger)
end

IEX::Api::Config::Client::ATTRIBUTES.each do |key|
it "sets #{key}" do
expect(client.send(key)).to eq IEX::Api::Config::Client.send(key)
end
end
end
end

context 'with custom settings' do
context '#initialize' do
describe '#initialize' do
IEX::Api::Config::Client::ATTRIBUTES.each do |key|
context key.to_s do
let(:client) { described_class.new(key => 'custom') }

it "sets #{key}" do
expect(client.send(key)).to_not eq IEX::Api::Config::Client.send(key)
expect(client.send(key)).not_to eq IEX::Api::Config::Client.send(key)
expect(client.send(key)).to eq 'custom'
end
end
end
end
end

context 'global config' do
let(:client) { described_class.new }

context 'user-agent' do
before do
IEX::Api.configure do |config|
config.user_agent = 'custom/user-agent'
end
end
context '#initialize' do

describe '#initialize' do
it 'sets user-agent' do
expect(client.user_agent).to eq 'custom/user-agent'
end

it 'creates a connection with the custom user-agent' do
expect(client.send(:connection).headers).to include(
'Accept' => 'application/json; charset=utf-8',
Expand All @@ -67,33 +80,39 @@
end
end
end

context 'proxy' do
before do
IEX::Api.configure do |config|
config.proxy = 'http://localhost:8080'
end
end
context '#initialize' do

describe '#initialize' do
it 'sets proxy' do
expect(client.proxy).to eq 'http://localhost:8080'
end

it 'creates a connection with the proxy' do
expect(client.send(:connection).proxy.uri.to_s).to eq 'http://localhost:8080'
end
end
end

context 'SSL options' do
before do
IEX::Api.configure do |config|
config.ca_path = '/ca_path'
config.ca_file = '/ca_file'
end
end
context '#initialize' do

describe '#initialize' do
it 'sets ca_path and ca_file' do
expect(client.ca_path).to eq '/ca_path'
expect(client.ca_file).to eq '/ca_file'
end

it 'creates a connection with ssl options' do
ssl = client.send(:connection).ssl
expect(ssl.ca_path).to eq '/ca_path'
Expand All @@ -108,7 +127,7 @@
after { IEX::Api.logger.reset! }

context 'when assigning an instance' do
context '#initialize' do
describe '#initialize' do
context 'when directly assigning `logger`' do
before { IEX::Api.logger = logger }

Expand Down Expand Up @@ -155,7 +174,7 @@
end
end

context '#initialize' do
describe '#initialize' do
it 'sets logger' do
expect(client.logger.instance).to eq logger
expect(client.logger.options).to eq opts
Expand All @@ -176,11 +195,13 @@
config.open_timeout = 15
end
end
context '#initialize' do

describe '#initialize' do
it 'sets timeout and open_timeout' do
expect(client.timeout).to eq 10
expect(client.open_timeout).to eq 15
end

it 'creates a connection with timeout options' do
conn = client.send(:connection)
expect(conn.options.timeout).to eq 10
Expand All @@ -204,13 +225,14 @@
expect(described_class.new.user_agent).not_to eq(pre_config_client.user_agent)
end

it 'should not allow the client to reset' do
it 'does not allow the client to reset' do
expect { client.reset! }.to raise_error(NoMethodError)
end
end

context 'without a token' do
let(:client) { described_class.new }

it 'results in an API key error', vcr: { cassette_name: 'client/access_denied' } do
expect do
client.get '/stock/msft/quote', token: client.publishable_token
Expand Down
1 change: 1 addition & 0 deletions spec/iex/endpoints/balance_sheet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
subject do
client.balance_sheet('MSFT')
end

let(:balance_sheet) { subject.first }

it 'fetches balance sheet' do
Expand Down
1 change: 1 addition & 0 deletions spec/iex/endpoints/cash_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
subject do
client.cash_flow('MSFT')
end

let(:cash_flow) { subject.first }

it 'fetches cash flow statement' do
Expand Down
Loading

0 comments on commit 70985a7

Please sign in to comment.