From fe75dcde1c0a43f0d08053ce7b41b55f4b23b8df Mon Sep 17 00:00:00 2001 From: rhymes Date: Tue, 29 Sep 2020 16:14:26 +0200 Subject: [PATCH] Routine rubocop fixes (#10478) --- .rubocop_todo.yml | 16 ++++++++-------- app/models/concerns/acts_as_profile_field.rb | 2 +- app/services/github/oauth_client.rb | 2 +- app/services/search/client.rb | 2 +- app/services/twitter_client/client.rb | 2 +- app/workers/metrics/record_data_counts_worker.rb | 8 ++++---- config/environments/production.rb | 4 ++-- .../github_tag/github_readme_tag_spec.rb | 2 +- spec/requests/api/v0/webhooks_spec.rb | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 86332fdb5..1c229d303 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,13 +1,13 @@ +# This configuration was generated by +# `rubocop --auto-gen-config --no-auto-gen-timestamp` +# using RuboCop version 0.92.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + # https://github.com/openstreetmap/openstreetmap-website/issues/2472 require: - rubocop-performance - rubocop-rails - rubocop-rspec - -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2020-09-07 10:28:36 UTC using RuboCop version 0.90.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. diff --git a/app/models/concerns/acts_as_profile_field.rb b/app/models/concerns/acts_as_profile_field.rb index fc165574a..74c5c1e98 100644 --- a/app/models/concerns/acts_as_profile_field.rb +++ b/app/models/concerns/acts_as_profile_field.rb @@ -3,7 +3,7 @@ concern :ActsAsProfileField do included do before_create :generate_attribute_name - WORD_REGEX = /\w+/.freeze + WORD_REGEX = /\w+/.freeze # rubocop:disable Lint/ConstantDefinitionInBlock validates :label, presence: true, uniqueness: { case_sensitive: false } validates :attribute_name, presence: true, on: :update diff --git a/app/services/github/oauth_client.rb b/app/services/github/oauth_client.rb index cf69cdf4c..388051c0f 100644 --- a/app/services/github/oauth_client.rb +++ b/app/services/github/oauth_client.rb @@ -46,7 +46,7 @@ module Github end # adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to - def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter + def respond_to_missing?(method, _include_all = false) target.respond_to?(method, false) || super end diff --git a/app/services/search/client.rb b/app/services/search/client.rb index 1b0369e50..a73852b7d 100644 --- a/app/services/search/client.rb +++ b/app/services/search/client.rb @@ -21,7 +21,7 @@ module Search end # adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to - def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter + def respond_to_missing?(method, _include_all = false) target.respond_to?(method, false) || super end diff --git a/app/services/twitter_client/client.rb b/app/services/twitter_client/client.rb index 590814b3d..06e4cebb7 100644 --- a/app/services/twitter_client/client.rb +++ b/app/services/twitter_client/client.rb @@ -12,7 +12,7 @@ module TwitterClient end # adapted from https://api.rubyonrails.org/classes/Module.html#method-i-delegate_missing_to - def respond_to_missing?(method, _include_all = false) # rubocop:disable Style/OptionalBooleanParameter + def respond_to_missing?(method, _include_all = false) target.respond_to?(method, false) || super end diff --git a/app/workers/metrics/record_data_counts_worker.rb b/app/workers/metrics/record_data_counts_worker.rb index 13f0a7e02..9155a8910 100644 --- a/app/workers/metrics/record_data_counts_worker.rb +++ b/app/workers/metrics/record_data_counts_worker.rb @@ -7,10 +7,10 @@ module Metrics models = [User, Article, Organization, Comment, Podcast, PodcastEpisode, Listing, PageView, Notification] models.each do |model| db_count = begin - model.count - rescue ActiveRecord::QueryCanceled - model.estimated_count - end + model.count + rescue ActiveRecord::QueryCanceled + model.estimated_count + end Rails.logger.info(message: "db_table_size", table_info: { table_name: model.table_name, table_size: db_count }) DatadogStatsClient.gauge("postgres.db_table_size", db_count, tags: ["table_name:#{model.table_name}"]) diff --git a/config/environments/production.rb b/config/environments/production.rb index e772fdb4c..639bac405 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -74,8 +74,8 @@ Rails.application.configure do # DEV uses the RedisCloud Heroku Add-On which comes with the predefined env variable REDISCLOUD_URL redis_url = ENV["REDISCLOUD_URL"] redis_url ||= ENV["REDIS_URL"] - DEFAULT_EXPIRATION = 24.hours.to_i.freeze - config.cache_store = :redis_cache_store, { url: redis_url, expires_in: DEFAULT_EXPIRATION } + default_expiration = 24.hours.to_i + config.cache_store = :redis_cache_store, { url: redis_url, expires_in: default_expiration } # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque diff --git a/spec/liquid_tags/github_tag/github_readme_tag_spec.rb b/spec/liquid_tags/github_tag/github_readme_tag_spec.rb index efa321d8c..c93eea31b 100644 --- a/spec/liquid_tags/github_tag/github_readme_tag_spec.rb +++ b/spec/liquid_tags/github_tag/github_readme_tag_spec.rb @@ -69,7 +69,7 @@ RSpec.describe GithubTag::GithubReadmeTag, type: :liquid_tag, vcr: true do end it "renders a repository with a missing README" do - allow_any_instance_of(Github::OauthClient).to receive(:readme).and_raise(Github::Errors::NotFound) + allow_any_instance_of(Github::OauthClient).to receive(:readme).and_raise(Github::Errors::NotFound) # rubocop:disable RSpec/AnyInstance VCR.use_cassette("github_client_repository") do template = generate_tag(url_repository).render diff --git a/spec/requests/api/v0/webhooks_spec.rb b/spec/requests/api/v0/webhooks_spec.rb index 0572b0895..feb1c2d79 100644 --- a/spec/requests/api/v0/webhooks_spec.rb +++ b/spec/requests/api/v0/webhooks_spec.rb @@ -129,9 +129,9 @@ RSpec.describe "Api::V0::Webhooks", type: :request do "github_username" => webhook.user.github_username, "website_url" => webhook.user.processed_website_url, "profile_image" => Images::Profile.call(webhook.user.profile_image_url, - length: 640), + length: 640), "profile_image_90" => Images::Profile.call(webhook.user.profile_image_url, - length: 90) + length: 90) }) end end