Skip to content

Commit

Permalink
Complete Style/SymbolArray todo
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Sep 11, 2022
1 parent 43c2d3c commit 0e06fc6
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 28 deletions.
4 changes: 0 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ Style/SingleLineMethods:
Style/StringLiterals:
Enabled: false

# TODO: delete this rule when we drop Ruby 1.9.3 support.
Style/SymbolArray:
EnforcedStyle: brackets

Metrics/LineLength:
Max: 90

Expand Down
2 changes: 1 addition & 1 deletion lib/pry/basic_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Pry
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)
end
include Kernel
Expand Down
4 changes: 2 additions & 2 deletions lib/pry/commands/ls/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Pry
class Command
class Ls < Pry::ClassCommand
class Constants < Pry::Command::Ls::Formatter
DEPRECATED_CONSTANTS = [
:Data, :Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE
DEPRECATED_CONSTANTS = %i[
Data Fixnum Bignum TimeoutError NIL FALSE TRUE
].tap do |constants|
constants << :JavaPackageModuleTemplate if Helpers::Platform.jruby?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/commands/watch_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def add_expression(_arguments)
end

def add_hook
hook = [:after_eval, :watch_expression]
hook = %i[after_eval watch_expression]
return if pry_instance.hooks.hook_exists?(*hook)

pry_instance.hooks.add_hook(*hook) do |_, pry_instance|
Expand Down
12 changes: 6 additions & 6 deletions lib/pry/indent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ class UnparseableNestingError < StandardError; end
#
# :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0
# classifications of "true", "false", and "nil".
IGNORE_TOKENS = [:space, :content, :string, :method, :ident,
:constant, :pre_constant, :predefined_constant].freeze
IGNORE_TOKENS = %i[space content string method ident
constant pre_constant predefined_constant].freeze

# 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,
# not the next line)
#
# :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively
# classifications of "super", "next", "return", etc.
STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float,
:keyword, :delimiter, :reserved,
:instance_variable,
:class_variable, :global_variable]
STATEMENT_END_TOKENS = IGNORE_TOKENS + %i[regexp integer float
keyword delimiter reserved
instance_variable
class_variable global_variable]

# Collection of tokens that should appear dedented even though they
# don't affect the surrounding code.
Expand Down
2 changes: 1 addition & 1 deletion lib/pry/input_completer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def ignored_modules
end

# 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)

scanner.call(Object.const_get(module_name))
Expand Down
6 changes: 3 additions & 3 deletions lib/pry/wrapped_module/candidate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Candidate

# Methods to delegate to associated `Pry::WrappedModule
# instance`.
private_delegates = [:lines_for_file, :method_candidates, :yard_docs?, :name]
public_delegates = [:wrapped, :module?, :class?, :nonblank_name,
:number_of_candidates]
private_delegates = %i[lines_for_file method_candidates yard_docs? name]
public_delegates = %i[wrapped module? class? nonblank_name
number_of_candidates]

def_delegators :@wrapper, *public_delegates
def_private_delegators :@wrapper, *private_delegates
Expand Down
18 changes: 9 additions & 9 deletions spec/commands/show_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def beta; end
end

after do
[:BetaClass, :AlphaClass].each { |name| Object.remove_const(name) }
%i[BetaClass AlphaClass].each { |name| Object.remove_const(name) }
end

it "shows docs for the nested classes" do
Expand All @@ -1176,7 +1176,7 @@ def beta; end
end

after do
[:BetaClass, :AlphaClass].each { |name| Object.remove_const(name) }
%i[BetaClass AlphaClass].each { |name| Object.remove_const(name) }
end

it "shows docs for the nested classes" do
Expand Down Expand Up @@ -1386,7 +1386,7 @@ class Child < Parent; end
end

after do
[:Child, :Parent].each { |name| Object.remove_const(name) }
%i[Child Parent].each { |name| Object.remove_const(name) }
end

it "shows the docs of the superclass" do
Expand All @@ -1412,7 +1412,7 @@ class Child < Parent; end
end

after do
[:Grandparent, :Child, :Parent].each { |name| Object.remove_const(name) }
%i[Grandparent Child Parent].each { |name| Object.remove_const(name) }
end

it "shows the docs of the superclass" do
Expand All @@ -1437,7 +1437,7 @@ class Child < Parent; end
end

after do
[:Child, :Parent].each { |name| Object.remove_const(name) }
%i[Child Parent].each { |name| Object.remove_const(name) }
end

it "raises Pry::CommandError" do
Expand All @@ -1459,7 +1459,7 @@ module Beta
end

after do
[:Beta, :Alpha].each { |name| Object.remove_const(name) }
%i[Beta Alpha].each { |name| Object.remove_const(name) }
end

it "shows the included module's doc" do
Expand All @@ -1486,7 +1486,7 @@ module Beta
end

after do
[:Beta, :Alpha].each { |name| Object.remove_const(name) }
%i[Beta Alpha].each { |name| Object.remove_const(name) }
end

it "raises Pry::CommandError" do
Expand All @@ -1512,7 +1512,7 @@ module Gamma
end

after do
[:Gamma, :Beta, :Alpha].each { |name| Object.remove_const(name) }
%i[Gamma Beta Alpha].each { |name| Object.remove_const(name) }
end

it "shows nth level included module doc" do
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def @obj.initialize; end
end

after do
[:Grandparent, :Parent, :Child].each { |name| Object.remove_const(name) }
%i[Grandparent Parent Child].each { |name| Object.remove_const(name) }
end

context "and when it's passed once" do
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
pry_dir,
'bin/pry',
*args,
err: [:child, :out]], &:read)
err: %i[child out]], &:read)
status = $CHILD_STATUS

# Pry will emit silent garbage because of our auto indent feature.
Expand Down

0 comments on commit 0e06fc6

Please sign in to comment.