Fix rubocop issues in glitch-soc-specific code

This commit is contained in:
Claire 2023-05-08 19:26:00 +02:00
parent d77fbbed73
commit 8b31030fe4
4 changed files with 35 additions and 34 deletions

View File

@ -964,6 +964,7 @@ Rails/ThreeStateBooleanColumn:
- 'db/migrate/20170209184350_add_reply_to_statuses.rb'
- 'db/migrate/20170330163835_create_imports.rb'
- 'db/migrate/20170905165803_add_local_to_statuses.rb'
- 'db/migrate/20171210213213_add_local_only_flag_to_statuses.rb'
- 'db/migrate/20181203021853_add_discoverable_to_accounts.rb'
- 'db/migrate/20190509164208_add_by_moderator_to_tombstone.rb'
- 'db/migrate/20190805123746_add_capabilities_to_tags.rb'

View File

@ -127,7 +127,7 @@ class Sanitize
node = env[:node]
rel = (node['rel'] || '').split & ['tag']
rel += ['nofollow', 'noopener', 'noreferrer'] unless TagManager.instance.local_url?(node['href'])
rel += %w(nofollow noopener noreferrer) unless TagManager.instance.local_url?(node['href'])
if rel.empty?
node.remove_attribute('rel')

View File

@ -9,10 +9,10 @@ RSpec.describe AdvancedTextFormatter do
let(:preloaded_accounts) { nil }
let(:content_type) { 'text/markdown' }
context 'given a markdown source' do
context 'with a markdown source' do
let(:content_type) { 'text/markdown' }
context 'given text containing plain text' do
context 'with text containing plain text' do
let(:text) { 'text' }
it 'paragraphizes the text' do
@ -20,7 +20,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing line feeds' do
context 'with text containing line feeds' do
let(:text) { "line\nfeed" }
it 'removes line feeds' do
@ -28,7 +28,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given some inline code using backticks' do
context 'with some inline code using backticks' do
let(:text) { 'test `foo` bar' }
it 'formats code using <code>' do
@ -36,7 +36,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a block code' do
context 'with a block code' do
let(:text) { "test\n\n```\nint main(void) {\n return 0; // https://joinmastodon.org/foo\n}\n```\n" }
it 'formats code using <pre> and <code>' do
@ -52,7 +52,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a link in inline code using backticks' do
context 'with a link in inline code using backticks' do
let(:text) { 'test `https://foo.bar/bar` bar' }
it 'does not rewrite the link' do
@ -60,7 +60,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text with a local-domain mention' do
context 'with text with a local-domain mention' do
let(:text) { 'foo https://cb6e6126.ngrok.io/about/more' }
it 'creates a link' do
@ -68,7 +68,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing linkable mentions' do
context 'with text containing linkable mentions' do
let(:preloaded_accounts) { [Fabricate(:account, username: 'alice')] }
let(:text) { '@alice' }
@ -77,7 +77,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing unlinkable mentions' do
context 'with text containing unlinkable mentions' do
let(:preloaded_accounts) { [] }
let(:text) { '@alice' }
@ -86,7 +86,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a stand-alone medium URL' do
context 'with a stand-alone medium URL' do
let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
it 'matches the full URL' do
@ -94,7 +94,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a stand-alone google URL' do
context 'with a stand-alone google URL' do
let(:text) { 'http://google.com' }
it 'matches the full URL' do
@ -102,7 +102,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a stand-alone URL with a newer TLD' do
context 'with a stand-alone URL with a newer TLD' do
let(:text) { 'http://example.gay' }
it 'matches the full URL' do
@ -110,7 +110,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a stand-alone IDN URL' do
context 'with a stand-alone IDN URL' do
let(:text) { 'https://nic.みんな/' }
it 'matches the full URL' do
@ -122,7 +122,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with a trailing period' do
context 'with a URL with a trailing period' do
let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
it 'matches the full URL but not the period' do
@ -130,7 +130,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL enclosed with parentheses' do
context 'with a URL enclosed with parentheses' do
let(:text) { '(http://google.com/)' }
it 'matches the full URL but not the parentheses' do
@ -138,7 +138,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with a trailing exclamation point' do
context 'with a URL with a trailing exclamation point' do
let(:text) { 'http://www.google.com!' }
it 'matches the full URL but not the exclamation point' do
@ -146,7 +146,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with a trailing single quote' do
context 'with a URL with a trailing single quote' do
let(:text) { "http://www.google.com'" }
it 'matches the full URL but not the single quote' do
@ -155,7 +155,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with a trailing angle bracket' do
context 'with a URL with a trailing angle bracket' do
let(:text) { 'http://www.google.com>' }
it 'matches the full URL but not the angle bracket' do
@ -163,7 +163,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with a query string' do
context 'with a URL with a query string' do
context 'with escaped unicode character' do
let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
@ -196,7 +196,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL with parentheses in it' do
context 'with a URL with parentheses in it' do
let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
it 'matches the full URL' do
@ -204,7 +204,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL in quotation marks' do
context 'with a URL in quotation marks' do
let(:text) { '"https://example.com/"' }
it 'does not match the quotation marks' do
@ -212,7 +212,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL in angle brackets' do
context 'with a URL in angle brackets' do
let(:text) { '<https://example.com/>' }
it 'does not match the angle brackets' do
@ -220,7 +220,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given a URL containing unsafe code (XSS attack, invisible part)' do
context 'with a URL containing unsafe code (XSS attack, invisible part)' do
let(:text) { 'http://example.com/blahblahblahblah/a<script>alert("Hello")</script>' }
it 'does not include the HTML in the URL' do
@ -232,7 +232,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing HTML code (script tag)' do
context 'with text containing HTML code (script tag)' do
let(:text) { '<script>alert("Hello")</script>' }
it 'does not include a script tag' do
@ -240,7 +240,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing HTML (XSS attack)' do
context 'with text containing HTML (XSS attack)' do
let(:text) { %q{<img src="javascript:alert('XSS');">} }
it 'does not include the javascript' do
@ -248,7 +248,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given an invalid URL' do
context 'with an invalid URL' do
let(:text) { 'http://www\.google\.com' }
it 'outputs the raw URL' do
@ -256,7 +256,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing a hashtag' do
context 'with text containing a hashtag' do
let(:text) { '#hashtag' }
it 'creates a hashtag link' do
@ -264,7 +264,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing a hashtag with Unicode chars' do
context 'with text containing a hashtag with Unicode chars' do
let(:text) { '#hashtagタグ' }
it 'creates a hashtag link' do
@ -272,7 +272,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text with a stand-alone xmpp: URI' do
context 'with text with a stand-alone xmpp: URI' do
let(:text) { 'xmpp:user@instance.com' }
it 'matches the full URI' do
@ -280,7 +280,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text with an xmpp: URI with a query-string' do
context 'with text with an xmpp: URI with a query-string' do
let(:text) { 'please join xmpp:muc@instance.com?join right now' }
it 'matches the full URI' do
@ -288,7 +288,7 @@ RSpec.describe AdvancedTextFormatter do
end
end
context 'given text containing a magnet: URI' do
context 'with text containing a magnet: URI' do
let(:text) { 'wikipedia gives this example of a magnet uri: magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a' }
it 'matches the full URI' do

View File

@ -216,7 +216,7 @@ RSpec.describe Status do
subject.text = "A toot #{subject.local_only_emoji}"
end
context 'if the status originates from this instance' do
context 'when the status originates from this instance' do
before do
subject.account = local_account
end
@ -228,7 +228,7 @@ RSpec.describe Status do
end
end
context 'if the status is remote' do
context 'when the status is remote' do
before do
subject.account = remote_account
end