Bump rubocop from 1.15.0 to 1.16.0 (#13894)

* Bump rubocop from 1.15.0 to 1.16.0

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Enable new cops and fix violations

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rhymes <github@rhymes.dev>
This commit is contained in:
dependabot[bot] 2021-06-02 09:11:38 -04:00 committed by GitHub
parent 7a17cdf0f3
commit 609afc71c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 89 additions and 65 deletions

View file

@ -56,6 +56,10 @@ Layout/DotPosition:
StyleGuide: '#consistent-multi-line-chains'
EnforcedStyle: leading
Lint/EmptyInPattern:
Description: 'Checks for the presence of `in` pattern branches without a body.'
Enabled: true
Layout/EmptyLinesAroundAttributeAccessor:
Description: "Keep blank lines around attribute accessors."
StyleGuide: '#empty-lines-around-attribute-accessor'
@ -536,6 +540,11 @@ Style/IfWithBooleanLiteralBranches:
# Description: 'Avoid trailing inline comments.'
# Enabled: false
Style/InPatternThen:
Description: 'Checks for `in;` uses in `case` expressions.'
StyleGuide: '#no-in-pattern-semicolons'
Enabled: true
# Style/IpAddresses:
# Description: "Don't include literal IP addresses in code."
# Enabled: false
@ -550,12 +559,25 @@ Style/IfWithBooleanLiteralBranches:
# StyleGuide: '#single-line-blocks'
# Enabled: false
Style/MultilineInPatternThen:
Description: 'Do not use `then` for multi-line `in` statement.'
Enabled: true
Style/NegatedIfElseCondition:
Description: >-
This cop checks for uses of `if-else` and ternary operators with a negated condition
which can be simplified by inverting condition and swapping branches.
Enabled: true
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: '#no-nested-conditionals'
Enabled: true
Style/NilLambda:
Description: 'Prefer `-> {}` to `-> { nil }`.'
Enabled: true
Style/OptionalBooleanParameter:
Description: 'Use keyword arguments when defining method with boolean argument.'
StyleGuide: '#boolean-keyword-arguments'
@ -565,13 +587,8 @@ Style/OptionHash:
Description: "Don't use option hashes when you can use keyword arguments."
Enabled: true
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: '#no-nested-conditionals'
Enabled: true
Style/NilLambda:
Description: 'Prefer `-> {}` to `-> { nil }`.'
Style/QuotedSymbols:
Description: 'Use a consistent style for quoted symbols.'
Enabled: true
Style/RedundantArgument:

View file

@ -147,7 +147,7 @@ group :development, :test do
gem "knapsack_pro", "~> 2.17.0" # Help parallelize Ruby spec builds
gem "pry-byebug", "~> 3.8" # Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish', 'continue' and 'break' commands to control execution
gem "rspec-rails", "~> 5.0" # rspec-rails is a testing framework for Rails 3+
gem "rubocop", "~> 1.15", require: false # Automatic Ruby code style checking tool
gem "rubocop", "~> 1.16", require: false # Automatic Ruby code style checking tool
gem "rubocop-performance", "~> 1.11", require: false # A collection of RuboCop cops to check for performance optimizations in Ruby code
gem "rubocop-rails", "~> 2.10", require: false # Automatic Rails code style checking tool
gem "rubocop-rspec", "~> 2.3", require: false # Code style checking for RSpec files

View file

@ -646,16 +646,16 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.10.2)
rubocop (1.15.0)
rubocop (1.16.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rubocop-ast (>= 1.7.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
rubocop-ast (1.7.0)
parser (>= 3.0.1.1)
rubocop-performance (1.11.3)
rubocop (>= 1.7.0, < 2.0)
@ -951,7 +951,7 @@ DEPENDENCIES
rpush-redis (~> 1.1)
rspec-rails (~> 5.0)
rspec-retry (~> 0.6)
rubocop (~> 1.15)
rubocop (~> 1.16)
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.10)
rubocop-rspec (~> 2.3)

View file

@ -42,7 +42,7 @@ class WikipediaTag < LiquidTagBase
def parse_page_with_anchor(url, lang, title, anchor)
api_url = "https://#{lang}.wikipedia.org/api/rest_v1/page/mobile-sections/#{title}"
response = HTTParty.get(api_url, headers: { 'user-agent': URL.url("/contact") })
response = HTTParty.get(api_url, headers: { "user-agent": URL.url("/contact") })
handle_response_error(response, url)
text, section_title = get_section_contents(response, anchor, url)
@ -57,7 +57,7 @@ class WikipediaTag < LiquidTagBase
def parse_page(url, lang, title)
api_url = "https://#{lang}.wikipedia.org/api/rest_v1/page/summary/#{title}"
response = HTTParty.get(api_url, headers: { 'user-agent': URL.url("/contact") })
response = HTTParty.get(api_url, headers: { "user-agent": URL.url("/contact") })
handle_response_error(response, url)
{

View file

@ -38,7 +38,7 @@ class Device < ApplicationRecord
subtitle: title,
body: body
},
'thread-id': Settings::Community.community_name
"thread-id": Settings::Community.community_name
},
data: payload
}

View file

@ -1,3 +1,4 @@
# rubocop:disable Style/TopLevelMethodDefinition
require "mini_magick"
# Carrierwave uses MiniMagick for image processing. To prevent server timeouts
@ -59,3 +60,4 @@ Rails.application.reloader.to_prepare do
local_storage_config
end
end
# rubocop:enable Style/TopLevelMethodDefinition

View file

