Skip to content

Commit 42e1ce2

Browse files
committed
Update rubocop
1 parent f27615d commit 42e1ce2

25 files changed

+98
-48
lines changed

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
pull_request:
9+
10+
jobs:
11+
rubocop:
12+
runs-on: ubuntu-latest
13+
env:
14+
BUNDLE_GEMFILE: 'gemfiles/rubocop.gemfile'
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: '3.0'
21+
bundler-cache: true
22+
- name: Lint Ruby code with Rubocop
23+
run: bundle exec rubocop

.rubocop.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
AllCops:
2-
TargetRubyVersion: 2.3
2+
TargetRubyVersion: 2.4
3+
NewCops: disable
4+
SuggestExtensions: false
35
Exclude:
46
- 'bin/**/*'
5-
- 'db/**/*'
6-
- 'config/**/*'
7-
- 'script/**/*'
7+
- 'tmp/**/*'
8+
- 'vendor/**/*'
89

9-
Style/AlignParameters:
10+
Layout/ArgumentAlignment:
1011
EnforcedStyle: with_fixed_indentation
1112

12-
Style/CaseIndentation:
13-
IndentWhenRelativeTo: end
13+
Layout/CaseIndentation:
14+
EnforcedStyle: end
1415

1516
Style/AsciiComments:
1617
Enabled: false
1718

18-
Style/IndentHash:
19-
Enabled: false
20-
2119
Style/CollectionMethods:
2220
Enabled: true
2321
PreferredMethods:
@@ -30,17 +28,13 @@ Style/BlockDelimiters:
3028
Exclude:
3129
- spec/**/*_spec.rb
3230

33-
Style/BracesAroundHashParameters:
34-
Exclude:
35-
- spec/**/*_spec.rb
36-
3731
Style/GuardClause:
3832
Enabled: false
3933

4034
Style/IfUnlessModifier:
4135
Enabled: false
4236

43-
Style/SpaceInsideHashLiteralBraces:
37+
Layout/SpaceInsideHashLiteralBraces:
4438
Enabled: false
4539

4640
Style/Lambda:
@@ -61,7 +55,10 @@ Metrics/ClassLength:
6155
Metrics/ModuleLength:
6256
Enabled: false
6357

64-
Metrics/LineLength:
58+
Layout/LineLength:
59+
Enabled: false
60+
61+
Metrics/BlockLength:
6562
Enabled: false
6663

6764
Metrics/MethodLength:
@@ -70,13 +67,13 @@ Metrics/MethodLength:
7067
Style/SingleLineBlockParams:
7168
Enabled: false
7269

73-
Lint/EndAlignment:
74-
AlignWith: variable
70+
Layout/EndAlignment:
71+
EnforcedStyleAlignWith: variable
7572

7673
Style/FormatString:
7774
Enabled: false
7875

79-
Style/MultilineOperationIndentation:
76+
Layout/MultilineOperationIndentation:
8077
EnforcedStyle: indented
8178

8279
Style/WordArray:
@@ -95,6 +92,9 @@ Style/FrozenStringLiteralComment:
9592
Style/TrivialAccessors:
9693
AllowPredicates: true
9794

98-
Style/FileName:
95+
Style/NumericPredicate:
96+
Enabled: false
97+
98+
Naming/FileName:
9999
Exclude:
100100
- lib/faraday-http-cache.rb

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ elsif ENV['FARADAY_ADAPTER'] == 'em_http'
1212
gem 'faraday-em_http'
1313
end
1414

15+
gem 'activesupport', '>= 5.0'
1516
gem 'em-http-request', '~> 1.1'
16-
gem 'rspec', '~> 3.1'
1717
gem 'rake', '~> 13.0'
18-
gem 'activesupport', '>= 5.0'
18+
gem 'rspec', '~> 3.1'
1919
gem 'sinatra', '~> 2.0'
20+
21+
eval_gemfile 'gemfiles/rubocop.gemfile'

Rakefile

100644100755
File mode changed.

examples/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require 'active_support/logger'
66

77
client = Faraday.new('https://api.github.com') do |stack|
8-
stack.use :http_cache, logger: ActiveSupport::Logger.new(STDOUT)
8+
stack.use :http_cache, logger: ActiveSupport::Logger.new($stdout)
99
stack.adapter Faraday.default_adapter
1010
end
1111

examples/parallel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require 'em-http-request'
77

88
client = Faraday.new('https://api.github.com') do |stack|
9-
stack.use :http_cache, logger: ActiveSupport::Logger.new(STDOUT)
9+
stack.use :http_cache, logger: ActiveSupport::Logger.new($stdout)
1010
stack.adapter :em_http
1111
end
1212

faraday-http-cache.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
Gem::Specification.new do |gem|
34
gem.name = 'faraday-http-cache'
45
gem.version = '2.2.0'
@@ -14,6 +15,6 @@ Gem::Specification.new do |gem|
1415
gem.require_paths = ['lib']
1516
gem.executables = []
1617

17-
gem.required_ruby_version = '>= 2.4.0'
18+
gem.required_ruby_version = '>= 2.1.0' # rubocop:disable Gemspec/RequiredRubyVersion
1819
gem.add_dependency 'faraday', '>= 0.8'
1920
end

gemfiles/rubocop.gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'rubocop', '~> 1.12.0'

lib/faraday/http_cache.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
require 'faraday'
34

45
require 'faraday/http_cache/storage'
@@ -44,7 +45,7 @@ module Faraday
4445
# builder.use :http_cache, store: Rails.cache, instrumenter: ActiveSupport::Notifications
4546
# end
4647
class HttpCache < Faraday::Middleware
47-
UNSAFE_METHODS = [:post, :put, :delete, :patch].freeze
48+
UNSAFE_METHODS = %i[post put delete patch].freeze
4849

4950
ERROR_STATUSES = (400..499).freeze
5051

@@ -71,7 +72,7 @@ class HttpCache < Faraday::Middleware
7172
:uncacheable,
7273

7374
# The request was cached but need to be revalidated by the server.
74-
:must_revalidate,
75+
:must_revalidate
7576
].freeze
7677

7778
# Public: Initializes a new HttpCache middleware.
@@ -263,7 +264,7 @@ def store(response)
263264
end
264265

265266
def delete(request, response)
266-
headers = %w(Location Content-Location)
267+
headers = %w[Location Content-Location]
267268
headers.each do |header|
268269
url = response.headers[header]
269270
@storage.delete(url) if url

lib/faraday/http_cache/cache_control.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
module Faraday
34
class HttpCache < Faraday::Middleware
45
# Internal: A class to represent the 'Cache-Control' header options.

0 commit comments

Comments
 (0)