Skip to content

Commit 0b054ff

Browse files
committed
Expand single-letter variable names for better readability
1 parent ee577ea commit 0b054ff

File tree

4 files changed

+56
-56
lines changed

4 files changed

+56
-56
lines changed

lib/rdoc/parser.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ def self.alias_extension(old_ext, new_ext)
7474
def self.binary?(file)
7575
return false if file =~ /\.(rdoc|txt)$/
7676

77-
s = File.read(file, 1024) or return false
77+
string = File.read(file, 1024) or return false
7878

79-
return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")
79+
return true if string[0, 2] == Marshal.dump('')[0, 2] or string.index("\x00")
8080

8181
mode = 'r:utf-8' # default source encoding has been changed to utf-8
82-
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
83-
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
82+
string.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
83+
encoding = string[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
8484
mode = "rb:#{encoding}" if encoding
85-
s = File.open(file, mode) {|f| f.gets(nil, 1024)}
85+
string = File.open(file, mode) {|f| f.gets(nil, 1024)}
8686

87-
not s.valid_encoding?
87+
!string.valid_encoding?
8888
end
8989

9090
##

lib/rdoc/parser/prism_ruby.rb

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ def handle_meta_method_comment(comment, node)
289289

290290
if attributes
291291
attributes.each do |attr|
292-
a = RDoc::Attr.new(@container, attr, rw, processed_comment, singleton: @singleton)
293-
a.store = @store
294-
a.line = line_no
295-
record_location(a)
296-
@container.add_attribute(a)
297-
a.visibility = visibility
292+
attr_obj = RDoc::Attr.new(@container, attr, rw, processed_comment, singleton: @singleton)
293+
attr_obj.store = @store
294+
attr_obj.line = line_no
295+
record_location(attr_obj)
296+
@container.add_attribute(attr_obj)
297+
attr_obj.visibility = visibility
298298
end
299299
elsif line_no || node
300300
method_name ||= call_node_name_arguments(node).first if is_call_node
@@ -401,13 +401,13 @@ def visible_tokens_from_location(location)
401401

402402
def change_method_visibility(names, visibility, singleton: @singleton)
403403
new_methods = []
404-
@container.methods_matching(names, singleton) do |m|
405-
if m.parent != @container
406-
m = m.dup
407-
record_location(m)
408-
new_methods << m
404+
@container.methods_matching(names, singleton) do |method|
405+
if method.parent != @container
406+
method = method.dup
407+
record_location(method)
408+
new_methods << method
409409
else
410-
m.visibility = visibility
410+
method.visibility = visibility
411411
end
412412
end
413413
new_methods.each do |method|
@@ -449,13 +449,13 @@ def add_alias_method(old_name, new_name, line_no)
449449
comment = consecutive_comment(line_no)
450450
handle_consecutive_comment_directive(@container, comment)
451451
visibility = @container.find_method(old_name, @singleton)&.visibility || :public
452-
a = RDoc::Alias.new(nil, old_name, new_name, comment, singleton: @singleton)
453-
handle_modifier_directive(a, line_no)
454-
a.store = @store
455-
a.line = line_no
456-
record_location(a)
457-
if should_document?(a)
458-
@container.add_alias(a)
452+
alias_obj = RDoc::Alias.new(nil, old_name, new_name, comment, singleton: @singleton)
453+
handle_modifier_directive(alias_obj, line_no)
454+
alias_obj.store = @store
455+
alias_obj.line = line_no
456+
record_location(alias_obj)
457+
if should_document?(alias_obj)
458+
@container.add_alias(alias_obj)
459459
@container.find_method(new_name, @singleton)&.visibility = visibility
460460
end
461461
end
@@ -468,13 +468,13 @@ def add_attributes(names, rw, line_no)
468468
return unless @container.document_children
469469

470470
names.each do |symbol|
471-
a = RDoc::Attr.new(nil, symbol.to_s, rw, comment, singleton: @singleton)
472-
a.store = @store
473-
a.line = line_no
474-
record_location(a)
475-
handle_modifier_directive(a, line_no)
476-
@container.add_attribute(a) if should_document?(a)
477-
a.visibility = visibility # should set after adding to container
471+
attr_obj = RDoc::Attr.new(nil, symbol.to_s, rw, comment, singleton: @singleton)
472+
attr_obj.store = @store
473+
attr_obj.line = line_no
474+
record_location(attr_obj)
475+
handle_modifier_directive(attr_obj, line_no)
476+
@container.add_attribute(attr_obj) if should_document?(attr_obj)
477+
attr_obj.visibility = visibility # should set after adding to container
478478
end
479479
end
480480

@@ -483,11 +483,11 @@ def add_includes_extends(names, rdoc_class, line_no) # :nodoc:
483483
comment = consecutive_comment(line_no)
484484
handle_consecutive_comment_directive(@container, comment)
485485
names.each do |name|
486-
ie = @container.add(rdoc_class, name, '')
487-
ie.store = @store
488-
ie.line = line_no
489-
ie.comment = comment
490-
record_location(ie)
486+
include_extend_obj = @container.add(rdoc_class, name, '')
487+
include_extend_obj.store = @store
488+
include_extend_obj.line = line_no
489+
include_extend_obj.comment = comment
490+
record_location(include_extend_obj)
491491
end
492492
end
493493

@@ -652,10 +652,10 @@ def add_constant(constant_name, rhs_name, start_line, end_line)
652652
@container.find_module_named(rhs_name)
653653
end
654654
if mod && constant.document_self
655-
a = @container.add_module_alias(mod, rhs_name, constant, @top_level)
656-
a.store = @store
657-
a.line = start_line
658-
record_location(a)
655+
module_alias = @container.add_module_alias(mod, rhs_name, constant, @top_level)
656+
module_alias.store = @store
657+
module_alias.line = start_line
658+
record_location(module_alias)
659659
end
660660
end
661661

lib/rdoc/parser/ruby.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ def get_class_or_module container, ignore_constants = false
368368
container = container.find_module_named name_t[:text]
369369
container ||=
370370
if ignore_constants then
371-
c = RDoc::NormalModule.new name_t[:text]
372-
c.store = @store
373-
new_modules << [prev_container, c]
374-
c
371+
module_obj = RDoc::NormalModule.new name_t[:text]
372+
module_obj.store = @store
373+
new_modules << [prev_container, module_obj]
374+
module_obj
375375
else
376-
c = prev_container.add_module RDoc::NormalModule, name_t[:text]
377-
c.ignore unless prev_container.document_children
378-
@top_level.add_to_classes_or_modules c
379-
c
376+
module_obj = prev_container.add_module RDoc::NormalModule, name_t[:text]
377+
module_obj.ignore unless prev_container.document_children
378+
@top_level.add_to_classes_or_modules module_obj
379+
module_obj
380380
end
381381

382382
record_location container
@@ -700,10 +700,10 @@ def make_message message
700700
# Creates a comment with the correct format
701701

702702
def new_comment comment, line_no = nil
703-
c = RDoc::Comment.new comment, @top_level, :ruby
704-
c.line = line_no
705-
c.format = @markup
706-
c
703+
comment_obj = RDoc::Comment.new comment, @top_level, :ruby
704+
comment_obj.line = line_no
705+
comment_obj.format = @markup
706+
comment_obj
707707
end
708708

709709
##

lib/rdoc/ri/driver.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,9 @@ def complete_method name, klass, selector, completions # :nodoc:
806806

807807
def display document
808808
page do |io|
809-
f = formatter(io)
810-
f.width = @width if @width and f.respond_to?(:width)
811-
text = document.accept f
809+
formatter = formatter(io)
810+
formatter.width = @width if @width and formatter.respond_to?(:width)
811+
text = document.accept formatter
812812

813813
io.write text
814814
end

0 commit comments

Comments
 (0)