Skip to content

Commit 8c044ac

Browse files
authored
Merge pull request #131 from nebolsin/security/rubocop-upgrade
Upgrade to Rubocop 0.50.0 (fixes CVE-2017-8418)
2 parents bc12708 + 9459a1a commit 8c044ac

14 files changed

+33
-47
lines changed

.rubocop.yml

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

3+
AllCops:
4+
TargetRubyVersion: 2.2
5+
6+
Metrics/BlockLength:
7+
ExcludedMethods: [it, describe]

.rubocop_todo.yml

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2017-08-26 18:01:43 +0100 using RuboCop version 0.42.0.
3+
# on 2017-10-01 22:20:54 +0300 using RuboCop version 0.50.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -12,7 +12,7 @@ Metrics/ClassLength:
1212
Max: 110
1313

1414
# Offense count: 97
15-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
15+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
1616
# URISchemes: http, https
1717
Metrics/LineLength:
1818
Max: 142
@@ -27,11 +27,6 @@ Metrics/MethodLength:
2727
Metrics/ModuleLength:
2828
Max: 398
2929

30-
# Offense count: 1
31-
Style/AsciiComments:
32-
Exclude:
33-
- 'lib/hyperclient/collection.rb'
34-
3530
# Offense count: 2
3631
# Configuration parameters: EnforcedStyle, SupportedStyles.
3732
# SupportedStyles: nested, compact
@@ -56,25 +51,7 @@ Style/DoubleNegation:
5651
- 'lib/hyperclient/curie.rb'
5752
- 'lib/hyperclient/link.rb'
5853

59-
# Offense count: 5
60-
# Cop supports --auto-correct.
61-
# Configuration parameters: EnforcedStyle, SupportedStyles.
62-
# SupportedStyles: line_count_dependent, lambda, literal
63-
Style/Lambda:
64-
Exclude:
65-
- 'test/hyperclient/entry_point_test.rb'
66-
- 'test/hyperclient/link_test.rb'
67-
- 'test/hyperclient/resource_test.rb'
68-
6954
# Offense count: 1
7055
Style/MethodMissing:
7156
Exclude:
7257
- 'lib/hyperclient/collection.rb'
73-
74-
# Offense count: 1
75-
# Cop supports --auto-correct.
76-
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
77-
# SupportedStyles: slashes, percent_r, mixed
78-
Style/RegexpLiteral:
79-
Exclude:
80-
- 'features/support/api.rb'

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 0.8.7 (Next)
22

