diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-30 21:07:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-30 21:07:14 +0300 |
commit | 9e7f94a7408534411dc8da69c9e3ad3a55722b51 (patch) | |
tree | baf917b2ab176390258c3a6a282b3b2432d4469c /rubocop | |
parent | 826cf5293fb78029f76c5e769696e3b37e681207 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r-- | rubocop/cop/graphql/descriptions.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rubocop/cop/graphql/descriptions.rb b/rubocop/cop/graphql/descriptions.rb index 3c945507699..d49673b29b3 100644 --- a/rubocop/cop/graphql/descriptions.rb +++ b/rubocop/cop/graphql/descriptions.rb @@ -49,6 +49,8 @@ module RuboCop MSG_NO_DESCRIPTION = "Please add a `description` property. #{MSG_STYLE_GUIDE_LINK}" MSG_NO_PERIOD = "`description` strings must end with a `.`. #{MSG_STYLE_GUIDE_LINK}" MSG_BAD_START = "`description` strings should not start with \"A...\" or \"The...\". #{MSG_STYLE_GUIDE_LINK}" + MSG_CONTAINS_THIS = "`description` strings should not contain the demonstrative \"this\"."\ + " #{MSG_STYLE_GUIDE_LINK}" def_node_matcher :graphql_describable?, <<~PATTERN (send nil? {:field :argument :value} ...) @@ -82,6 +84,8 @@ module RuboCop MSG_NO_PERIOD elsif bad_start?(description) MSG_BAD_START + elsif contains_demonstrative_this?(description) + MSG_CONTAINS_THIS end return unless message @@ -114,6 +118,10 @@ module RuboCop string?(description) && description.value.strip.downcase.start_with?('a ', 'the ') end + def contains_demonstrative_this?(description) + string?(description) && /\bthis\b/.match?(description.value.strip) + end + # Returns true if `description` node is a `:str` (as opposed to a `#copy_field_description` call) def string?(description) description.type == :str |