Merge pull request #2256 from dduugg/rubocop-todos

Complete rubocop todos
This commit is contained in:
André Luis Leal Cardoso Junior 2022-09-11 19:49:50 -03:00 committed by GitHub
commit e374c3a808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 35 deletions

View File

@ -33,12 +33,6 @@ Style/ClassAndModuleChildren:
Exclude: Exclude:
- 'spec/fixtures/example_nesting.rb' - 'spec/fixtures/example_nesting.rb'
# TODO: delete exclusions when we drop Ruby 1.9.3 support.
Style/ExpandPathArguments:
Exclude:
- 'lib/pry/commands.rb'
- 'pry.gemspec'
Style/Semicolon: Style/Semicolon:
Exclude: Exclude:
- 'spec/method_spec.rb' - 'spec/method_spec.rb'
@ -51,10 +45,6 @@ Style/SingleLineMethods:
Style/StringLiterals: Style/StringLiterals:
Enabled: false Enabled: false
# TODO: delete this rule when we drop Ruby 1.9.3 support.
Style/SymbolArray:
EnforcedStyle: brackets
Metrics/LineLength: Metrics/LineLength:
Max: 90 Max: 90

View File

@ -2,7 +2,7 @@
class Pry class Pry
class BasicObject < BasicObject class BasicObject < BasicObject
[:Kernel, :File, :Dir, :LoadError, :ENV, :Pry].each do |constant| %i[Kernel File Dir LoadError ENV Pry].each do |constant|
const_set constant, ::Object.const_get(constant) const_set constant, ::Object.const_get(constant)
end end
include Kernel include Kernel

View File

@ -4,8 +4,8 @@ class Pry
class Command class Command
class Ls < Pry::ClassCommand class Ls < Pry::ClassCommand
class Constants < Pry::Command::Ls::Formatter class Constants < Pry::Command::Ls::Formatter
DEPRECATED_CONSTANTS = [ DEPRECATED_CONSTANTS = %i[
:Data, :Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE Data Fixnum Bignum TimeoutError NIL FALSE TRUE
].tap do |constants| ].tap do |constants|
constants << :JavaPackageModuleTemplate if Helpers::Platform.jruby? constants << :JavaPackageModuleTemplate if Helpers::Platform.jruby?
end end

View File

@ -96,7 +96,7 @@ class Pry
end end
def add_hook def add_hook
hook = [:after_eval, :watch_expression] hook = %i[after_eval watch_expression]
return if pry_instance.hooks.hook_exists?(*hook) return if pry_instance.hooks.hook_exists?(*hook)
pry_instance.hooks.add_hook(*hook) do |_, pry_instance| pry_instance.hooks.add_hook(*hook) do |_, pry_instance|

View File

@ -57,8 +57,8 @@ class Pry
# #
# :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0 # :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0
# classifications of "true", "false", and "nil". # classifications of "true", "false", and "nil".
IGNORE_TOKENS = [:space, :content, :string, :method, :ident, IGNORE_TOKENS = %i[space content string method ident
:constant, :pre_constant, :predefined_constant].freeze constant pre_constant predefined_constant].freeze
# Tokens that indicate the end of a statement (i.e. that, if they appear # Tokens that indicate the end of a statement (i.e. that, if they appear
# directly before an "if" indicates that that if applies to the same line, # directly before an "if" indicates that that if applies to the same line,
@ -66,10 +66,10 @@ class Pry
# #
# :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively # :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively
# classifications of "super", "next", "return", etc. # classifications of "super", "next", "return", etc.
STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float, STATEMENT_END_TOKENS = IGNORE_TOKENS + %i[regexp integer float
:keyword, :delimiter, :reserved, keyword delimiter reserved
:instance_variable, instance_variable
:class_variable, :global_variable] class_variable global_variable]
# Collection of tokens that should appear dedented even though they # Collection of tokens that should appear dedented even though they
# don't affect the surrounding code. # don't affect the surrounding code.

View File

