Autofix Rubocop Rails/RootPathnameMethods (#23760)
This commit is contained in:
parent
48aeab90f6
commit
8fd3fc404d
8 changed files with 10 additions and 22 deletions
|
@ -1801,18 +1801,6 @@ Rails/ReversibleMigration:
|
||||||
- 'db/migrate/20180617162849_remove_unused_indexes.rb'
|
- 'db/migrate/20180617162849_remove_unused_indexes.rb'
|
||||||
- 'db/migrate/20220827195229_change_canonical_email_blocks_nullable.rb'
|
- 'db/migrate/20220827195229_change_canonical_email_blocks_nullable.rb'
|
||||||
|
|
||||||
# Offense count: 10
|
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
||||||
Rails/RootPathnameMethods:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/mastodon/premailer_webpack_strategy.rb'
|
|
||||||
- 'lib/tasks/emojis.rake'
|
|
||||||
- 'lib/tasks/mastodon.rake'
|
|
||||||
- 'lib/tasks/repo.rake'
|
|
||||||
- 'spec/fabricators/custom_emoji_fabricator.rb'
|
|
||||||
- 'spec/fabricators/site_upload_fabricator.rb'
|
|
||||||
- 'spec/rails_helper.rb'
|
|
||||||
|
|
||||||
# Offense count: 141
|
# Offense count: 141
|
||||||
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
# Configuration parameters: ForbiddenMethods, AllowedMethods.
|
||||||
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
|
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
|
||||||
|
|
|
@ -13,7 +13,7 @@ module PremailerWebpackStrategy
|
||||||
HTTP.get(url).to_s
|
HTTP.get(url).to_s
|
||||||
else
|
else
|
||||||
url = url[1..-1] if url.start_with?('/')
|
url = url[1..-1] if url.start_with?('/')
|
||||||
File.read(Rails.public_path.join(url))
|
Rails.public_path.join(url).read
|
||||||
end
|
end
|
||||||
|
|
||||||
css.gsub(/url\(\//, "url(#{asset_host}/")
|
css.gsub(/url\(\//, "url(#{asset_host}/")
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace :emojis do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
existence_maps = grouped_codes.map { |c| c.index_with { |cc| File.exist?(Rails.public_path.join('emoji', "#{codepoints_to_filename(cc)}.svg")) } }
|
existence_maps = grouped_codes.map { |c| c.index_with { |cc| Rails.public_path.join('emoji', "#{codepoints_to_filename(cc)}.svg").exist? } }
|
||||||
map = {}
|
map = {}
|
||||||
|
|
||||||
existence_maps.each do |group|
|
existence_maps.each do |group|
|
||||||
|
|
|
@ -445,7 +445,7 @@ namespace :mastodon do
|
||||||
generated_header << "# using docker-compose or not.\n\n"
|
generated_header << "# using docker-compose or not.\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
File.write(Rails.root.join('.env.production'), "#{generated_header}#{env_contents}\n")
|
Rails.root.join('.env.production').write("#{generated_header}#{env_contents}\n")
|
||||||
|
|
||||||
if using_docker
|
if using_docker
|
||||||
prompt.ok 'Below is your configuration, save it to an .env.production file outside Docker:'
|
prompt.ok 'Below is your configuration, save it to an .env.production file outside Docker:'
|
||||||
|
|
|
@ -5,7 +5,7 @@ REPOSITORY_NAME = 'mastodon/mastodon'
|
||||||
namespace :repo do
|
namespace :repo do
|
||||||
desc 'Generate the AUTHORS.md file'
|
desc 'Generate the AUTHORS.md file'
|
||||||
task :authors do
|
task :authors do
|
||||||
file = File.open(Rails.root.join('AUTHORS.md'), 'w')
|
file = Rails.root.join('AUTHORS.md').open('w')
|
||||||
|
|
||||||
file << <<~HEADER
|
file << <<~HEADER
|
||||||
Authors
|
Authors
|
||||||
|
@ -87,8 +87,8 @@ namespace :repo do
|
||||||
task check_locales_files: :environment do
|
task check_locales_files: :environment do
|
||||||
pastel = Pastel.new
|
pastel = Pastel.new
|
||||||
|
|
||||||
missing_yaml_files = I18n.available_locales.reject { |locale| File.exist?(Rails.root.join('config', 'locales', "#{locale}.yml")) }
|
missing_yaml_files = I18n.available_locales.reject { |locale| Rails.root.join('config', 'locales', "#{locale}.yml").exist? }
|
||||||
missing_json_files = I18n.available_locales.reject { |locale| File.exist?(Rails.root.join('app', 'javascript', 'mastodon', 'locales', "#{locale}.json")) }
|
missing_json_files = I18n.available_locales.reject { |locale| Rails.root.join('app', 'javascript', 'mastodon', 'locales', "#{locale}.json").exist? }
|
||||||
|
|
||||||
locales_in_files = Dir[Rails.root.join('config', 'locales', '*.yml')].map do |path|
|
locales_in_files = Dir[Rails.root.join('config', 'locales', '*.yml')].map do |path|
|
||||||
file_name = File.basename(path)
|
file_name = File.basename(path)
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
Fabricator(:custom_emoji) do
|
Fabricator(:custom_emoji) do
|
||||||
shortcode 'coolcat'
|
shortcode 'coolcat'
|
||||||
domain nil
|
domain nil
|
||||||
image { File.open(Rails.root.join('spec', 'fixtures', 'files', 'emojo.png')) }
|
image { Rails.root.join('spec', 'fixtures', 'files', 'emojo.png').open }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:site_upload) do
|
Fabricator(:site_upload) do
|
||||||
file { File.open(File.join(Rails.root, 'spec', 'fabricators', 'assets', 'utah_teapot.png')) }
|
file { Rails.root.join('spec', 'fabricators', 'assets', 'utah_teapot.png').open }
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,11 +73,11 @@ end
|
||||||
RSpec::Matchers.define_negated_matcher :not_change, :change
|
RSpec::Matchers.define_negated_matcher :not_change, :change
|
||||||
|
|
||||||
def request_fixture(name)
|
def request_fixture(name)
|
||||||
File.read(Rails.root.join('spec', 'fixtures', 'requests', name))
|
Rails.root.join('spec', 'fixtures', 'requests', name).read
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachment_fixture(name)
|
def attachment_fixture(name)
|
||||||
File.open(Rails.root.join('spec', 'fixtures', 'files', name))
|
Rails.root.join('spec', 'fixtures', 'files', name).open
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_jsonld_contexts!
|
def stub_jsonld_contexts!
|
||||||
|
|
Loading…
Reference in a new issue