3+
* [#131](https://github.com/codegram/hyperclient/pull/131): Upgrade to Rubocop 0.50.0, fix Bundler's insecure git source warning - [@nebolsin](https://github.com/nebolsin).
34
* Your contribution here.
45

56
### 0.8.6 (August 27, 2017)

Gemfile

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# NOTE: this is temporary until Bundler 2.0 changes how github: references work.
2+
git_source(:github) { |repo| "https://github.com/#{repo['/'] ? repo : "#{repo}/#{repo}"}.git" }
3+
14
source 'https://rubygems.org'
25

36
gemspec
@@ -12,20 +15,20 @@ group :development do
1215
end
1316

1417
group :development, :test do
15-
gem 'yard', '~> 0.8'
16-
gem 'yard-tomdoc'
1718
gem 'rake'
19+
gem 'rubocop', '~> 0.50.0', require: false
1820
gem 'simplecov', require: false
19-
gem 'rubocop', '~> 0.42.0', require: false
21+
gem 'yard', '~> 0.8'
22+
gem 'yard-tomdoc'
2023
end
2124

2225
group :test do
23-
gem 'futuroscope', github: 'codegram/futuroscope'
2426
gem 'danger-changelog', '~> 0.1'
27+
gem 'futuroscope', github: 'codegram/futuroscope'
2528
gem 'minitest'
26-
gem 'turn'
27-
gem 'webmock'
2829
gem 'mocha'
2930
gem 'rack-test'
3031
gem 'spinach'
32+
gem 'turn'
33+
gem 'webmock'
3134
end

Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require 'yard'
1717
YARD::Config.load_plugin('yard-tomdoc')
1818
YARD::Rake::YardocTask.new do |t|
1919
t.files = ['lib/**/*.rb']
20-
t.options = %w(-r README.md)
20+
t.options = %w[-r README.md]
2121
end
2222

2323
require 'rake/testtask'
@@ -38,4 +38,4 @@ end
3838
require 'rubocop/rake_task'
3939
RuboCop::RakeTask.new(:rubocop)
4040

41-
task default: [:test, :spinach, :rubocop]
41+
task default: %i[test spinach rubocop]

features/steps/api_navigation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
1818
end
1919

2020
step 'I search for posts by tag with a templated link' do
21-
api._links.tagged._expand(tags: %w(foo bar))._resource
21+
api._links.tagged._expand(tags: %w[foo bar])._resource
2222
end
2323

2424
step 'the API should receive the request for posts by tag with all the params' do

features/support/api.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module API
77
before do
88
WebMock::Config.instance.query_values_notation = :flat_array
99

10-
stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
10+
stub_request(:any, /api.example.org*/).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
1111
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
1212
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/hal+json' })
1313
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response, headers: { 'Content-Type' => 'application/hal+json' })

hyperclient.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- encoding: utf-8 -*-
1+
22
require File.expand_path('../lib/hyperclient/version', __FILE__)
33

44
Gem::Specification.new do |gem|

lib/hyperclient/collection.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def include?(key)
3535
end
3636

3737
# Public: Returns a value from the collection for the given key.
38-
# If the key cant be found, there are several options:
38+
# If the key can't be found, there are several options:
3939
# With no other arguments, it will raise an KeyError exception;
4040
# if default is given, then that will be returned;
4141
#

lib/hyperclient/resource.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def method_missing(method, *args, &block)
109109
if args.any? && args.first.is_a?(Hash)
110110
_links.send(method, [], &block)._expand(*args)
111111
elsif !Array.method_defined?(method)
112-
[:_attributes, :_embedded, :_links].each do |target|
112+
%i[_attributes _embedded _links].each do |target|
113113
target = send(target)
114114
return target.send(method, *args, &block) if target.respond_to?(method.to_s)
115115
end
@@ -120,7 +120,7 @@ def method_missing(method, *args, &block)
120120
# Internal: Accessory method to allow the resource respond to
121121
# methods that will hit method_missing.
122122
def respond_to_missing?(method, include_private = false)
123-
[:_attributes, :_embedded, :_links].each do |target|
123+
%i[_attributes _embedded _links].each do |target|
124124
return true if send(target).respond_to?(method, include_private)
125125
end
126126
false

test/hyperclient/collection_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Hyperclient
3232
name
3333
end
3434

35-
names.must_equal %w(_links title description permitted _hidden_attribute _embedded)
35+
names.must_equal %w[_links title description permitted _hidden_attribute _embedded]
3636
end
3737

3838
describe '#to_hash' do

test/hyperclient/entry_point_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ module Hyperclient
4545

4646
it 'raises a ConnectionAlreadyInitializedError if attempting to modify headers' do
4747
entry_point.connection.must_be_kind_of Faraday::Connection
48-
lambda { entry_point.headers = {} }.must_raise ConnectionAlreadyInitializedError
48+
-> { entry_point.headers = {} }.must_raise ConnectionAlreadyInitializedError
4949
end
5050

5151
it 'raises a ConnectionAlreadyInitializedError if attempting to modify the faraday block' do
5252
entry_point.connection.must_be_kind_of Faraday::Connection
53-
lambda { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
53+
-> { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
5454
end
5555
end
5656

test/hyperclient/link_test.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Hyperclient
77
EntryPoint.new('http://api.example.org/')
88
end
99

10-
%w(type deprecation name profile title hreflang).each do |prop|
10+
%w[type deprecation name profile title hreflang].each do |prop|
1111
describe prop do
1212
it 'returns the property value' do
1313
link = Link.new('key', { prop => 'value' }, entry_point)
@@ -39,7 +39,7 @@ module Hyperclient
3939
it 'returns a list of required variables' do
4040
link = Link.new('key', { 'href' => '/orders{?id,owner}', 'templated' => true }, entry_point)
4141

42-
link._variables.must_equal %w(id owner)
42+
link._variables.must_equal %w[id owner]
4343
end
4444

4545
it 'returns an empty array for untemplated links' do
@@ -161,7 +161,7 @@ module Hyperclient
161161
stub.get('http://api.example.org/productions/1') { [400, {}, nil] }
162162
end
163163

164-
lambda { link._get }.must_raise Faraday::ClientError
164+
-> { link._get }.must_raise Faraday::ClientError
165165
end
166166

167167
it 'executes requests asynchronously using futuroscope' do
@@ -531,7 +531,7 @@ module Hyperclient
531531
end
532532

533533
it 'raises an error when the method does not exist in the resource' do
534-
lambda { link.this_method_does_not_exist }.must_raise NoMethodError
534+
-> { link.this_method_does_not_exist }.must_raise NoMethodError
535535
end
536536

537537
it 'responds to missing methods' do

test/hyperclient/resource_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module Hyperclient
100100
resource._attributes.expects('respond_to?').with('foo').returns(false)
101101
resource._links.expects('respond_to?').with('foo').returns(false)
102102
resource._embedded.expects('respond_to?').with('foo').returns(false)
103-
lambda { resource.foo }.must_raise NoMethodError
103+
-> { resource.foo }.must_raise NoMethodError
104104
end
105105

106106
it 'delegates []' do

0 commit comments

Comments
 (0)