From da9759bd13273ff0601f10633cfb13974c6e6498 Mon Sep 17 00:00:00 2001 From: Ryan McGeary Date: Tue, 25 Jun 2019 09:32:24 -0600 Subject: [PATCH] [Fix #79] Rubocop::Cop::Rails constant removal Before, it attempted to remove the constant whether Rubocop::Cop::Rails was defined or if ::Rails was defined. Turning off the inherit flag while checking const_defined? remedies this. --- CHANGELOG.md | 2 ++ lib/rubocop/cop/rails_cops.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9b72b65ef..47b7812596 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Bug fixes * [#43](https://github.com/rubocop-hq/rubocop-rails/issues/43): Remove `change_column_null` method from `BulkChangeTable` cop offenses. ([@anthony-robin][]) +* [#79](https://github.com/rubocop-hq/rubocop-rails/issues/79): Fix `RuboCop::Cop::Rails not defined (NameError)`. ([@rmm5t][]) ### Changes @@ -27,3 +28,4 @@ [@andyw8]: https://github.com/andyw8 [@buehmann]: https://github.com/buehmann [@anthony-robin]: https://github.com/anthony-robin +[@rmm5t]: https://github.com/rmm5t diff --git a/lib/rubocop/cop/rails_cops.rb b/lib/rubocop/cop/rails_cops.rb index ecf3854158..807c68763c 100644 --- a/lib/rubocop/cop/rails_cops.rb +++ b/lib/rubocop/cop/rails_cops.rb @@ -4,7 +4,7 @@ module RuboCop # RuboCop included the Rails cops directly before version 1.0.0. # We can remove them to avoid warnings about redefining constants. module Cop - remove_const('Rails') if const_defined?('Rails') + remove_const('Rails') if const_defined?('Rails', false) end end