Commit 335be3aa authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Rémy Coutable

Fix Layout/EmptyLinesAroundArguments cop

This MR fixes the Layout/EmptyLinesAroundArguments
cop and adds changelog for the change.

Add changelog
parent a9e9dbba
...@@ -18,20 +18,6 @@ Capybara/CurrentPathExpectation: ...@@ -18,20 +18,6 @@ Capybara/CurrentPathExpectation:
Layout/ArgumentAlignment: Layout/ArgumentAlignment:
Enabled: false Enabled: false
# Offense count: 72
# Cop supports --auto-correct.
Layout/EmptyLinesAroundArguments:
Exclude:
- 'app/models/concerns/discussion_on_diff.rb'
- 'app/models/concerns/resolvable_discussion.rb'
- 'app/models/diff_discussion.rb'
- 'app/models/discussion.rb'
- 'ee/spec/models/geo/project_registry_spec.rb'
- 'lib/banzai/pipeline/broadcast_message_pipeline.rb'
- 'lib/banzai/pipeline/gfm_pipeline.rb'
- 'lib/banzai/pipeline/single_line_pipeline.rb'
- 'spec/features/markdown/copy_as_gfm_spec.rb'
# Offense count: 413 # Offense count: 413
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth. # Configuration parameters: EnforcedStyle, IndentationWidth.
......
...@@ -13,14 +13,12 @@ module DiscussionOnDiff ...@@ -13,14 +13,12 @@ module DiscussionOnDiff
:diff_line, :diff_line,
:active?, :active?,
:created_at_diff?, :created_at_diff?,
to: :first_note to: :first_note
delegate :file_path, delegate :file_path,
:blob, :blob,
:highlighted_diff_lines, :highlighted_diff_lines,
:diff_lines, :diff_lines,
to: :diff_file, to: :diff_file,
allow_nil: true allow_nil: true
end end
......
...@@ -31,7 +31,6 @@ module ResolvableDiscussion ...@@ -31,7 +31,6 @@ module ResolvableDiscussion
delegate :resolved_at, delegate :resolved_at,
:resolved_by, :resolved_by,
:resolved_by_push?, :resolved_by_push?,
to: :last_resolved_note, to: :last_resolved_note,
allow_nil: true allow_nil: true
end end
......
...@@ -16,7 +16,6 @@ class DiffDiscussion < Discussion ...@@ -16,7 +16,6 @@ class DiffDiscussion < Discussion
:diff_note_positions, :diff_note_positions,
:on_text?, :on_text?,
:on_image?, :on_image?,
to: :first_note to: :first_note
def legacy_diff_discussion? def legacy_diff_discussion?
......
...@@ -24,7 +24,6 @@ class Discussion ...@@ -24,7 +24,6 @@ class Discussion
:system_note_with_references_visible_for?, :system_note_with_references_visible_for?,
:resource_parent, :resource_parent,
:save, :save,
to: :first_note to: :first_note
def declarative_policy_delegate def declarative_policy_delegate
......
---
title: Fix Layout/EmptyLinesAroundArguments cop
merge_request: 41086
author: Rajendra Kadam
type: fixed
...@@ -361,7 +361,6 @@ RSpec.describe Geo::ProjectRegistry, :geo do ...@@ -361,7 +361,6 @@ RSpec.describe Geo::ProjectRegistry, :geo do
repository_verification_retry_count: nil, repository_verification_retry_count: nil,
repository_retry_count: nil, repository_retry_count: nil,
repository_retry_at: nil repository_retry_at: nil
) )
end end
end end
...@@ -1182,7 +1181,6 @@ RSpec.describe Geo::ProjectRegistry, :geo do ...@@ -1182,7 +1181,6 @@ RSpec.describe Geo::ProjectRegistry, :geo do
repository_verification_retry_count: nil, repository_verification_retry_count: nil,
repository_retry_count: nil, repository_retry_count: nil,
repository_retry_at: nil repository_retry_at: nil
) )
end end
end end
......
...@@ -7,7 +7,6 @@ module Banzai ...@@ -7,7 +7,6 @@ module Banzai
@filters ||= FilterArray[ @filters ||= FilterArray[
Filter::MarkdownFilter, Filter::MarkdownFilter,
Filter::BroadcastMessageSanitizationFilter, Filter::BroadcastMessageSanitizationFilter,
Filter::EmojiFilter, Filter::EmojiFilter,
Filter::ColorFilter, Filter::ColorFilter,
Filter::AutolinkFilter, Filter::AutolinkFilter,
......
...@@ -12,14 +12,11 @@ module Banzai ...@@ -12,14 +12,11 @@ module Banzai
def self.filters def self.filters
@filters ||= FilterArray[ @filters ||= FilterArray[
Filter::PlantumlFilter, Filter::PlantumlFilter,
# Must always be before the SanitizationFilter to prevent XSS attacks # Must always be before the SanitizationFilter to prevent XSS attacks
Filter::SpacedLinkFilter, Filter::SpacedLinkFilter,
Filter::SanitizationFilter, Filter::SanitizationFilter,
Filter::AssetProxyFilter, Filter::AssetProxyFilter,
Filter::SyntaxHighlightFilter, Filter::SyntaxHighlightFilter,
Filter::MathFilter, Filter::MathFilter,
Filter::ColorFilter, Filter::ColorFilter,
Filter::MermaidFilter, Filter::MermaidFilter,
...@@ -34,13 +31,10 @@ module Banzai ...@@ -34,13 +31,10 @@ module Banzai
Filter::ExternalLinkFilter, Filter::ExternalLinkFilter,
Filter::SuggestionFilter, Filter::SuggestionFilter,
Filter::FootnoteFilter, Filter::FootnoteFilter,
*reference_filters, *reference_filters,
Filter::EmojiFilter, Filter::EmojiFilter,
Filter::TaskListFilter, Filter::TaskListFilter,
Filter::InlineDiffFilter, Filter::InlineDiffFilter,
Filter::SetDirectionFilter Filter::SetDirectionFilter
] ]
end end
......
...@@ -8,11 +8,9 @@ module Banzai ...@@ -8,11 +8,9 @@ module Banzai
Filter::HtmlEntityFilter, Filter::HtmlEntityFilter,
Filter::SanitizationFilter, Filter::SanitizationFilter,
Filter::AssetProxyFilter, Filter::AssetProxyFilter,
Filter::EmojiFilter, Filter::EmojiFilter,
Filter::AutolinkFilter, Filter::AutolinkFilter,
Filter::ExternalLinkFilter, Filter::ExternalLinkFilter,
*reference_filters *reference_filters
] ]
end end
......
...@@ -30,13 +30,11 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -30,13 +30,11 @@ RSpec.describe 'Copy as GFM', :js do
it 'works', :aggregate_failures do it 'works', :aggregate_failures do
verify( verify(
'nesting', 'nesting',
'> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**' '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
) )
verify( verify(
'a real world example from the gitlab-ce README', 'a real world example from the gitlab-ce README',
<<~GFM <<~GFM
# GitLab # GitLab
...@@ -103,19 +101,16 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -103,19 +101,16 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'InlineDiffFilter', 'InlineDiffFilter',
'{-Deleted text-}', '{-Deleted text-}',
'{+Added text+}' '{+Added text+}'
) )
verify( verify(
'TaskListFilter', 'TaskListFilter',
<<~GFM, <<~GFM,
* [ ] Unchecked task * [ ] Unchecked task
* [x] Checked task * [x] Checked task
GFM GFM
<<~GFM <<~GFM
1. [ ] Unchecked ordered task 1. [ ] Unchecked ordered task
1. [x] Checked ordered task 1. [x] Checked ordered task
...@@ -124,7 +119,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -124,7 +119,6 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'ReferenceFilter', 'ReferenceFilter',
# issue reference # issue reference
@feat.issue.to_reference, @feat.issue.to_reference,
# full issue reference # full issue reference
...@@ -141,13 +135,11 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -141,13 +135,11 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'AutolinkFilter', 'AutolinkFilter',
'https://example.com' 'https://example.com'
) )
verify( verify(
'TableOfContentsFilter', 'TableOfContentsFilter',
<<~GFM, <<~GFM,
[[_TOC_]] [[_TOC_]]
...@@ -155,64 +147,53 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -155,64 +147,53 @@ RSpec.describe 'Copy as GFM', :js do
## Heading 2 ## Heading 2
GFM GFM
pipeline: :wiki, pipeline: :wiki,
wiki: @project.wiki wiki: @project.wiki
) )
verify( verify(
'EmojiFilter', 'EmojiFilter',
':thumbsup:' ':thumbsup:'
) )
verify( verify(
'ImageLinkFilter', 'ImageLinkFilter',
'![Image](https://example.com/image.png)' '![Image](https://example.com/image.png)'
) )
verify_media_with_partial_path( verify_media_with_partial_path(
'[test.txt](/uploads/a123/image.txt)', '[test.txt](/uploads/a123/image.txt)',
project_media_uri(@project, '/uploads/a123/image.txt') project_media_uri(@project, '/uploads/a123/image.txt')
) )
verify_media_with_partial_path( verify_media_with_partial_path(
'![Image](/uploads/a123/image.png)', '![Image](/uploads/a123/image.png)',
project_media_uri(@project, '/uploads/a123/image.png') project_media_uri(@project, '/uploads/a123/image.png')
) )
verify( verify(
'VideoLinkFilter', 'VideoLinkFilter',
'![Video](https://example.com/video.mp4)' '![Video](https://example.com/video.mp4)'
) )
verify_media_with_partial_path( verify_media_with_partial_path(
'![Video](/uploads/a123/video.mp4)', '![Video](/uploads/a123/video.mp4)',
project_media_uri(@project, '/uploads/a123/video.mp4') project_media_uri(@project, '/uploads/a123/video.mp4')
) )
verify( verify(
'AudioLinkFilter', 'AudioLinkFilter',
'![Audio](https://example.com/audio.wav)' '![Audio](https://example.com/audio.wav)'
) )
verify_media_with_partial_path( verify_media_with_partial_path(
'![Audio](/uploads/a123/audio.wav)', '![Audio](/uploads/a123/audio.wav)',
project_media_uri(@project, '/uploads/a123/audio.wav') project_media_uri(@project, '/uploads/a123/audio.wav')
) )
verify( verify(
'MathFilter: math as converted from GFM to HTML', 'MathFilter: math as converted from GFM to HTML',
'$`c = \pm\sqrt{a^2 + b^2}`$', '$`c = \pm\sqrt{a^2 + b^2}`$',
# math block # math block
<<~GFM <<~GFM
```math ```math
...@@ -334,7 +315,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -334,7 +315,6 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'MermaidFilter: mermaid as converted from GFM to HTML', 'MermaidFilter: mermaid as converted from GFM to HTML',
<<~GFM <<~GFM
```mermaid ```mermaid
graph TD; graph TD;
...@@ -429,7 +409,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -429,7 +409,6 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'SuggestionFilter: suggestion as converted from GFM to HTML', 'SuggestionFilter: suggestion as converted from GFM to HTML',
<<~GFM <<~GFM
```suggestion ```suggestion
New New
...@@ -491,7 +470,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -491,7 +470,6 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'SanitizationFilter', 'SanitizationFilter',
<<~GFM <<~GFM
<sub>sub</sub> <sub>sub</sub>
...@@ -527,13 +505,11 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -527,13 +505,11 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'SanitizationFilter', 'SanitizationFilter',
<<~GFM, <<~GFM,
``` ```
Plain text Plain text
``` ```
GFM GFM
<<~GFM, <<~GFM,
```ruby ```ruby
def foo def foo
...@@ -541,7 +517,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -541,7 +517,6 @@ RSpec.describe 'Copy as GFM', :js do
end end
``` ```
GFM GFM
<<~GFM <<~GFM
Foo Foo
...@@ -553,27 +528,19 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -553,27 +528,19 @@ RSpec.describe 'Copy as GFM', :js do
verify( verify(
'MarkdownFilter', 'MarkdownFilter',
"Line with two spaces at the end \nto insert a linebreak", "Line with two spaces at the end \nto insert a linebreak",
'`code`', '`code`',
'`` code with ` ticks ``', '`` code with ` ticks ``',
'> Quote', '> Quote',
# multiline quote # multiline quote
<<~GFM, <<~GFM,
> Multiline Quote > Multiline Quote
> >
> With multiple paragraphs > With multiple paragraphs
GFM GFM
'![Image](https://example.com/image.png)', '![Image](https://example.com/image.png)',
'# Heading with no anchor link', '# Heading with no anchor link',
'[Link](https://example.com)', '[Link](https://example.com)',
<<~GFM, <<~GFM,
* List item * List item
* List item 2 * List item 2
...@@ -598,7 +565,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -598,7 +565,6 @@ RSpec.describe 'Copy as GFM', :js do
> Blockquote > Blockquote
GFM GFM
<<~GFM, <<~GFM,
1. Ordered list item 1. Ordered list item
1. Ordered list item 2 1. Ordered list item 2
...@@ -623,22 +589,16 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -623,22 +589,16 @@ RSpec.describe 'Copy as GFM', :js do
--- ---
GFM GFM
'# Heading', '# Heading',
'## Heading', '## Heading',
'### Heading', '### Heading',
'#### Heading', '#### Heading',
'##### Heading', '##### Heading',
'###### Heading', '###### Heading',
'**Bold**', '**Bold**',
'*Italics*', '*Italics*',
'~~Strikethrough~~', '~~Strikethrough~~',
'---', '---',
# table # table
<<~GFM, <<~GFM,
| Centered | Right | Left | | Centered | Right | Left |
...@@ -696,9 +656,7 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -696,9 +656,7 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"] .line .no', '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"] .line .no',
'`RuntimeError`', '`RuntimeError`',
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
) )
end end
...@@ -708,9 +666,7 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -708,9 +666,7 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]', '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]',
'`raise RuntimeError, "System commands must be given as an array of strings"`', '`raise RuntimeError, "System commands must be given as an array of strings"`',
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
) )
end end
...@@ -720,14 +676,12 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -720,14 +676,12 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as a code block' do it 'copies as a code block' do
verify( verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
<<~GFM, <<~GFM,
```ruby ```ruby
raise RuntimeError, "System commands must be given as an array of strings" raise RuntimeError, "System commands must be given as an array of strings"
end end
``` ```
GFM GFM
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]' target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
) )
end end
...@@ -755,7 +709,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -755,7 +709,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as a code block' do it 'copies as a code block' do
verify( verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
<<~GFM, <<~GFM,
```ruby ```ruby
unless cmd.is_a?(Array) unless cmd.is_a?(Array)
...@@ -763,7 +716,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -763,7 +716,6 @@ RSpec.describe 'Copy as GFM', :js do
end end
``` ```
GFM GFM
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].left-side' target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].left-side'
) )
end end
...@@ -773,7 +725,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -773,7 +725,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as a code block' do it 'copies as a code block' do
verify( verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]', '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
<<~GFM, <<~GFM,
```ruby ```ruby
unless cmd.is_a?(Array) unless cmd.is_a?(Array)
...@@ -781,7 +732,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -781,7 +732,6 @@ RSpec.describe 'Copy as GFM', :js do
end end
``` ```
GFM GFM
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].right-side' target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].right-side'
) )
end end
...@@ -799,7 +749,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -799,7 +749,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'.line[id="LC9"] .no', '.line[id="LC9"] .no',
'`RuntimeError`' '`RuntimeError`'
) )
end end
...@@ -809,7 +758,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -809,7 +758,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'.line[id="LC9"]', '.line[id="LC9"]',
'`raise RuntimeError, "System commands must be given as an array of strings"`' '`raise RuntimeError, "System commands must be given as an array of strings"`'
) )
end end
...@@ -819,7 +767,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -819,7 +767,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as a code block' do it 'copies as a code block' do
verify( verify(
'.line[id="LC9"], .line[id="LC10"]', '.line[id="LC9"], .line[id="LC10"]',
<<~GFM <<~GFM
```ruby ```ruby
raise RuntimeError, "System commands must be given as an array of strings" raise RuntimeError, "System commands must be given as an array of strings"
...@@ -841,7 +788,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -841,7 +788,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'.line[id="LC27"] .nl', '.line[id="LC27"] .nl',
'`"bio"`' '`"bio"`'
) )
end end
...@@ -851,7 +797,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -851,7 +797,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as inline code' do it 'copies as inline code' do
verify( verify(
'.line[id="LC27"]', '.line[id="LC27"]',
'`"bio": null,`' '`"bio": null,`'
) )
end end
...@@ -861,7 +806,6 @@ RSpec.describe 'Copy as GFM', :js do ...@@ -861,7 +806,6 @@ RSpec.describe 'Copy as GFM', :js do
it 'copies as a code block with the correct language' do it 'copies as a code block with the correct language' do
verify( verify(
'.line[id="LC27"], .line[id="LC28"]', '.line[id="LC27"], .line[id="LC28"]',
<<~GFM <<~GFM
```json ```json
"bio": null, "bio": null,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment