mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Enable Rubocop Style/StringConcatenation defaults (#23792)
This commit is contained in:
parent
7ecf783dd3
commit
0cfdd1a401
@ -2263,25 +2263,6 @@ Style/SlicingWithRange:
|
|||||||
- 'lib/mastodon/premailer_webpack_strategy.rb'
|
- 'lib/mastodon/premailer_webpack_strategy.rb'
|
||||||
- 'lib/tasks/repo.rake'
|
- 'lib/tasks/repo.rake'
|
||||||
|
|
||||||
# Offense count: 25
|
|
||||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
||||||
# Configuration parameters: Mode.
|
|
||||||
Style/StringConcatenation:
|
|
||||||
Exclude:
|
|
||||||
- 'app/lib/activitypub/case_transform.rb'
|
|
||||||
- 'app/lib/validation_error_formatter.rb'
|
|
||||||
- 'app/services/backup_service.rb'
|
|
||||||
- 'app/services/fetch_link_card_service.rb'
|
|
||||||
- 'lib/mastodon/emoji_cli.rb'
|
|
||||||
- 'lib/mastodon/redis_config.rb'
|
|
||||||
- 'lib/mastodon/snowflake.rb'
|
|
||||||
- 'lib/paperclip/gif_transcoder.rb'
|
|
||||||
- 'lib/paperclip/type_corrector.rb'
|
|
||||||
- 'spec/controllers/api/v1/apps_controller_spec.rb'
|
|
||||||
- 'spec/controllers/api/v1/streaming_controller_spec.rb'
|
|
||||||
- 'spec/validators/disallowed_hashtags_validator_spec.rb'
|
|
||||||
- 'spec/workers/web/push_notification_worker_spec.rb'
|
|
||||||
|
|
||||||
# Offense count: 272
|
# Offense count: 272
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: EnforcedStyle, MinSize.
|
# Configuration parameters: EnforcedStyle, MinSize.
|
||||||
|
@ -13,7 +13,7 @@ module ActivityPub::CaseTransform
|
|||||||
when Symbol then camel_lower(value.to_s).to_sym
|
when Symbol then camel_lower(value.to_s).to_sym
|
||||||
when String
|
when String
|
||||||
camel_lower_cache[value] ||= if value.start_with?('_:')
|
camel_lower_cache[value] ||= if value.start_with?('_:')
|
||||||
'_:' + value.gsub(/\A_:/, '').underscore.camelize(:lower)
|
"_:#{value.gsub(/\A_:/, '').underscore.camelize(:lower)}"
|
||||||
else
|
else
|
||||||
value.underscore.camelize(:lower)
|
value.underscore.camelize(:lower)
|
||||||
end
|
end
|
||||||
|
@ -19,7 +19,7 @@ class ValidationErrorFormatter
|
|||||||
messages = errors.messages[attribute_name]
|
messages = errors.messages[attribute_name]
|
||||||
|
|
||||||
h[@aliases[attribute_name] || attribute_name] = attribute_errors.map.with_index do |error, index|
|
h[@aliases[attribute_name] || attribute_name] = attribute_errors.map.with_index do |error, index|
|
||||||
{ error: 'ERR_' + error[:error].to_s.upcase, description: messages[index] }
|
{ error: "ERR_#{error[:error].to_s.upcase}", description: messages[index] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class BackupService < BaseService
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
archive_filename = ['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-') + '.tar.gz'
|
archive_filename = "#{['archive', Time.now.utc.strftime('%Y%m%d%H%M%S'), SecureRandom.hex(16)].join('-')}.tar.gz"
|
||||||
|
|
||||||
@backup.dump = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file, filename: archive_filename)
|
@backup.dump = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file, filename: archive_filename)
|
||||||
@backup.processed = true
|
@backup.processed = true
|
||||||
@ -86,14 +86,14 @@ class BackupService < BaseService
|
|||||||
def dump_actor!(tar)
|
def dump_actor!(tar)
|
||||||
actor = serialize(account, ActivityPub::ActorSerializer)
|
actor = serialize(account, ActivityPub::ActorSerializer)
|
||||||
|
|
||||||
actor[:icon][:url] = 'avatar' + File.extname(actor[:icon][:url]) if actor[:icon]
|
actor[:icon][:url] = "avatar#{File.extname(actor[:icon][:url])}" if actor[:icon]
|
||||||
actor[:image][:url] = 'header' + File.extname(actor[:image][:url]) if actor[:image]
|
actor[:image][:url] = "header#{File.extname(actor[:image][:url])}" if actor[:image]
|
||||||
actor[:outbox] = 'outbox.json'
|
actor[:outbox] = 'outbox.json'
|
||||||
actor[:likes] = 'likes.json'
|
actor[:likes] = 'likes.json'
|
||||||
actor[:bookmarks] = 'bookmarks.json'
|
actor[:bookmarks] = 'bookmarks.json'
|
||||||
|
|
||||||
download_to_tar(tar, account.avatar, 'avatar' + File.extname(account.avatar.path)) if account.avatar.exists?
|
download_to_tar(tar, account.avatar, "avatar#{File.extname(account.avatar.path)}") if account.avatar.exists?
|
||||||
download_to_tar(tar, account.header, 'header' + File.extname(account.header.path)) if account.header.exists?
|
download_to_tar(tar, account.header, "header#{File.extname(account.header.path)}") if account.header.exists?
|
||||||
|
|
||||||
json = Oj.dump(actor)
|
json = Oj.dump(actor)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService
|
|||||||
def html
|
def html
|
||||||
return @html if defined?(@html)
|
return @html if defined?(@html)
|
||||||
|
|
||||||
Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => Mastodon::Version.user_agent + ' Bot').perform do |res|
|
Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => "#{Mastodon::Version.user_agent} Bot").perform do |res|
|
||||||
# We follow redirects, and ideally we want to save the preview card for
|
# We follow redirects, and ideally we want to save the preview card for
|
||||||
# the destination URL and not any link shortener in-between, so here
|
# the destination URL and not any link shortener in-between, so here
|
||||||
# we set the URL to the one of the last response in the redirect chain
|
# we set the URL to the one of the last response in the redirect chain
|
||||||
|
@ -68,7 +68,7 @@ module Mastodon
|
|||||||
failed += 1
|
failed += 1
|
||||||
say('Failure/Error: ', :red)
|
say('Failure/Error: ', :red)
|
||||||
say(entry.full_name)
|
say(entry.full_name)
|
||||||
say(' ' + custom_emoji.errors[:image].join(', '), :red)
|
say(" #{custom_emoji.errors[:image].join(', ')}", :red)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
def setup_redis_env_url(prefix = nil, defaults = true)
|
def setup_redis_env_url(prefix = nil, defaults = true)
|
||||||
prefix = prefix.to_s.upcase + '_' unless prefix.nil?
|
prefix = "#{prefix.to_s.upcase}_" unless prefix.nil?
|
||||||
prefix = '' if prefix.nil?
|
prefix = '' if prefix.nil?
|
||||||
|
|
||||||
return if ENV[prefix + 'REDIS_URL'].present?
|
return if ENV["#{prefix}REDIS_URL"].present?
|
||||||
|
|
||||||
password = ENV.fetch(prefix + 'REDIS_PASSWORD') { '' if defaults }
|
password = ENV.fetch("#{prefix}REDIS_PASSWORD") { '' if defaults }
|
||||||
host = ENV.fetch(prefix + 'REDIS_HOST') { 'localhost' if defaults }
|
host = ENV.fetch("#{prefix}REDIS_HOST") { 'localhost' if defaults }
|
||||||
port = ENV.fetch(prefix + 'REDIS_PORT') { 6379 if defaults }
|
port = ENV.fetch("#{prefix}REDIS_PORT") { 6379 if defaults }
|
||||||
db = ENV.fetch(prefix + 'REDIS_DB') { 0 if defaults }
|
db = ENV.fetch("#{prefix}REDIS_DB") { 0 if defaults }
|
||||||
|
|
||||||
ENV[prefix + 'REDIS_URL'] = begin
|
ENV["#{prefix}REDIS_URL"] = begin
|
||||||
if [password, host, port, db].all?(&:nil?)
|
if [password, host, port, db].all?(&:nil?)
|
||||||
ENV['REDIS_URL']
|
ENV['REDIS_URL']
|
||||||
else
|
else
|
||||||
@ -27,7 +27,7 @@ setup_redis_env_url(:cache, false)
|
|||||||
setup_redis_env_url(:sidekiq, false)
|
setup_redis_env_url(:sidekiq, false)
|
||||||
|
|
||||||
namespace = ENV.fetch('REDIS_NAMESPACE', nil)
|
namespace = ENV.fetch('REDIS_NAMESPACE', nil)
|
||||||
cache_namespace = namespace ? namespace + '_cache' : 'cache'
|
cache_namespace = namespace ? "#{namespace}_cache" : 'cache'
|
||||||
sidekiq_namespace = namespace
|
sidekiq_namespace = namespace
|
||||||
|
|
||||||
REDIS_CACHE_PARAMS = {
|
REDIS_CACHE_PARAMS = {
|
||||||
|
@ -115,7 +115,7 @@ module Mastodon::Snowflake
|
|||||||
# And only those that are using timestamp_id.
|
# And only those that are using timestamp_id.
|
||||||
next unless (data = DEFAULT_REGEX.match(id_col.default_function))
|
next unless (data = DEFAULT_REGEX.match(id_col.default_function))
|
||||||
|
|
||||||
seq_name = data[:seq_prefix] + '_id_seq'
|
seq_name = "#{data[:seq_prefix]}_id_seq"
|
||||||
|
|
||||||
# If we were on Postgres 9.5+, we could do CREATE SEQUENCE IF
|
# If we were on Postgres 9.5+, we could do CREATE SEQUENCE IF
|
||||||
# NOT EXISTS, but we can't depend on that. Instead, catch the
|
# NOT EXISTS, but we can't depend on that. Instead, catch the
|
||||||
|
@ -109,7 +109,7 @@ module Paperclip
|
|||||||
final_file = Paperclip::Transcoder.make(file, options, attachment)
|
final_file = Paperclip::Transcoder.make(file, options, attachment)
|
||||||
|
|
||||||
if options[:style] == :original
|
if options[:style] == :original
|
||||||
attachment.instance.file_file_name = File.basename(attachment.instance.file_file_name, '.*') + '.mp4'
|
attachment.instance.file_file_name = "#{File.basename(attachment.instance.file_file_name, '.*')}.mp4"
|
||||||
attachment.instance.file_content_type = 'video/mp4'
|
attachment.instance.file_content_type = 'video/mp4'
|
||||||
attachment.instance.type = MediaAttachment.types[:gifv]
|
attachment.instance.type = MediaAttachment.types[:gifv]
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ module Paperclip
|
|||||||
def make
|
def make
|
||||||
return @file unless options[:format]
|
return @file unless options[:format]
|
||||||
|
|
||||||
target_extension = '.' + options[:format]
|
target_extension = ".#{options[:format]}"
|
||||||
extension = File.extname(attachment.instance_read(:file_name))
|
extension = File.extname(attachment.instance_read(:file_name))
|
||||||
|
|
||||||
return @file unless options[:style] == :original && target_extension && extension != target_extension
|
return @file unless options[:style] == :original && target_extension && extension != target_extension
|
||||||
|
@ -68,7 +68,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with a too-long website' do
|
context 'with a too-long website' do
|
||||||
let(:website) { 'https://foo.bar/' + ('hoge' * 2_000) }
|
let(:website) { "https://foo.bar/#{'hoge' * 2_000}" }
|
||||||
|
|
||||||
it 'returns http unprocessable entity' do
|
it 'returns http unprocessable entity' do
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
@ -76,7 +76,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with a too-long redirect_uris' do
|
context 'with a too-long redirect_uris' do
|
||||||
let(:redirect_uris) { 'https://foo.bar/' + ('hoge' * 2_000) }
|
let(:redirect_uris) { "https://foo.bar/#{'hoge' * 2_000}" }
|
||||||
|
|
||||||
it 'returns http unprocessable entity' do
|
it 'returns http unprocessable entity' do
|
||||||
expect(response).to have_http_status(422)
|
expect(response).to have_http_status(422)
|
||||||
|
@ -25,7 +25,7 @@ describe Api::V1::StreamingController do
|
|||||||
|
|
||||||
context 'with streaming api on different host' do
|
context 'with streaming api on different host' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Rails.configuration.x.streaming_api_base_url = 'wss://streaming-' + Rails.configuration.x.web_domain
|
Rails.configuration.x.streaming_api_base_url = "wss://streaming-#{Rails.configuration.x.web_domain}"
|
||||||
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
@streaming_host = URI.parse(Rails.configuration.x.streaming_api_base_url).host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do
|
|||||||
described_class.new.validate(status)
|
described_class.new.validate(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| '#' + x }.join(' ')) }
|
let(:status) { double(errors: errors, local?: local, reblog?: reblog, text: disallowed_tags.map { |x| "##{x}" }.join(' ')) }
|
||||||
let(:errors) { double(add: nil) }
|
let(:errors) { double(add: nil) }
|
||||||
|
|
||||||
context 'for a remote reblog' do
|
context 'for a remote reblog' do
|
||||||
|
@ -37,7 +37,7 @@ describe Web::PushNotificationWorker do
|
|||||||
expect(a_request(:post, endpoint).with(headers: {
|
expect(a_request(:post, endpoint).with(headers: {
|
||||||
'Content-Encoding' => 'aesgcm',
|
'Content-Encoding' => 'aesgcm',
|
||||||
'Content-Type' => 'application/octet-stream',
|
'Content-Type' => 'application/octet-stream',
|
||||||
'Crypto-Key' => 'dh=BAgtUks5d90kFmxGevk9tH7GEmvz9DB0qcEMUsOBgKwMf-TMjsKIIG6LQvGcFAf6jcmAod15VVwmYwGIIxE4VWE;p256ecdsa=' + vapid_public_key.delete('='),
|
'Crypto-Key' => "dh=BAgtUks5d90kFmxGevk9tH7GEmvz9DB0qcEMUsOBgKwMf-TMjsKIIG6LQvGcFAf6jcmAod15VVwmYwGIIxE4VWE;p256ecdsa=#{vapid_public_key.delete('=')}",
|
||||||
'Encryption' => 'salt=WJeVM-RY-F9351SVxTFx_g',
|
'Encryption' => 'salt=WJeVM-RY-F9351SVxTFx_g',
|
||||||
'Ttl' => '172800',
|
'Ttl' => '172800',
|
||||||
'Urgency' => 'normal',
|
'Urgency' => 'normal',
|
||||||
|
Loading…
Reference in New Issue
Block a user