Skip to content

Commit

Permalink
Merge pull request #393 from VinayGuthal/check_requires_arc_true_fals…
Browse files Browse the repository at this point in the history
…e_strings

Check requires arc true false strings
  • Loading branch information
orta authored Jul 17, 2017
2 parents 6b36c7e + f624d96 commit 3f9fb9a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

##### Bug Fixes

* None.

* Check requires_arc for true/false strings
[Vinay Guthal](https://github.com/VinayGuthal)
[#393](https://github.com/CocoaPods/Core/pull/393)

## 1.3.0.beta.2 (2017-06-22)

Expand Down
21 changes: 19 additions & 2 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def lint
if spec
validate_root_name
check_required_attributes
check_requires_arc_attribute
run_root_validation_hooks
perform_all_specs_analysis
else
Expand Down Expand Up @@ -99,6 +100,20 @@ def validate_root_name
end
end

# Generates a warning if the requires_arc attribute has true or false string values.
#
# @return [void]
#
def check_requires_arc_attribute
attribute = DSL.attributes.values.find { |attr| attr.name == :requires_arc }
if attribute
value = spec.send(attribute.name)
if value == 'true' || value == 'false'
results.add_warning('requires_arc', value + ' is considered to be the name of a file.')
end
end
end

# Checks that every required attribute has a value.
#
# @return [void]
Expand Down Expand Up @@ -370,8 +385,10 @@ def _validate_test_type(t)
return
end
supported_test_types = Specification::DSL::SUPPORTED_TEST_TYPES
results.add_error('test_type', "The test type `#{t}` is not supported. " \
"Supported test type values are #{supported_test_types}.") unless supported_test_types.include?(t)
unless supported_test_types.include?(t)
results.add_error('test_type', "The test type `#{t}` is not supported. " \
"Supported test type values are #{supported_test_types}.")
end
end

# Performs validations related to github sources.
Expand Down
6 changes: 6 additions & 0 deletions lib/cocoapods-core/specification/root_attribute_accessors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def name
parent ? "#{parent.name}/#{base_name}" : base_name
end

# @return [Bool, String, Array<String>] The requires_arc value.
#
def requires_arc
attributes_hash['requires_arc']
end

# @return [Version] The version of the Pod.
#
# @todo The version is memoized because the Resolvers sets the head
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Pod::Spec.new do |s|
s.name = 'BananaLib'
s.version = '0.8'
s.authors = 'Banana Corp', { 'Monkey Boy' => '[email protected]' }
s.homepage = 'http://banana-corp.local/banana-lib.html'
s.summary = 'Chunky bananas!'
s.description = 'Full of chunky bananas.'
s.source = { :git => 'http://banana-corp.local/banana-lib.git', :tag => 'v1.0' }
s.source_files = 'Classes/*.{h,m}', 'Vendor'
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' }
s.prefix_header_file = 'Classes/BananaLib.pch'
s.resources = 'Resources/*.png'
s.requires_arc = 'true'
s.dependency 'monkey', '~> 1.0.1', '< 1.0.9'
s.license = {
:type => 'MIT',
:file => 'LICENSE',
:text => 'Permission is hereby granted ...',
}
end
8 changes: 7 additions & 1 deletion spec/source/health_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Pod

it 'analyzes all the specifications of a repo' do
@reporter.analyze
@reporter.report.analyzed_paths.count.should == 10
@reporter.report.analyzed_paths.count.should == 11
end

it 'is robust against malformed specifications' do
Expand All @@ -44,6 +44,12 @@ module Pod
errors.should.match /Incorrect path/
end

it 'checks if requires_arc has the string value of true or false' do
@reporter.analyze
warnings = @reporter.report.pods_by_warning.keys.join("\n")
warnings.should.match /true is considered to be the name of a file/
end

it 'checks for any stray specifications' do
@reporter.analyze
errors = @reporter.report.pods_by_error.keys.join("\n")
Expand Down
5 changes: 5 additions & 0 deletions spec/specification/root_attribute_accessors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Pod
@spec = Spec.new do |s|
s.name = 'Pod'
s.version = '1.0'
s.requires_arc = true
s.subspec 'Subspec' do
end
end
Expand Down Expand Up @@ -168,5 +169,9 @@ module Pod
@spec.module_map = 'module.modulemap'
@spec.module_map.should == 'module.modulemap'
end

it 'returns the correct requires_arc value, if specified' do
@spec.requires_arc.should == true
end
end
end

0 comments on commit 3f9fb9a

Please sign in to comment.