diff --git a/.rubocop.yml b/.rubocop.yml index c6fc94bdc..e9e5d0615 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -751,6 +751,10 @@ Rails/DefaultScope: StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope' Enabled: true +Rails/EnvironmentVariableAccess: + Description: 'Do not access `ENV` directly after initialization.' + Enabled: false + Rails/FilePath: EnforcedStyle: slashes @@ -805,6 +809,18 @@ Rails/RenderPlainText: StyleGuide: 'https://rails.rubystyle.guide/#plain-text-rendering' Enabled: true +# TODO: enable this once all loader related deprecations on console/server startup are dealt with +Rails/RequireDependency: + Description: 'Do not use `require_dependency` when running in Zeitwerk mode. `require_dependency` is for autoloading in classic mode.' + Reference: 'https://guides.rubyonrails.org/autoloading_and_reloading_constants.html' + Enabled: false + +Rails/ReversibleMigrationMethodDefinition: + Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.' + Enabled: true + Include: + - db/migrate/*.rb + Rails/ShortI18n: Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.' StyleGuide: 'https://rails.rubystyle.guide/#short-i18n' @@ -820,6 +836,11 @@ Rails/SkipsModelValidations: Rails/SquishedSQLHeredocs: Enabled: false +Rails/TimeZoneAssignment: + Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.' + Reference: 'https://thoughtbot.com/blog/its-about-time-zones' + Enabled: true + Rails/WhereExists: Description: 'Prefer `exists?(...)` over `where(...).exists?`.' Enabled: true diff --git a/Gemfile b/Gemfile index 99f06497b..3167b0d95 100644 --- a/Gemfile +++ b/Gemfile @@ -149,7 +149,7 @@ group :development, :test do gem "rspec-rails", "~> 5.0" # rspec-rails is a testing framework for Rails 3+ gem "rubocop", "~> 1.13", 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.9", require: false # Automatic Rails code style checking tool + 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 gem "sassc-rails", "~> 2.1.2" # Integrate SassC-Ruby into Rails gem "spring", "~> 2.1" # Preloads your application so things like console, rake and tests run faster diff --git a/Gemfile.lock b/Gemfile.lock index f8270f4c9..a3a486c58 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -661,10 +661,10 @@ GEM rubocop-performance (1.11.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.9.1) + rubocop-rails (2.10.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) + rubocop (>= 1.7.0, < 2.0) rubocop-rspec (2.3.0) rubocop (~> 1.0) rubocop-ast (>= 1.1.0) @@ -953,7 +953,7 @@ DEPENDENCIES rspec-retry (~> 0.6) rubocop (~> 1.13) rubocop-performance (~> 1.11) - rubocop-rails (~> 2.9) + rubocop-rails (~> 2.10) rubocop-rspec (~> 2.3) ruby-prof (~> 1.4) rubyzip (~> 2.3) diff --git a/app/services/edge_cache/bust_article.rb b/app/services/edge_cache/bust_article.rb index 3199ffa2e..87e196aa3 100644 --- a/app/services/edge_cache/bust_article.rb +++ b/app/services/edge_cache/bust_article.rb @@ -1,11 +1,13 @@ module EdgeCache class BustArticle + # rubocop:disable Rails/RelativeDateConstant TIMEFRAMES = [ [-> { 1.week.ago }, "week"], [-> { 1.month.ago }, "month"], [-> { 1.year.ago }, "year"], [-> { 5.years.ago }, "infinity"], ].freeze + # rubocop:enable Rails/RelativeDateConstant def self.call(article) return unless article diff --git a/spec/tasks/metrics_spec.rb b/spec/tasks/metrics_spec.rb index 75639e5a1..5e05b7440 100644 --- a/spec/tasks/metrics_spec.rb +++ b/spec/tasks/metrics_spec.rb @@ -9,7 +9,7 @@ RSpec.describe "Metrics Overview task", type: :task do describe "#overview" do let(:event_name) { "Admin Overview Link Clicked" } let(:click_target) { "https://forem.gitbook.io/forem-admin-guide/quick-start-guide" } - let(:host) { ENV['APP_DOMAIN'] } + let(:host) { ENV["APP_DOMAIN"] } it "returns the event count and target for admin overview events" do create(:ahoy_event, name: event_name, properties: { diff --git a/vendor/cache/rubocop-rails-2.10.0.gem b/vendor/cache/rubocop-rails-2.10.0.gem new file mode 100644 index 000000000..3e5328d37 Binary files /dev/null and b/vendor/cache/rubocop-rails-2.10.0.gem differ diff --git a/vendor/cache/rubocop-rails-2.9.1.gem b/vendor/cache/rubocop-rails-2.9.1.gem deleted file mode 100644 index 1f2689cea..000000000 Binary files a/vendor/cache/rubocop-rails-2.9.1.gem and /dev/null differ