Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
MethodDefineMacros
option to Naming/PredicateName
cop
Follow up for #4855 (comment). Feature ======= This PR also add the `MethodDefineMacros` option to check on methods dynamically defined to `Naming/PredicateName` cop. The target that RuboCop checks by default is `define_method`. This also applies to end user application code. The following is config/default.yml. ```yaml Naming/PredicateName: MethodDefineMacros: - define_method - define_singleton_method ``` `def_node_matcher` is also used for internal affairs of RuboCop itself. The following is config/.rubocop.yml. ```yaml Naming/PredicateName: MethodDefineMacros: - define_method - define_singleton_method - def_node_matcher ``` The following is the effect applied to the before master branch (995315f) . ```console % bundle exec rake internal_investigation Running RuboCop... Inspecting 1010 files (snip) Offenses: lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:26:26: C: Rename has_many_or_has_one_without_options? to many_or_has_one_without_options?. def_node_matcher :has_many_or_has_one_without_options?, <<-PATTERN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:30:26: C: Rename has_many_or_has_one_with_options? to many_or_has_one_with_options?. def_node_matcher :has_many_or_has_one_with_options?, <<-PATTERN ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:34:26: C: Rename has_dependent? to dependent?. def_node_matcher :has_dependent?, <<-PATTERN ^^^^^^^^^^^^^^^ lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb:38:26: C: Rename has_through? to through?. def_node_matcher :has_through?, <<-PATTERN ^^^^^^^^^^^^^ lib/rubocop/cop/rails/not_null_column.rb:34:26: C: Rename has_default? to default?. def_node_matcher :has_default?, <<-PATTERN ^^^^^^^^^^^^^ 1010 files inspected, 5 offenses detected RuboCop failed! ```
- Loading branch information
Showing
6 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters