From 3783c23457adaa4a1f97ffd0891a1a5a8d02f188 Mon Sep 17 00:00:00 2001 From: Luke Duncalfe Date: Mon, 20 May 2019 17:13:29 +1200 Subject: Link to issue in CodeReuse/ActiveRecord message This provides the user with some context as to why certain ActiveRecord methods are blacklisted. --- rubocop/cop/code_reuse/active_record.rb | 3 ++- spec/rubocop/cop/code_reuse/active_record_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rubocop/cop/code_reuse/active_record.rb b/rubocop/cop/code_reuse/active_record.rb index 2be8f7c11aa..1e650abfceb 100644 --- a/rubocop/cop/code_reuse/active_record.rb +++ b/rubocop/cop/code_reuse/active_record.rb @@ -9,7 +9,8 @@ module RuboCop class ActiveRecord < RuboCop::Cop::Cop include CodeReuseHelpers - MSG = 'This method can only be used inside an ActiveRecord model' + MSG = 'This method can only be used inside an ActiveRecord model: ' \ + 'https://gitlab.com/gitlab-org/gitlab-ce/issues/49653' # Various methods from ActiveRecord::Querying that are blacklisted. We # exclude some generic ones such as `any?` and `first`, as these may diff --git a/spec/rubocop/cop/code_reuse/active_record_spec.rb b/spec/rubocop/cop/code_reuse/active_record_spec.rb index a30fc52d26f..8f3a3690d88 100644 --- a/spec/rubocop/cop/code_reuse/active_record_spec.rb +++ b/spec/rubocop/cop/code_reuse/active_record_spec.rb @@ -14,7 +14,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do expect_offense(<<~SOURCE) def foo User.where - ^^^^^ This method can only be used inside an ActiveRecord model + ^^^^^ This method can only be used inside an ActiveRecord model: https://gitlab.com/gitlab-org/gitlab-ce/issues/49653 end SOURCE end @@ -23,7 +23,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do expect_offense(<<~SOURCE) def foo User.where(id: 10) - ^^^^^ This method can only be used inside an ActiveRecord model + ^^^^^ This method can only be used inside an ActiveRecord model: https://gitlab.com/gitlab-org/gitlab-ce/issues/49653 end SOURCE end @@ -40,7 +40,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do expect_offense(<<~SOURCE) def foo project.group(:name) - ^^^^^ This method can only be used inside an ActiveRecord model + ^^^^^ This method can only be used inside an ActiveRecord model: https://gitlab.com/gitlab-org/gitlab-ce/issues/49653 end SOURCE end -- cgit v1.2.1