Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ Lint/UnreachableCode:

Style/MethodDefParentheses:
Enabled: true

Style/MultilineIfThen:
Enabled: true

Style/MultilineWhenThen:
Enabled: true

Style/MultilineInPatternThen:
Enabled: true
4 changes: 2 additions & 2 deletions exe/rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ rescue Errno::ENOSPC
rescue SystemExit
raise
rescue Exception => e
if $DEBUG_RDOC then
if $DEBUG_RDOC
$stderr.puts e.message
$stderr.puts "#{e.backtrace.join "\n\t"}"
$stderr.puts
elsif Interrupt === e then
elsif Interrupt === e
$stderr.puts
$stderr.puts 'Interrupted'
else
Expand Down
8 changes: 4 additions & 4 deletions lib/rdoc/code_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def comment=(comment)
when NilClass then ''
when RDoc::Comment then comment.normalize
else
if comment and not comment.empty? then
if comment and not comment.empty?
normalize_comment comment
else
# HACK correct fix is to have #initialize create @comment
# with the correct encoding
if String === @comment and @comment.empty? then
if String === @comment and @comment.empty?
@comment = RDoc::Encoding.change_encoding @comment, comment.encoding
end
@comment
Expand Down Expand Up @@ -289,7 +289,7 @@ def parent
return @parent if @parent
return nil unless @parent_name

if @parent_class == RDoc::TopLevel then
if @parent_class == RDoc::TopLevel
@parent = @store.add_file @parent_name
else
@parent = @store.find_class_or_module @parent_name
Expand Down Expand Up @@ -361,7 +361,7 @@ def store=(store)

return unless @track_visibility

if :nodoc == options.visibility then
if :nodoc == options.visibility
initialize_visibility
@track_visibility = false
end
Expand Down
26 changes: 13 additions & 13 deletions lib/rdoc/code_object/any_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def aref_prefix
# Use this for displaying a method's argument lists.

def arglists
if @call_seq then
if @call_seq
@call_seq
elsif @params then
elsif @params
"#{name}#{param_seq}"
end
end
Expand Down Expand Up @@ -126,9 +126,9 @@ def has_call_seq?

def is_alias_for # :nodoc:
case @is_alias_for
when RDoc::MethodAttr then
when RDoc::MethodAttr
@is_alias_for
when Array then
when Array
return nil unless @store

klass_name, singleton, method_name = @is_alias_for
Expand Down Expand Up @@ -214,7 +214,7 @@ def marshal_load(array)
add_alias RDoc::Alias.new(@name, new_name, RDoc::Comment.from_document(document), singleton: @singleton)
end

