Fix Style/SingleLineBlockParams, RSpec/MultipleExpectations and remaining Layout/LineLength (#9204)

* Fix Style/SingleLineBlockParams

* Fix RSpec/MultipleExpectations and Layout/LineLength

* Restore test to previous version for speed

* Remove useless params
This commit is contained in:
rhymes 2020-07-10 11:23:02 +02:00 committed by GitHub
parent 0a51540a4c
commit b3060bc475
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 17 deletions

View file

@ -452,3 +452,9 @@ RSpec/ExampleLength:
Enabled: true
Max: 15
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
RSpec/MultipleExpectations:
Description: Checks if examples contain too many `expect` calls.
Enabled: true
Max: 8
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations

View file

@ -37,10 +37,6 @@ Performance/OpenStruct:
- 'spec/models/github_repo_spec.rb'
- 'spec/requests/github_repos_spec.rb'
# Offense count: 930
RSpec/MultipleExpectations:
Max: 12
# Offense count: 16
Rails/OutputSafety:
Exclude:
@ -58,10 +54,3 @@ Rails/OutputSafety:
Rails/UniqueValidationWithoutIndex:
Exclude:
- 'app/models/article.rb'
# Offense count: 3
# Configuration parameters: Methods.
# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
Style/SingleLineBlockParams:
Exclude:
- 'app/labor/markdown_fixer.rb'

View file

@ -7,17 +7,17 @@ class MarkdownFixer
add_quotes_to_title add_quotes_to_description
modify_hr_tags convert_new_lines split_tags underscores_in_usernames
]
methods.reduce(markdown) { |result, method| send(method, result) }
methods.reduce(markdown) { |acc, elem| send(elem, acc) }
end
def fix_for_preview(markdown)
methods = %i[add_quotes_to_title add_quotes_to_description modify_hr_tags underscores_in_usernames]
methods.reduce(markdown) { |result, method| send(method, result) }
methods.reduce(markdown) { |acc, elem| send(elem, acc) }
end
def fix_for_comment(markdown)
methods = %I[modify_hr_tags underscores_in_usernames]
methods.reduce(markdown) { |result, method| send(method, result) }
methods.reduce(markdown) { |acc, elem| send(elem, acc) }
end
def add_quotes_to_title(markdown)

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength
require "rails_helper"
require Rails.root.join("lib/data_update_scripts/20200519142908_re_index_feed_content_and_users_to_elasticsearch.rb")
@ -8,7 +7,8 @@ describe DataUpdateScripts::ReIndexFeedContentAndUsersToElasticsearch do
Search::User.refresh_index
end
it "indexes feed content(articles, comments, podcast episodes) and users to Elasticsearch" do
# rubocop:disable RSpec/ExampleLength
it "indexes feed content(articles, comments, podcast episodes) and users to Elasticsearch", :aggregate_failures do
article = create(:article)
podcast_episode = create(:podcast_episode)
comment = create(:comment)
@ -20,6 +20,7 @@ describe DataUpdateScripts::ReIndexFeedContentAndUsersToElasticsearch do
expect { user.elasticsearch_doc }.to raise_error(Search::Errors::Transport::NotFound)
sidekiq_perform_enqueued_jobs { described_class.new.run }
expect(article.elasticsearch_doc).not_to be_nil
expect(podcast_episode.elasticsearch_doc).not_to be_nil
expect(comment.elasticsearch_doc).not_to be_nil
@ -30,5 +31,5 @@ describe DataUpdateScripts::ReIndexFeedContentAndUsersToElasticsearch do
expect(comment.elasticsearch_doc["_source"].keys).to include "public_reactions_count"
expect(user.elasticsearch_doc["_source"].keys).to include "public_reactions_count"
end
# rubocop:enable RSpec/ExampleLength
end
# rubocop:enable RSpec/ExampleLength

View file

@ -42,6 +42,7 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do
end
# rubocop:disable RSpec/ExampleLength
# rubocop:disable RSpec/MultipleExpectations
it "sends only 1 notification at a time, in the correct order" do
user.update!(created_at: 1.day.ago)
@ -93,6 +94,7 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do
expect(user.notifications.last.notifiable).to eq(download_app_broadcast)
Timecop.return
end
# rubocop:enable RSpec/MultipleExpectations
# rubocop:enable RSpec/ExampleLength
end