-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Gemspec/DevelopmentDependencies not trigger when add_development_… #11872
Fix Gemspec/DevelopmentDependencies not trigger when add_development_… #11872
Conversation
c857f1c
to
46a1573
Compare
@@ -23,6 +23,28 @@ | |||
RUBY | |||
end | |||
|
|||
it 'registers an offense when using `#add_development_dependency` in a gemspec with version' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it 'registers an offense when using `#add_development_dependency` in a gemspec with version' do | |
it 'registers an offense when using `#add_development_dependency` in a gemspec with a single version argument' do |
RUBY | ||
end | ||
|
||
it 'registers an offense when using `#add_development_dependency` in a gemspec with many arguments' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it 'registers an offense when using `#add_development_dependency` in a gemspec with many arguments' do | |
it 'registers an offense when using `#add_development_dependency` in a gemspec with two version arguments' do |
@@ -75,7 +75,7 @@ class DevelopmentDependencies < Base | |||
|
|||
# @!method add_development_dependency?(node) | |||
def_node_matcher :add_development_dependency?, <<~PATTERN | |||
(send _ :add_development_dependency (str #forbidden_gem? ...)) | |||
(send _ :add_development_dependency (str #forbidden_gem? ...) (...)*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever a need for more than two arguments for the version? If not, wouldn't the following matcher suffice?
(send _ :add_development_dependency (str #forbidden_gem? ...) (...)*) | |
(send _ :add_development_dependency (str #forbidden_gem? ...) _? _?) |
…dependency has more then one arguments
46a1573
to
e768851
Compare
Thanks! |
…dependency has more then one arguments
I was wondering why this cop was not triggered in my gemspec, to finally found that, the node matcher didn't match if an argument (or more) is passed.
There was a comment in the PR that introduce this cop which had no response and I didn't found any related issues about this behaviour.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.