Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Rubocop 0.50.0 (fixes CVE-2017-8418) #131

Merged
merged 1 commit into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.2

Metrics/BlockLength:
ExcludedMethods: [it, describe]
27 changes: 2 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-08-26 18:01:43 +0100 using RuboCop version 0.42.0.
# on 2017-10-01 22:20:54 +0300 using RuboCop version 0.50.0.
# 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
Expand All @@ -12,7 +12,7 @@ Metrics/ClassLength:
Max: 110

# Offense count: 97
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 142
Expand All @@ -27,11 +27,6 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Max: 398

# Offense count: 1
Style/AsciiComments:
Exclude:
- 'lib/hyperclient/collection.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Expand All @@ -56,25 +51,7 @@ Style/DoubleNegation:
- 'lib/hyperclient/curie.rb'
- 'lib/hyperclient/link.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'test/hyperclient/entry_point_test.rb'
- 'test/hyperclient/link_test.rb'
- 'test/hyperclient/resource_test.rb'

# Offense count: 1
Style/MethodMissing:
Exclude:
- 'lib/hyperclient/collection.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'features/support/api.rb'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.8.7 (Next)

* [#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).
* Your contribution here.

### 0.8.6 (August 27, 2017)
Expand Down
15 changes: 9 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# NOTE: this is temporary until Bundler 2.0 changes how github: references work.
git_source(:github) { |repo| "https://github.com/#{repo['/'] ? repo : "#{repo}/#{repo}"}.git" }

source 'https://rubygems.org'

gemspec
Expand All @@ -12,20 +15,20 @@ group :development do
end

group :development, :test do
gem 'yard', '~> 0.8'
gem 'yard-tomdoc'
gem 'rake'
gem 'rubocop', '~> 0.50.0', require: false
gem 'simplecov', require: false
gem 'rubocop', '~> 0.42.0', require: false
gem 'yard', '~> 0.8'
gem 'yard-tomdoc'
end

group :test do
gem 'futuroscope', github: 'codegram/futuroscope'
gem 'danger-changelog', '~> 0.1'
gem 'futuroscope', github: 'codegram/futuroscope'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a reference into the HEAD of futuroscope? I suspect not and i would kill the whole git_source thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the latest released futuroscope version on Rubygems is 0.1.11 from February 23, 2014. And there's a bunch of commits in master since then, including Futuroscope::Pools::NoPool implementation which is used in hyperclient test suite.

gem 'minitest'
gem 'turn'
gem 'webmock'
gem 'mocha'
gem 'rack-test'
gem 'spinach'
gem 'turn'
gem 'webmock'
end
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require 'yard'
YARD::Config.load_plugin('yard-tomdoc')
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb']
t.options = %w(-r README.md)
t.options = %w[-r README.md]
end

require 'rake/testtask'
Expand All @@ -38,4 +38,4 @@ end
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

task default: [:test, :spinach, :rubocop]
task default: %i[test spinach rubocop]
2 changes: 1 addition & 1 deletion features/steps/api_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Spinach::Features::ApiNavigation < Spinach::FeatureSteps
end

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

step 'the API should receive the request for posts by tag with all the params' do
Expand Down
2 changes: 1 addition & 1 deletion features/support/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module API
before do
WebMock::Config.instance.query_values_notation = :flat_array

stub_request(:any, %r{api.example.org*}).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:any, /api.example.org*/).to_return(body: root_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts').to_return(body: posts_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/posts/1').to_return(body: post_response, headers: { 'Content-Type' => 'application/hal+json' })
stub_request(:get, 'api.example.org/page2').to_return(body: page2_response, headers: { 'Content-Type' => 'application/hal+json' })
Expand Down
2 changes: 1 addition & 1 deletion hyperclient.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-

require File.expand_path('../lib/hyperclient/version', __FILE__)

Gem::Specification.new do |gem|
Expand Down
2 changes: 1 addition & 1 deletion lib/hyperclient/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def include?(key)
end

# Public: Returns a value from the collection for the given key.
# If the key cant be found, there are several options:
# If the key can't be found, there are several options:
# With no other arguments, it will raise an KeyError exception;
# if default is given, then that will be returned;
#
Expand Down
4 changes: 2 additions & 2 deletions lib/hyperclient/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def method_missing(method, *args, &block)
if args.any? && args.first.is_a?(Hash)
_links.send(method, [], &block)._expand(*args)
elsif !Array.method_defined?(method)
[:_attributes, :_embedded, :_links].each do |target|
%i[_attributes _embedded _links].each do |target|
target = send(target)
return target.send(method, *args, &block) if target.respond_to?(method.to_s)
end
Expand All @@ -120,7 +120,7 @@ def method_missing(method, *args, &block)
# Internal: Accessory method to allow the resource respond to
# methods that will hit method_missing.
def respond_to_missing?(method, include_private = false)
[:_attributes, :_embedded, :_links].each do |target|
%i[_attributes _embedded _links].each do |target|
return true if send(target).respond_to?(method, include_private)
end
false
Expand Down
2 changes: 1 addition & 1 deletion test/hyperclient/collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Hyperclient
name
end

names.must_equal %w(_links title description permitted _hidden_attribute _embedded)
names.must_equal %w[_links title description permitted _hidden_attribute _embedded]
end

describe '#to_hash' do
Expand Down
4 changes: 2 additions & 2 deletions test/hyperclient/entry_point_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ module Hyperclient

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

it 'raises a ConnectionAlreadyInitializedError if attempting to modify the faraday block' do
entry_point.connection.must_be_kind_of Faraday::Connection
lambda { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
-> { entry_point.connection {} }.must_raise ConnectionAlreadyInitializedError
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/hyperclient/link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Hyperclient
EntryPoint.new('http://api.example.org/')
end

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

link._variables.must_equal %w(id owner)
link._variables.must_equal %w[id owner]
end

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

lambda { link._get }.must_raise Faraday::ClientError
-> { link._get }.must_raise Faraday::ClientError
end

it 'executes requests asynchronously using futuroscope' do
Expand Down Expand Up @@ -531,7 +531,7 @@ module Hyperclient
end

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

it 'responds to missing methods' do
Expand Down
2 changes: 1 addition & 1 deletion test/hyperclient/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Hyperclient
resource._attributes.expects('respond_to?').with('foo').returns(false)
resource._links.expects('respond_to?').with('foo').returns(false)
resource._embedded.expects('respond_to?').with('foo').returns(false)
lambda { resource.foo }.must_raise NoMethodError
-> { resource.foo }.must_raise NoMethodError
end

it 'delegates []' do
Expand Down