@parent_name ||= if @full_name =~ /#/ then
@parent_name ||= if @full_name =~ /#/
$`
else
name = @full_name.split('::')
Expand Down Expand Up @@ -244,21 +244,21 @@ def name
# are preferred over parsed method and block params.

def param_list
if @call_seq then
if @call_seq
params = @call_seq.split("\n").last
params = params.sub(/.*?\((.*)\)/, '\1')
params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
elsif @params then
elsif @params
params = @params.sub(/\((.*)\)/, '\1')

params << ",#{@block_params}" if @block_params
elsif @block_params then
elsif @block_params
params = @block_params
else
return []
end

if @block_params then
if @block_params
# If this method has explicit block parameters, remove any explicit
# &block
params = params.sub(/,?\s*&\w+/, '')
Expand All @@ -276,19 +276,19 @@ def param_list
# given by +call-seq+ it is preferred over the parsed values.

def param_seq
if @call_seq then
if @call_seq
params = @call_seq.split("\n").last
params = params.sub(/[^( ]+/, '')
params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
elsif @params then
elsif @params
params = @params.gsub(/\s*\#.*/, '')
params = params.tr_s("\n ", " ")
params = "(#{params})" unless params[0] == ?(
else
params = ''
end

if @block_params then
if @block_params
# If this method has explicit block parameters, remove any explicit
# &block
params = params.sub(/,?\s*&\w+/, '')
Expand Down Expand Up @@ -328,7 +328,7 @@ def superclass_method
return @superclass_method if @superclass_method

parent.each_ancestor do |ancestor|
if method = ancestor.method_list.find { |m| m.name == @name } then
if method = ancestor.method_list.find { |m| m.name == @name }
@superclass_method = method
break
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/code_object/attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def marshal_load(array)

def pretty_print(q) # :nodoc:
q.group 2, "[#{self.class.name} #{full_name} #{rw} #{visibility}", "]" do
unless comment.empty? then
unless comment.empty?
q.breakable
q.text "comment:"
q.breakable
Expand Down
36 changes: 18 additions & 18 deletions lib/rdoc/code_object/class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def add_comment(comment, location)
original = comment

comment = case comment
when RDoc::Comment then
when RDoc::Comment
comment.normalize
else
normalize_comment comment
Expand Down Expand Up @@ -229,7 +229,7 @@ def clear_comment

def comment=(comment) # :nodoc:
comment = case comment
when RDoc::Comment then
when RDoc::Comment
comment.normalize
else
normalize_comment comment
Expand Down Expand Up @@ -314,7 +314,7 @@ def find_class_named(name)
# Return the fully qualified name of this class or module

def full_name
@full_name ||= if RDoc::ClassModule === parent then
@full_name ||= if RDoc::ClassModule === parent
"#{parent.full_name}::#{@name}"
else
@name
Expand Down Expand Up @@ -427,7 +427,7 @@ def marshal_load(array) # :nodoc:

array[6].each do |constant, document, file|
case constant
when RDoc::Constant then
when RDoc::Constant
add_constant constant
else
constant = add_constant RDoc::Constant.new(constant, nil, RDoc::Comment.from_document(document))
Expand Down Expand Up @@ -485,7 +485,7 @@ def merge(class_module)

other_document = parse class_module.comment_location

if other_document then
if other_document
document = parse @comment_location

document = document.merge other_document
Expand All @@ -503,7 +503,7 @@ def merge(class_module)
other_files = cm.in_files

merge_collections attributes, cm.attributes, other_files do |add, attr|
if add then
if add
add_attribute attr
else
@attributes.delete attr
Expand All @@ -512,7 +512,7 @@ def merge(class_module)
end

merge_collections constants, cm.constants, other_files do |add, const|
if add then
if add
add_constant const
else
@constants.delete const
Expand All @@ -521,7 +521,7 @@ def merge(class_module)
end

merge_collections includes, cm.includes, other_files do |add, incl|
if add then
if add
add_include incl
else
@includes.delete incl
Expand All @@ -531,7 +531,7 @@ def merge(class_module)
@includes.uniq! # clean up

merge_collections extends, cm.extends, other_files do |add, ext|
if add then
if add
add_extend ext
else
@extends.delete ext
Expand All @@ -541,7 +541,7 @@ def merge(class_module)
@extends.uniq! # clean up

merge_collections method_list, cm.method_list, other_files do |add, meth|
if add then
if add
add_method meth
else
@method_list.delete meth
Expand All @@ -562,7 +562,7 @@ def merge(class_module)
# item to be added or removed.
#
# merge_collections things, other.things, other.in_files do |add, thing|
# if add then
# if add
# # add the thing
# else
# # remove the thing
Expand Down Expand Up @@ -602,7 +602,7 @@ def merge_sections(cm) # :nodoc:
other_files = other_section.in_files

merge_collections my_comments, other_comments, other_files do |add, comment|
if add then
if add
my_section.add_comment comment
else
my_section.remove_comment comment
Expand Down Expand Up @@ -639,9 +639,9 @@ def name=(new_name)

def parse(comment_location)
case comment_location
when String then
when String
super
when Hash then
when Hash
docs = comment_location.flat_map do |location, comments|
comments.map do |comment|
doc = super comment
Expand All @@ -651,11 +651,11 @@ def parse(comment_location)
end

RDoc::Markup::Document.new(*docs)
when RDoc::Comment then
when RDoc::Comment
doc = super comment_location.text, comment_location.format
doc.file = comment_location.location
doc
when RDoc::Markup::Document then
when RDoc::Markup::Document
return comment_location
else
raise ArgumentError, "unknown comment class #{comment_location.class}"
Expand Down Expand Up @@ -827,7 +827,7 @@ def super_classes
end

def to_s # :nodoc:
if is_alias_for then
if is_alias_for
"#{self.class.name} #{self.full_name} -> #{is_alias_for}"
else
super
Expand Down Expand Up @@ -895,7 +895,7 @@ def update_aliases
cm_alias.aliases.clear
cm_alias.is_alias_for = cm

if cm.module? then
if cm.module?
@store.modules_hash[cm_alias.full_name] = cm_alias
modules_hash[const.name] = cm_alias
else
Expand Down
6 changes: 3 additions & 3 deletions lib/rdoc/code_object/constant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def documented?
return true if super
return false unless @is_alias_for
case @is_alias_for
when String then
when String
found = @store.find_class_or_module @is_alias_for
return false unless found
@is_alias_for = found
Expand All @@ -99,7 +99,7 @@ def full_name

def is_alias_for
case @is_alias_for
when String then
when String
found = @store.find_class_or_module @is_alias_for
@is_alias_for = found if found
@is_alias_for
Expand Down Expand Up @@ -191,7 +191,7 @@ def search_snippet

def pretty_print(q) # :nodoc:
q.group 2, "[#{self.class.name} #{full_name}", "]" do
unless comment.empty? then
unless comment.empty?
q.breakable
q.text "comment:"
q.breakable
Expand Down
Loading