From aa4179c506f1dfd0b69f2cff074300b828fd151d Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Thu, 1 Aug 2024 12:18:47 +0100 Subject: [PATCH] Remove unnecessary `file_name` parameter from `Parser#initialize` --- lib/rdoc/parser.rb | 6 +++--- lib/rdoc/parser/c.rb | 2 +- lib/rdoc/parser/prism_ruby.rb | 2 +- lib/rdoc/parser/ruby.rb | 2 +- lib/rdoc/parser/simple.rb | 2 +- test/rdoc/test_rdoc_parser.rb | 2 +- test/rdoc/test_rdoc_parser_c.rb | 4 ++-- test/rdoc/test_rdoc_parser_changelog.rb | 3 +-- test/rdoc/test_rdoc_parser_markdown.rb | 2 +- test/rdoc/test_rdoc_parser_prism_ruby.rb | 4 ++-- test/rdoc/test_rdoc_parser_rd.rb | 2 +- test/rdoc/test_rdoc_parser_ruby.rb | 3 +-- test/rdoc/test_rdoc_parser_simple.rb | 2 +- test/rdoc/test_rdoc_store.rb | 4 ++-- test/rdoc/xref_test_case.rb | 3 +-- 15 files changed, 20 insertions(+), 23 deletions(-) diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 76801ba377..d027711aea 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -191,7 +191,7 @@ def self.for top_level, content, options, stats content = remove_modeline content - parser.new top_level, file_name, content, options, stats + parser.new top_level, content, options, stats rescue SystemCallError nil end @@ -252,12 +252,12 @@ def self.use_markup content # RDoc::Markup::PreProcess object is created which allows processing of # directives. - def initialize top_level, file_name, content, options, stats + def initialize top_level, content, options, stats @top_level = top_level @top_level.parser = self.class @store = @top_level.store - @file_name = file_name + @file_name = top_level.absolute_name @content = content @options = options @stats = stats diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb index 7e83a6151f..5a834091ec 100644 --- a/lib/rdoc/parser/c.rb +++ b/lib/rdoc/parser/c.rb @@ -168,7 +168,7 @@ class RDoc::Parser::C < RDoc::Parser # Prepares for parsing a C file. See RDoc::Parser#initialize for details on # the arguments. - def initialize top_level, file_name, content, options, stats + def initialize top_level, content, options, stats super @known_classes = RDoc::KNOWN_CLASSES.dup diff --git a/lib/rdoc/parser/prism_ruby.rb b/lib/rdoc/parser/prism_ruby.rb index 06ef4abdb3..9ca1a56ec4 100644 --- a/lib/rdoc/parser/prism_ruby.rb +++ b/lib/rdoc/parser/prism_ruby.rb @@ -18,7 +18,7 @@ class RDoc::Parser::PrismRuby < RDoc::Parser attr_accessor :visibility attr_reader :container, :singleton - def initialize(top_level, file_name, content, options, stats) + def initialize(top_level, content, options, stats) super content = handle_tab_width(content) diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index 909b02d2af..58c54d606b 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -170,7 +170,7 @@ class RDoc::Parser::Ruby < RDoc::Parser ## # Creates a new Ruby parser. - def initialize(top_level, file_name, content, options, stats) + def initialize(top_level, content, options, stats) super content = handle_tab_width(content) diff --git a/lib/rdoc/parser/simple.rb b/lib/rdoc/parser/simple.rb index b1dabad0f8..931fa28913 100644 --- a/lib/rdoc/parser/simple.rb +++ b/lib/rdoc/parser/simple.rb @@ -14,7 +14,7 @@ class RDoc::Parser::Simple < RDoc::Parser ## # Prepare to parse a plain file - def initialize(top_level, file_name, content, options, stats) + def initialize(top_level, content, options, stats) super preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include diff --git a/test/rdoc/test_rdoc_parser.rb b/test/rdoc/test_rdoc_parser.rb index 51a16ce361..7b890f703d 100644 --- a/test/rdoc/test_rdoc_parser.rb +++ b/test/rdoc/test_rdoc_parser.rb @@ -310,7 +310,7 @@ def test_class_use_markup_unknown def test_initialize with_top_level("file.rb", "") do |top_level, content| - @RP.new top_level, top_level.absolute_name, content, @options, nil + @RP.new top_level, content, @options, nil assert_equal @RP, top_level.parser end diff --git a/test/rdoc/test_rdoc_parser_c.rb b/test/rdoc/test_rdoc_parser_c.rb index 31702a7cd0..ac9b90c6b9 100644 --- a/test/rdoc/test_rdoc_parser_c.rb +++ b/test/rdoc/test_rdoc_parser_c.rb @@ -138,7 +138,7 @@ def test_initialize @fn => { 'cSomeExtSingle' => 'SomeExtSingle' } } - parser = RDoc::Parser::C.new @top_level, @fn, '', @options, @stats + parser = RDoc::Parser::C.new @top_level, '', @options, @stats expected = { 'cSomeExt' => some_ext } assert_equal expected, parser.classes @@ -2144,7 +2144,7 @@ def util_get_class content, name = nil end def util_parser content = '' - RDoc::Parser::C.new @top_level, @fn, content, @options, @stats + RDoc::Parser::C.new @top_level, content, @options, @stats end end diff --git a/test/rdoc/test_rdoc_parser_changelog.rb b/test/rdoc/test_rdoc_parser_changelog.rb index 587a156d3a..c61c5cf825 100644 --- a/test/rdoc/test_rdoc_parser_changelog.rb +++ b/test/rdoc/test_rdoc_parser_changelog.rb @@ -474,8 +474,7 @@ def test_scan_git_commit_date end def util_parser content = '' - RDoc::Parser::ChangeLog.new \ - @top_level, @tempfile.path, content, @options, @stats + RDoc::Parser::ChangeLog.new @top_level, content, @options, @stats end def log_entry(*a) diff --git a/test/rdoc/test_rdoc_parser_markdown.rb b/test/rdoc/test_rdoc_parser_markdown.rb index cca9c1ddfd..976c711a01 100644 --- a/test/rdoc/test_rdoc_parser_markdown.rb +++ b/test/rdoc/test_rdoc_parser_markdown.rb @@ -55,7 +55,7 @@ def test_scan end def util_parser content - RDoc::Parser::Markdown.new @top_level, @fn, content, @options, @stats + RDoc::Parser::Markdown.new @top_level, content, @options, @stats end end diff --git a/test/rdoc/test_rdoc_parser_prism_ruby.rb b/test/rdoc/test_rdoc_parser_prism_ruby.rb index 16b8d522b6..8889b91cc5 100644 --- a/test/rdoc/test_rdoc_parser_prism_ruby.rb +++ b/test/rdoc/test_rdoc_parser_prism_ruby.rb @@ -1996,7 +1996,7 @@ def accept_legacy_bug? end def util_parser(content) - @parser = RDoc::Parser::PrismRuby.new @top_level, @filename, content, @options, @stats + @parser = RDoc::Parser::PrismRuby.new @top_level, content, @options, @stats @parser.scan end end @@ -2010,7 +2010,7 @@ def accept_legacy_bug? end def util_parser(content) - @parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options, @stats + @parser = RDoc::Parser::Ruby.new @top_level, content, @options, @stats @parser.scan end end unless ENV['RDOC_USE_PRISM_PARSER'] diff --git a/test/rdoc/test_rdoc_parser_rd.rb b/test/rdoc/test_rdoc_parser_rd.rb index 48663e6d7d..cbf96a01f7 100644 --- a/test/rdoc/test_rdoc_parser_rd.rb +++ b/test/rdoc/test_rdoc_parser_rd.rb @@ -49,7 +49,7 @@ def test_scan end def util_parser content - RDoc::Parser::RD.new @top_level, @fn, content, @options, @stats + RDoc::Parser::RD.new @top_level, content, @options, @stats end end diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index cf02a035a6..b7c4f4fbd6 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -4087,8 +4087,7 @@ class Baz end def util_parser(content) - @parser = RDoc::Parser::Ruby.new @top_level, @filename, content, @options, - @stats + @parser = RDoc::Parser::Ruby.new @top_level, content, @options, @stats end def util_two_parsers(first_file_content, second_file_content) diff --git a/test/rdoc/test_rdoc_parser_simple.rb b/test/rdoc/test_rdoc_parser_simple.rb index 4255cb97d8..5c701d0a08 100644 --- a/test/rdoc/test_rdoc_parser_simple.rb +++ b/test/rdoc/test_rdoc_parser_simple.rb @@ -109,7 +109,7 @@ def test_scan end def util_parser(content) - RDoc::Parser::Simple.new @top_level, @fn, content, @options, @stats + RDoc::Parser::Simple.new @top_level, content, @options, @stats end end diff --git a/test/rdoc/test_rdoc_store.rb b/test/rdoc/test_rdoc_store.rb index 2665f163e4..6631d04db9 100644 --- a/test/rdoc/test_rdoc_store.rb +++ b/test/rdoc/test_rdoc_store.rb @@ -116,7 +116,7 @@ def test_add_c_variables some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt' c_file.add_class RDoc::SingleClass, 'SomeExtSingle' - c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil + c_parser = RDoc::Parser::C.new c_file, '', options, nil c_parser.classes['cSomeExt'] = some_ext c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle' @@ -698,7 +698,7 @@ def test_save_cache some_ext = c_file.add_class RDoc::NormalClass, 'SomeExt' c_file.add_class RDoc::SingleClass, 'SomeExtSingle' - c_parser = RDoc::Parser::C.new c_file, 'ext.c', '', options, nil + c_parser = RDoc::Parser::C.new c_file, '', options, nil c_parser.classes['cSomeExt'] = some_ext c_parser.singleton_classes['s_cSomeExt'] = 'SomeExtSingle' diff --git a/test/rdoc/xref_test_case.rb b/test/rdoc/xref_test_case.rb index 0f7395e516..9c0b7129aa 100644 --- a/test/rdoc/xref_test_case.rb +++ b/test/rdoc/xref_test_case.rb @@ -20,8 +20,7 @@ def setup stats = RDoc::Stats.new @store, 0 - parser = RDoc::Parser::Ruby.new @xref_data, @file_name, XREF_DATA, @options, - stats + parser = RDoc::Parser::Ruby.new @xref_data, XREF_DATA, @options, stats @example_md = @store.add_file 'EXAMPLE.md' @example_md.parser = RDoc::Parser::Markdown