@ -270,7 +270,7 @@ class Pry
end end
# FIXME: Add Pry here as well? # FIXME: Add Pry here as well?
[:IRB, :SLex, :RubyLex, :RubyToken].each do |module_name| %i[IRB SLex RubyLex RubyToken].each do |module_name|
next unless Object.const_defined?(module_name) next unless Object.const_defined?(module_name)
scanner.call(Object.const_get(module_name)) scanner.call(Object.const_get(module_name))

View File

@ -20,9 +20,9 @@ class Pry
# Methods to delegate to associated `Pry::WrappedModule # Methods to delegate to associated `Pry::WrappedModule
# instance`. # instance`.
private_delegates = [:lines_for_file, :method_candidates, :yard_docs?, :name] private_delegates = %i[lines_for_file method_candidates yard_docs? name]
public_delegates = [:wrapped, :module?, :class?, :nonblank_name, public_delegates = %i[wrapped module? class? nonblank_name
:number_of_candidates] number_of_candidates]
def_delegators :@wrapper, *public_delegates def_delegators :@wrapper, *public_delegates
def_private_delegators :@wrapper, *private_delegates def_private_delegators :@wrapper, *private_delegates

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
require File.expand_path('../lib/pry/version', __FILE__) require File.expand_path('lib/pry/version', __dir__)
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "pry" s.name = "pry"

View File

@ -1151,7 +1151,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:BetaClass, :AlphaClass].each { |name| Object.remove_const(name) } %i[BetaClass AlphaClass].each { |name| Object.remove_const(name) }
end end
it "shows docs for the nested classes" do it "shows docs for the nested classes" do
@ -1176,7 +1176,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:BetaClass, :AlphaClass].each { |name| Object.remove_const(name) } %i[BetaClass AlphaClass].each { |name| Object.remove_const(name) }
end end
it "shows docs for the nested classes" do it "shows docs for the nested classes" do
@ -1386,7 +1386,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Child, :Parent].each { |name| Object.remove_const(name) } %i[Child Parent].each { |name| Object.remove_const(name) }
end end
it "shows the docs of the superclass" do it "shows the docs of the superclass" do
@ -1412,7 +1412,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Grandparent, :Child, :Parent].each { |name| Object.remove_const(name) } %i[Grandparent Child Parent].each { |name| Object.remove_const(name) }
end end
it "shows the docs of the superclass" do it "shows the docs of the superclass" do
@ -1437,7 +1437,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Child, :Parent].each { |name| Object.remove_const(name) } %i[Child Parent].each { |name| Object.remove_const(name) }
end end
it "raises Pry::CommandError" do it "raises Pry::CommandError" do
@ -1459,7 +1459,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Beta, :Alpha].each { |name| Object.remove_const(name) } %i[Beta Alpha].each { |name| Object.remove_const(name) }
end end
it "shows the included module's doc" do it "shows the included module's doc" do
@ -1486,7 +1486,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Beta, :Alpha].each { |name| Object.remove_const(name) } %i[Beta Alpha].each { |name| Object.remove_const(name) }
end end
it "raises Pry::CommandError" do it "raises Pry::CommandError" do
@ -1512,7 +1512,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Gamma, :Beta, :Alpha].each { |name| Object.remove_const(name) } %i[Gamma Beta Alpha].each { |name| Object.remove_const(name) }
end end
it "shows nth level included module doc" do it "shows nth level included module doc" do
@ -1550,7 +1550,7 @@ describe "show-source" do # rubocop:disable Metrics/BlockLength
end end
after do after do
[:Grandparent, :Parent, :Child].each { |name| Object.remove_const(name) } %i[Grandparent Parent Child].each { |name| Object.remove_const(name) }
end end
context "and when it's passed once" do context "and when it's passed once" do

View File

@ -13,7 +13,7 @@ RSpec.describe 'The bin/pry CLI' do
pry_dir, pry_dir,
'bin/pry', 'bin/pry',
*args, *args,
err: [:child, :out]], &:read) err: %i[child out]], &:read)
status = $CHILD_STATUS status = $CHILD_STATUS
# Pry will emit silent garbage because of our auto indent feature. # Pry will emit silent garbage because of our auto indent feature.