-
Notifications
You must be signed in to change notification settings - Fork 350
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
[Specification::DSL] Fixes around Linter and Analyzer #233
Conversation
@@ -76,8 +76,10 @@ module DSL | |||
# @param [String] name | |||
# the name of the pod. | |||
# | |||
root_attribute :name, | |||
:required => true | |||
attribute :name, |
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.
name should definitely be a root attribute...
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.
But it's also valid and required for subspecs.
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.
ah but you shouldn't be able to set the subspecs name directly, it's set via spec.subspec 'ss_name' do |ss|
bit
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.
Agree on that, but if it's defined as root_attribute
, it will be never validated for subspecs and the behavior, when the value is set, is undefined. It would be an exception among other root attributes, because it may occur on subspec level. I think being able to overwrite it in the subspec block in the DSL is the lesser of the two evils.
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.
@mrackwitz in that case, we must validate that
if spec.parent
spec.name.start_with?("#{spec.parent.name}/")
end
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.
@segiddins: Where would you add that check?
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.
linter?
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.
That's not required to lint Specification
, because the names are not flattened. Subspecs store only the last name element in their attributes_hash[:name]
.
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.
👍 in that case, need to validate that no /
gets into attributes_hash[:name]
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.
Yes, indeed. 👍
3e57238
to
1969089
Compare
@@ -2,6 +2,12 @@ | |||
|
|||
## Master | |||
|
|||
##### Enhancements | |||
|
|||
* The linter fails now if root attributes occur on subspec level. |
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.
two spaces
This needs more testing around setting names in subspecs |
1969089
to
ed08d80
Compare
@segiddins: Added the linter validation for subspec names. Anything else, you see? |
@@ -145,6 +150,11 @@ def result_should_include(*values) | |||
result_should_include('name', 'whitespace') | |||
end | |||
|
|||
it 'fails a specification whose name contains a backslash' do | |||
@spec.stubs(:name).returns('BananaKit/BananaFruit') |
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.
The test name says backslash but here we are testing a forward slash.
@mrackwitz while you're at it, please make sure #177 and #178 are addressed? |
results.add_error('name', 'The name of a spec should not contain ' \ | ||
'a slash.') | ||
end | ||
|
||
if spec.root.name =~ /\s/ |
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.
if spec.name
4ee6737
to
f0ce915
Compare
Not only root attributes.
29ce6ad
to
2df8f5f
Compare
@segiddins: Addressed the issues. |
@@ -9,6 +9,18 @@ | |||
[Samuel Giddins](https://github.com/segiddins) | |||
[#221](https://github.com/CocoaPods/Core/issues/221) | |||
|
|||
* The linter will now ensure that subspecs' names do not contain whitespace. |
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.
IMO, this is a bug fix not an enhancement. (same goes for below entry)
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.
Overall it will be likely rather perceived as bug fixes.
2df8f5f
to
4c4140a
Compare
[Specification::DSL] Fixes around Linter and Analyzer
[Specification::DSL] Fixes around Linter and Analyzer
Includes a fix that
:root_only => true
attributes could been overwritten in subspecs.Especially the change in a6d508f should been reviewed carefully.
/c @kylef @segiddins @alloy