From 25121081d3893a1e6f724d9da42eff3e57942dda Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Tue, 14 Sep 2021 11:47:24 +0900 Subject: [PATCH] [Fix #546] Exclude `app/models` by default for `Rails/ContentTag` Fixes #546 This PR excludes `app/models` by default for `Rails/ContentTag`. Because it prevents false positives for `tag` calls to `has_one: tag`. No helpers are used in normal models. --- ..._exclude_models_by_default_for_rails_content_tag.md | 1 + config/default.yml | 3 +++ docs/modules/ROOT/pages/cops_rails.adoc | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 changelog/change_exclude_models_by_default_for_rails_content_tag.md diff --git a/changelog/change_exclude_models_by_default_for_rails_content_tag.md b/changelog/change_exclude_models_by_default_for_rails_content_tag.md new file mode 100644 index 0000000000..46e16c77ce --- /dev/null +++ b/changelog/change_exclude_models_by_default_for_rails_content_tag.md @@ -0,0 +1 @@ +* [#546](https://github.com/rubocop/rubocop-rails/issues/546): Exclude `app/models` by default for `Rails/ContentTag`. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index 6676ca47b0..c497306f4b 100644 --- a/config/default.yml +++ b/config/default.yml @@ -189,6 +189,9 @@ Rails/ContentTag: Enabled: true VersionAdded: '2.6' VersionChanged: '2.12' + # This `Exclude` config prevents false positives for `tag` calls to `has_one: tag`. No helpers are used in normal models. + Exclude: + - app/models/**/*.rb Rails/CreateTableWithTimestamps: Description: >- diff --git a/docs/modules/ROOT/pages/cops_rails.adoc b/docs/modules/ROOT/pages/cops_rails.adoc index ea2469b2a8..7a5f748eef 100644 --- a/docs/modules/ROOT/pages/cops_rails.adoc +++ b/docs/modules/ROOT/pages/cops_rails.adoc @@ -845,6 +845,16 @@ tag.br(class: 'classname') tag(name, class: 'classname') ---- +=== Configurable attributes + +|=== +| Name | Default value | Configurable values + +| Exclude +| `app/models/**/*.rb` +| Array +|=== + === References * https://github.com/rubocop/rubocop-rails/issues/260