Commit 3028e378 authored by Fabio Pelosin's avatar Fabio Pelosin

[Linter] Added support to check the path of a podspec.

parent b2961dd2
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
# TODO: Add check to ensure that attributes inherited by subspecs are not duplicated ? # TODO: Add check to ensure that attributes inherited by subspecs are not duplicated ?
attr_accessor :quick, :lenient, :no_clean attr_accessor :quick, :lenient, :no_clean, :check_paths
attr_reader :spec, :file attr_reader :spec, :file
attr_reader :errors, :warnings, :notes attr_reader :errors, :warnings, :notes
...@@ -14,7 +14,9 @@ module Pod ...@@ -14,7 +14,9 @@ module Pod
end end
def spec_name def spec_name
file.basename('.*').to_s name = file.basename('.*').to_s
name << ( @spec ? " (#{spec.version})" : " (#{file.dirname.basename})")
name
end end
# Takes an array of podspec files and lints them all # Takes an array of podspec files and lints them all
...@@ -27,9 +29,16 @@ module Pod ...@@ -27,9 +29,16 @@ module Pod
if !deprecation_errors.empty? if !deprecation_errors.empty?
@errors = deprecation_errors @errors = deprecation_errors
@errors << "#{platform.name} [!] Fatal errors found skipping the rest of the validation"
else else
@spec = Specification.from_file(file) @spec = Specification.from_file(file)
platforms = spec.available_platforms platforms = spec.available_platforms
if @check_paths
expected_path = "#{@spec.version}/#{@spec.name}.podspec"
@errors << "Incorrect path, the path is `#{file}` and should be `#{expected_path}`" unless file.to_s.end_with?(expected_path)
end
platforms.each do |platform| platforms.each do |platform|
@platform_errors[platform], @platform_warnings[platform], @platform_notes[platform] = [], [], [] @platform_errors[platform], @platform_warnings[platform], @platform_notes[platform] = [], [], []
...@@ -48,9 +57,9 @@ module Pod ...@@ -48,9 +57,9 @@ module Pod
end end
# Get common messages # Get common messages
@errors = @platform_errors.values.reduce(:&) @errors += @platform_errors.values.reduce(:&)
@warnings = @platform_warnings.values.reduce(:&) @warnings += @platform_warnings.values.reduce(:&)
@notes = @platform_notes.values.reduce(:&) @notes += @platform_notes.values.reduce(:&)
platforms.each do |platform| platforms.each do |platform|
# Mark platform specific messages # Mark platform specific messages
......
...@@ -88,6 +88,7 @@ module Pod ...@@ -88,6 +88,7 @@ module Pod
linter = Linter.new(podspec) linter = Linter.new(podspec)
linter.lenient = true linter.lenient = true
linter.quick = true linter.quick = true
linter.check_paths = true
linter.lint linter.lint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment