From 6465378939dbf0107dc69a1b445f2752bd866a58 Mon Sep 17 00:00:00 2001 From: r7kamura Date: Wed, 10 May 2023 08:11:42 +0900 Subject: [PATCH] Exclude `File.join` from `Rails/RootPathnameMethods` target methods --- ...ge_exclude_file_join_from_rails_root_pathname_methods.md | 1 + lib/rubocop/cop/rails/root_pathname_methods.rb | 1 - spec/rubocop/cop/rails/root_pathname_methods_spec.rb | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/change_exclude_file_join_from_rails_root_pathname_methods.md diff --git a/changelog/change_exclude_file_join_from_rails_root_pathname_methods.md b/changelog/change_exclude_file_join_from_rails_root_pathname_methods.md new file mode 100644 index 0000000000..997ff1c5df --- /dev/null +++ b/changelog/change_exclude_file_join_from_rails_root_pathname_methods.md @@ -0,0 +1 @@ +* [#1001](https://github.com/rubocop/rubocop-rails/pull/1001): Exclude `File.join` from `Rails/RootPathnameMethods` target methods. ([@r7kamura][]) diff --git a/lib/rubocop/cop/rails/root_pathname_methods.rb b/lib/rubocop/cop/rails/root_pathname_methods.rb index cc7c87a796..231ad00ef7 100644 --- a/lib/rubocop/cop/rails/root_pathname_methods.rb +++ b/lib/rubocop/cop/rails/root_pathname_methods.rb @@ -65,7 +65,6 @@ class RootPathnameMethods < Base fnmatch? ftype grpowned? - join lchmod lchown lstat diff --git a/spec/rubocop/cop/rails/root_pathname_methods_spec.rb b/spec/rubocop/cop/rails/root_pathname_methods_spec.rb index 709f8592b5..8d97e309e8 100644 --- a/spec/rubocop/cop/rails/root_pathname_methods_spec.rb +++ b/spec/rubocop/cop/rails/root_pathname_methods_spec.rb @@ -191,4 +191,10 @@ file = Rails.root.join('docs', 'invoice.pdf').open RUBY end + + it 'does not register an offense when using `File.join(Rails.root, ...)`' do + expect_no_offenses(<<~RUBY) + File.join(Rails.root, '/foo') + RUBY + end end