Skip to content

Commit

Permalink
Specify TargetRubyVersion: 2.7 in .rubocop.yml (#1544)
Browse files Browse the repository at this point in the history
Follow up #1454.

gemspec `required_ruby_version` requires 2.7 and higher, so specify
`TargetRubyVersion` to 2.7. Some syntax detected by updating to 2.7 applies.

It also removes `Gemspec/RequiredRubyVersion` cop from .rubocop_todo.yml to
enable the cop so that version mismatch can be detected.
  • Loading branch information
koic authored Feb 27, 2023
1 parent 3ec233f commit d48eaff
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.7
NewCops: enable
Metrics/BlockLength:
AllowedMethods: ['describe', 'context']
Expand Down
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'octokit.gemspec'

# Offense count: 13
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Expand Down
18 changes: 8 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ task test: :spec
task default: :spec

namespace :doc do
begin
require 'yard'
YARD::Rake::YardocTask.new do |task|
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
task.options = [
'--output-dir', 'doc/yard',
'--markup', 'markdown'
]
end
rescue LoadError
require 'yard'
YARD::Rake::YardocTask.new do |task|
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
task.options = [
'--output-dir', 'doc/yard',
'--markup', 'markdown'
]
end
rescue LoadError
end
4 changes: 2 additions & 2 deletions lib/octokit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ def inspect
inspected.gsub! @bearer_token, '********' if @bearer_token
# Only show last 4 of token, secret
if @access_token
inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..-1]}"
inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..]}"
end
if @client_secret
inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..-1]}"
inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..]}"
end

inspected
Expand Down
2 changes: 1 addition & 1 deletion lib/octokit/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def netrc?
private

def options
Octokit::Configurable.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }.to_h
Octokit::Configurable.keys.to_h { |key| [key, instance_variable_get(:"@#{key}")] }
end

def fetch_client_id_and_secret(overrides = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/octokit/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class << self
# Configuration options
# @return [Hash]
def options
Octokit::Configurable.keys.map { |key| [key, send(key)] }.to_h
Octokit::Configurable.keys.to_h { |key| [key, send(key)] }
end

# Default access token from ENV
Expand Down
2 changes: 1 addition & 1 deletion lib/octokit/gist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Gist
# Instantiate {Gist} object from Gist URL
# @ return [Gist]
def self.from_url(url)
Gist.new(URI.parse(url).path[1..-1])
Gist.new(URI.parse(url).path[1..])
end

def initialize(gist)
Expand Down
2 changes: 1 addition & 1 deletion lib/octokit/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Repository
#
# @return [Repository]
def self.from_url(url)
new URI.parse(url).path[1..-1]
new URI.parse(url).path[1..]
.gsub(%r{^repos/}, '')
.split('/', 3)[0..1]
.join('/')
Expand Down
18 changes: 6 additions & 12 deletions spec/octokit/client/actions_secrets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ def create_box(public_key)
end

after(:each) do
begin
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end

describe '.get_public_key', :vcr do
Expand All @@ -45,10 +43,8 @@ def create_box(public_key)
end

after(:each) do
begin
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end

describe '.list_secrets', :vcr do
Expand Down Expand Up @@ -86,10 +82,8 @@ def create_box(public_key)
end

after(:each) do
begin
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name) unless @repo.nil?
rescue Octokit::NotFound
end

describe '.list_secrets', :vcr do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/deployments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
end

after(:each) do
begin
@client.delete_ref(@test_repo, "heads/#{@branch_name}")
rescue Octokit::UnprocessableEntity
end
@client.delete_ref(@test_repo, "heads/#{@branch_name}")
rescue Octokit::UnprocessableEntity
end

describe '.create_deployment' do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/hooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

describe '.hooks', :vcr do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

describe '.create_issue', :vcr do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/reactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

context 'with commit comment' do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@
end

after(:each) do
begin
@client.delete_ref(@test_repo, 'heads/testing/test-ref')
rescue Octokit::UnprocessableEntity
end
@client.delete_ref(@test_repo, 'heads/testing/test-ref')
rescue Octokit::UnprocessableEntity
end

describe '.create_ref' do
Expand Down
19 changes: 7 additions & 12 deletions spec/octokit/client/repositories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

describe '.create_repository_from_template', :vcr do
Expand Down Expand Up @@ -403,10 +401,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

describe '.permission_level', :vcr do
Expand Down Expand Up @@ -568,10 +564,9 @@

after do
# cleanup
begin
@client.delete_repository("#{test_github_org}/#{@repository.name}")
rescue Octokit::NotFound
end

@client.delete_repository("#{test_github_org}/#{@repository.name}")
rescue Octokit::NotFound
end

it 'repository transfer from myself to my organization' do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/repository_invitations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.id)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.id)
rescue Octokit::NotFound
end

describe '.invite_user_to_repository', :vcr do
Expand Down
6 changes: 2 additions & 4 deletions spec/octokit/client/source_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
end

after(:each) do
begin
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end
@client.delete_repository(@repo.full_name)
rescue Octokit::NotFound
end

describe 'pre deprecation' do
Expand Down

0 comments on commit d48eaff

Please sign in to comment.