@ -1,3 +1,4 @@
# rubocop:disable Style/TopLevelMethodDefinition
Rails.application.config.to_prepare do
Dir.glob(Rails.root.join("lib/slack/notifier/util/*.rb")).each do |filename|
require_dependency filename
@ -49,3 +50,4 @@ def init_slack_client
end
SlackClient = init_slack_client
# rubocop:enable Style/TopLevelMethodDefinition

View file

@ -132,9 +132,10 @@ describe Rack::Attack, type: :request, throttle: true do
end
# rubocop:disable RSpec/AnyInstance, RSpec/ExampleLength
it "throttles viewing tags" do
it "throttles viewing tags", :aggregate_failures do
allow_any_instance_of(Stories::TaggedArticlesController).to receive(:tagged_count).and_return(0)
allow_any_instance_of(Stories::TaggedArticlesController).to receive(:stories_by_timeframe).and_return(Article.none)
allow_any_instance_of(Stories::TaggedArticlesController).to receive(:stories_by_timeframe)
.and_return(Article.none)
allow_any_instance_of(Articles::Feeds::LargeForemExperimental).to receive(
:published_articles_by_tag,
).and_return(Article.none)

View file

@ -1,11 +1,11 @@
require "rails_helper"
require Rails.root.join("lib/data_update_scripts/20200901040521_create_profile_fields.rb")
def profile_field_and_group_count
[ProfileField.count, ProfileFieldGroup.count]
end
describe DataUpdateScripts::CreateProfileFields do
def profile_field_and_group_count
[ProfileField.count, ProfileFieldGroup.count]
end
before do
ProfileFieldGroup.destroy_all
ProfileField.destroy_all

View file

@ -1,29 +1,29 @@
require "rails_helper"
def user_from_authorization_service(service_name, signed_in_resource = nil, cta_variant = "navbar_basic")
auth = OmniAuth.config.mock_auth[service_name]
Authentication::Authenticator.call(
auth,
current_user: signed_in_resource,
cta_variant: cta_variant,
)
end
def mock_username(provider_name, username)
if provider_name == :apple
OmniAuth.config.mock_auth[provider_name].info.first_name = username
else
OmniAuth.config.mock_auth[provider_name].info.nickname = username
end
end
def provider_username(service_name)
auth_payload = OmniAuth.config.mock_auth[service_name]
provider_class = Authentication::Providers.get!(auth_payload.provider)
provider_class.new(auth_payload).user_nickname
end
RSpec.describe User, type: :model do
def user_from_authorization_service(service_name, signed_in_resource = nil, cta_variant = "navbar_basic")
auth = OmniAuth.config.mock_auth[service_name]
Authentication::Authenticator.call(
auth,
current_user: signed_in_resource,
cta_variant: cta_variant,
)
end
def mock_username(provider_name, username)
if provider_name == :apple
OmniAuth.config.mock_auth[provider_name].info.first_name = username
else
OmniAuth.config.mock_auth[provider_name].info.nickname = username
end
end
def provider_username(service_name)
auth_payload = OmniAuth.config.mock_auth[service_name]
provider_class = Authentication::Providers.get!(auth_payload.provider)
provider_class.new(auth_payload).user_nickname
end
let(:user) { create(:user) }
let(:other_user) { create(:user) }
let(:org) { create(:organization) }

View file

@ -1,6 +1,14 @@
require "rails_helper"
RSpec.describe Notifications::Milestone::Send, type: :service do
def send_milestone_notification_view
described_class.call("View", article)
end
def send_milestone_notification_reaction
described_class.call("Reaction", article)
end
let(:user) { create(:user) }
let(:article) { create(:article, user_id: user.id, page_views_count: 4000, public_reactions_count: 70) }
@ -78,11 +86,3 @@ RSpec.describe Notifications::Milestone::Send, type: :service do
end
end
end
def send_milestone_notification_view
described_class.call("View", article)
end
def send_milestone_notification_reaction
described_class.call("Reaction", article)
end

View file

@ -27,6 +27,7 @@ RSpec.configure do |config|
end
end
# rubocop:disable Style/TopLevelMethodDefinition
# adapted from <https://medium.com/doctolib-engineering/hunting-flaky-tests-2-waiting-for-ajax-bd76d79d9ee9>
def wait_for_javascript
max_time = Capybara::Helpers.monotonic_time + Capybara.default_max_wait_time
@ -42,3 +43,4 @@ def wait_for_javascript
raise "wait_for_javascript timeout" unless finished
end
# rubocop:enable Style/TopLevelMethodDefinition

View file

@ -1,19 +1,19 @@
require "rails_helper"
def expect_broadcast_data(page)
within ".broadcast-wrapper" do
expect(page).to have_selector(".broadcast-data")
expect(page).to have_text("Hello, World!")
end
end
def expect_no_broadcast_data(page)
expect(page).not_to have_css(".broadcast-wrapper")
expect(page).not_to have_selector(".broadcast-data")
expect(page).not_to have_text("Hello, World!")
end
RSpec.describe "User visits a homepage", type: :system do
def expect_broadcast_data(page)
within ".broadcast-wrapper" do
expect(page).to have_selector(".broadcast-data")
expect(page).to have_text("Hello, World!")
end
end
def expect_no_broadcast_data(page)
expect(page).not_to have_css(".broadcast-wrapper")
expect(page).not_to have_selector(".broadcast-data")
expect(page).not_to have_text("Hello, World!")
end
context "when user hasn't logged in" do
context "with an active announcement" do
before do

Binary file not shown.

BIN
vendor/cache/rubocop-1.16.0.gem vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
vendor/cache/rubocop-ast-1.7.0.gem vendored Normal file

Binary file not shown.