Skip to content
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

Merged
merged 14 commits into from
Apr 9, 2015

Conversation

mrackwitz
Copy link
Member

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

@@ -76,8 +76,10 @@ module DSL
# @param [String] name
# the name of the pod.
#
root_attribute :name,
:required => true
attribute :name,
Copy link
Member

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...

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter?

Copy link
Member Author

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].

Copy link
Member

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]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed. 👍

@@ -2,6 +2,12 @@

## Master

##### Enhancements

* The linter fails now if root attributes occur on subspec level.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two spaces

@segiddins
Copy link
Member

This needs more testing around setting names in subspecs

@mrackwitz mrackwitz force-pushed the mr-spec-dsl-fixes branch from 1969089 to ed08d80 Compare April 6, 2015 21:41
mrackwitz added a commit that referenced this pull request Apr 6, 2015
@mrackwitz
Copy link
Member Author

@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')
Copy link
Contributor

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.

@segiddins
Copy link
Member

@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/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if spec.name

@mrackwitz mrackwitz force-pushed the mr-spec-dsl-fixes branch from 4ee6737 to f0ce915 Compare April 8, 2015 10:17
@mrackwitz mrackwitz force-pushed the mr-spec-dsl-fixes branch from 29ce6ad to 2df8f5f Compare April 8, 2015 10:36
mrackwitz added a commit that referenced this pull request Apr 8, 2015
@mrackwitz
Copy link
Member Author

@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.
Copy link
Contributor

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)

Copy link
Member Author

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.

@mrackwitz mrackwitz force-pushed the mr-spec-dsl-fixes branch from 2df8f5f to 4c4140a Compare April 9, 2015 09:36
kylef added a commit that referenced this pull request Apr 9, 2015
[Specification::DSL] Fixes around Linter and Analyzer
@kylef kylef merged commit b609fa0 into master Apr 9, 2015
@mrackwitz mrackwitz deleted the mr-spec-dsl-fixes branch April 9, 2015 09:56
@kylef kylef restored the mr-spec-dsl-fixes branch April 12, 2015 04:48
@kylef kylef deleted the mr-spec-dsl-fixes branch April 12, 2015 04:51
mrackwitz added a commit that referenced this pull request Apr 12, 2015
mrackwitz added a commit that referenced this pull request Apr 12, 2015
Ashton-W pushed a commit to Ashton-W/Core that referenced this pull request Nov 2, 2015
Ashton-W pushed a commit to Ashton-W/Core that referenced this pull request Nov 2, 2015
[Specification::DSL] Fixes around Linter and Analyzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants