[ruby/rdoc] Improve rubocop setup

(https://github.com/ruby/rdoc/pull/1139)

* Rename rake rubocop to rake format_generated_files

* Add rubocop rules to ensure spaces are applied consistently

* Improve rubocop related CI workflows

https://github.com/ruby/rdoc/commit/27932d001c
This commit is contained in:
Stan Lo 2024-07-17 21:42:58 +01:00 committed by git
parent 573c2893dc
commit 239d54dfbc
9 changed files with 15 additions and 15 deletions

View File

@ -70,7 +70,7 @@ class RDoc::Alias < RDoc::CodeObject
# HTML id-friendly version of +#new_name+.
def html_name
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
end
def inspect # :nodoc:

View File

@ -268,8 +268,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
when 'const_get' then 'const'
when 'new' then
$1.split('::').last. # ClassName => class_name
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z\d])([A-Z])/, '\1_\2').
downcase
else
$2
@ -291,7 +291,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
def html_name
require 'cgi/util'
CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
CGI.escape(@name.gsub('-', '-2D')).gsub('%', '-').sub(/^-/, '')
end
##

View File

@ -183,8 +183,8 @@ class RDoc::TopLevel < RDoc::Context
"#<%s:0x%x %p modules: %p classes: %p>" % [
self.class, object_id,
base_name,
@modules.map { |n,m| m },
@classes.map { |n,c| c }
@modules.map { |n, m| m },
@classes.map { |n, c| c }
]
end
@ -254,8 +254,8 @@ class RDoc::TopLevel < RDoc::Context
q.text "base name: #{base_name.inspect}"
q.breakable
items = @modules.map { |n,m| m }
items.concat @modules.map { |n,c| c }
items = @modules.map { |n, m| m }
items.concat @modules.map { |n, c| c }
q.seplist items do |mod| q.pp mod end
end
end

View File

@ -29,7 +29,7 @@ class RDoc::Generator::POT::MessageExtractor
extract_text(klass.comment_location, klass.full_name)
klass.each_section do |section, constants, attributes|
extract_text(section.title ,"#{klass.full_name}: section title")
extract_text(section.title, "#{klass.full_name}: section title")
section.comments.each do |comment|
extract_text(comment, "#{klass.full_name}: #{section.title}")
end

View File

@ -260,7 +260,7 @@ class RDoc::Markup::AttributeManager
def add_word_pair(start, stop, name, exclusive = false)
raise ArgumentError, "Word flags may not start with '<'" if
start[0,1] == '<'
start[0, 1] == '<'
bitmap = @attributes.bitmap_for name
@ -271,7 +271,7 @@ class RDoc::Markup::AttributeManager
@word_pair_map[pattern] = bitmap
end
@protectable << start[0,1]
@protectable << start[0, 1]
@protectable.uniq!
@exclusive_bitmap |= bitmap if exclusive

View File

@ -24,7 +24,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
def init_tags
add_tag :BOLD, '+b', '-b'
add_tag :EM, '+_', '-_'
add_tag :TT, '' , '' # we need in_tt information maintained
add_tag :TT, '', '' # we need in_tt information maintained
end
##

View File

@ -683,7 +683,7 @@ Usage: #{opt.program_name} [options] [names...]
EOF
parsers = Hash.new { |h,parser| h[parser] = [] }
parsers = Hash.new { |h, parser| h[parser] = [] }
RDoc::Parser.parsers.each do |regexp, parser|
parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source

View File

@ -440,7 +440,7 @@ class RDoc::Parser::C < RDoc::Parser
# Scans #content for rb_include_module
def do_includes
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c, m|
next unless cls = @classes[c]
m = @known_classes[m] || m

View File

@ -193,7 +193,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
entries << [entry_name, entry_body] if entry_name
entries.reject! do |(entry,_)|
entries.reject! do |(entry, _)|
entry == nil
end