1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

rubocop: fix offences of the Layout/FirstParameterIndentation cop

This commit is contained in:
Kyrylo Silin 2019-02-25 00:31:59 +02:00
parent f0a6af8492
commit 970d0e1d57
5 changed files with 53 additions and 46 deletions

View file

@ -13,17 +13,6 @@ Gemspec/RequiredRubyVersion:
Exclude: Exclude:
- 'pry.gemspec' - 'pry.gemspec'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
Exclude:
- 'lib/pry/input_completer.rb'
- 'spec/command_spec.rb'
- 'spec/commands/ls_spec.rb'
- 'spec/method_spec.rb'
# Offense count: 3 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth. # Configuration parameters: EnforcedStyle, IndentationWidth.

View file

@ -188,10 +188,10 @@ class Pry::InputCompleter
select_message(path, receiver, message, candidates) select_message(path, receiver, message, candidates)
else else
candidates = eval( candidates = eval(
"methods | private_methods | local_variables | " \ "methods | private_methods | local_variables | " \
"self.class.constants | instance_variables", "self.class.constants | instance_variables",
bind bind
).collect(&:to_s) ).collect(&:to_s)
if eval("respond_to?(:class_variables)", bind) if eval("respond_to?(:class_variables)", bind)
candidates += eval("class_variables", bind).collect(&:to_s) candidates += eval("class_variables", bind).collect(&:to_s)

View file

@ -784,10 +784,10 @@ describe "Pry::Command" do
describe 'group' do describe 'group' do
before do before do
@set.import( @set.import(
Pry::CommandSet.new do Pry::CommandSet.new do
create_command("magic") { group("Not for a public use") } create_command("magic") { group("Not for a public use") }
end end
) )
end end
it 'should be correct for default commands' do it 'should be correct for default commands' do

View file

@ -20,13 +20,19 @@ describe "ls" do
end end
it "should include super-classes by default" do it "should include super-classes by default" do
expect(pry_eval( expect(
"cd Class.new(Class.new{ def goo; end; public :goo }).new", pry_eval(
"ls")).to match(/goo/) "cd Class.new(Class.new{ def goo; end; public :goo }).new",
"ls"
)
).to match(/goo/)
expect(pry_eval( expect(
"cd Class.new(Class.new{ def goo; end; public :goo })", pry_eval(
"ls -M")).to match(/goo/) "cd Class.new(Class.new{ def goo; end; public :goo })",
"ls -M"
)
).to match(/goo/)
end end
it "should not include super-classes when -q is given" do it "should not include super-classes when -q is given" do
@ -47,10 +53,12 @@ describe "ls" do
end end
it "should work on subclasses of BasicObject" do it "should work on subclasses of BasicObject" do
expect(pry_eval( expect(
"class LessBasic < BasicObject; def jaroussky; 5; end; end", pry_eval(
"ls LessBasic.new" "class LessBasic < BasicObject; def jaroussky; 5; end; end",
)).to match(/LessBasic#methods:.*jaroussky/m) "ls LessBasic.new"
)
).to match(/LessBasic#methods:.*jaroussky/m)
end end
end end
@ -127,6 +135,7 @@ describe "ls" do
expect(result).not_to match(/0x\d{5}/) expect(result).not_to match(/0x\d{5}/)
expect(result).to match(/asdf.*xyz/m) expect(result).to match(/asdf.*xyz/m)
end end
it 'should not list pry noise' do it 'should not list pry noise' do
expect(pry_eval('ls -l')).not_to match(/_(?:dir|file|ex|pry|out|in)_/) expect(pry_eval('ls -l')).not_to match(/_(?:dir|file|ex|pry|out|in)_/)
end end
@ -134,17 +143,23 @@ describe "ls" do
describe "when inside Modules" do describe "when inside Modules" do
it "should still work" do it "should still work" do
expect(pry_eval( expect(
"cd Module.new{ def foobie; end; public :foobie }", pry_eval(
"ls -M")).to match(/foobie/) "cd Module.new{ def foobie; end; public :foobie }",
"ls -M"
)
).to match(/foobie/)
end end
it "should work for ivars" do it "should work for ivars" do
expect(pry_eval( expect(
"module StigmaT1sm; def foobie; @@gharble = 456; end; end", pry_eval(
"Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie", "module StigmaT1sm; def foobie; @@gharble = 456; end; end",
"cd StigmaT1sm", "Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie",
"ls -i")).to match(/@@gharble/) "cd StigmaT1sm",
"ls -i"
)
).to match(/@@gharble/)
end end
it "should include instance methods by default" do it "should include instance methods by default" do
@ -184,11 +199,13 @@ describe "ls" do
end end
it "should show constants for an object's class regardless of mixins" do it "should show constants for an object's class regardless of mixins" do
expect(pry_eval( expect(
"cd Pry.new", pry_eval(
"extend Module.new", "cd Pry.new",
"ls -c" "extend Module.new",
)).to match(/Method/) "ls -c"
)
).to match(/Method/)
end end
end end

View file

@ -486,10 +486,11 @@ describe Pry::Method do
end end
it "should include the Pry::Method.instance_resolution_order of Class after the singleton classes" do it "should include the Pry::Method.instance_resolution_order of Class after the singleton classes" do
expect(Pry::Method.resolution_order(LS::Top)).to eq( singleton_classes = [
[eigen_class(LS::Top), eigen_class(Object), eigen_class(BasicObject), eigen_class(LS::Top), eigen_class(Object), eigen_class(BasicObject),
*Pry::Method.instance_resolution_order(Class)] *Pry::Method.instance_resolution_order(Class)
) ]
expect(Pry::Method.resolution_order(LS::Top)).to eq(singleton_classes)
end end
end end
end end