Commit 7a148635 authored by Fabio Pelosin's avatar Fabio Pelosin

[Repo::Lint] Update for CocoaPods-Core changes

parent b910097b
...@@ -6,11 +6,11 @@ end ...@@ -6,11 +6,11 @@ end
gemspec gemspec
group :development do group :development do
gem "cocoapods-core", :git => "git://github.com/CocoaPods/Core.git" # gem "cocoapods-core", :git => "git://github.com/CocoaPods/Core.git"
gem "xcodeproj", :git => "git://github.com/CocoaPods/Xcodeproj.git" gem "xcodeproj", :git => "git://github.com/CocoaPods/Xcodeproj.git"
gem "cocoapods-downloader", :git => "git://github.com/CocoaPods/cocoapods-downloader" gem "cocoapods-downloader", :git => "git://github.com/CocoaPods/cocoapods-downloader"
# gem "cocoapods-core", :path => "../Core" gem "cocoapods-core", :path => "../Core"
# gem "xcodeproj", :path => "../Xcodeproj" # gem "xcodeproj", :path => "../Xcodeproj"
# gem "cocoapods-downloader", :path => "../cocoapods-downloader" # gem "cocoapods-downloader", :path => "../cocoapods-downloader"
......
...@@ -100,54 +100,32 @@ module Pod ...@@ -100,54 +100,32 @@ module Pod
dirs.each do |dir| dirs.each do |dir|
SourcesManager.check_version_information(dir) SourcesManager.check_version_information(dir)
UI.puts "\nLinting spec repo `#{dir.realpath.basename}`\n".yellow UI.puts "\nLinting spec repo `#{dir.realpath.basename}`\n".yellow
podspecs = Pathname.glob( dir + '**/*.podspec')
invalid_count = 0 validator = Source::HealthReporter.new(dir)
validator.pre_check do |name, version|
messages_by_type = {} UI.print '.'
podspecs.each do |podspec|
# print "\033[K -> #{podspec.relative_path_from(dir)}\r" unless config.silent?
validator = Validator.new(podspec)
validator.quick = true
validator.repo_path = dir
validator.only_errors = @only_errors
validator.disable_ui_output = true
validator.validate
invalid_count += 1 if validator.result_type == :error
unless validator.validated?
if @only_errors
results = validator.results.select { |r| r.type.to_s == "error" }
else
results = validator.results
end
sorted_results = results.sort_by { |r| [r.type.to_s, r.message] }
sorted_results.each do |result|
name = validator.spec ? validator.spec.name : podspec.relative_path_from(dir)
version = validator.spec ? validator.spec.version : 'unknown'
messages_by_type[result.type] ||= {}
messages_by_type[result.type][result.message] ||= {}
messages_by_type[result.type][result.message][name] ||= []
messages_by_type[result.type][result.message][name] << version
end
end
end end
report = validator.analyze
UI.puts
UI.puts
# print "\033[K" unless config.silent? report.pods_by_warning.each do |message, versions_by_name|
messages_by_type.each do |type, names_by_message| UI.puts "-> #{message}".yellow
names_by_message.each do |message, versions_by_names| versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
color = type == :error ? :red : :yellow
UI.puts "[#{type}] #{message}".send(color)
versions_by_names.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
UI.puts UI.puts
end end
end
UI.puts "Analyzed #{podspecs.count} podspecs files.\n\n" report.pods_by_error.each do |message, versions_by_name|
UI.puts "-> #{message}".red
versions_by_name.each { |name, versions| UI.puts " - #{name} (#{versions * ', '})" }
UI.puts
end
if invalid_count == 0 UI.puts "Analyzed #{report.analyzed_paths.count} podspecs files.\n\n"
if report.pods_by_error.count.zero?
UI.puts "All the specs passed validation.".green << "\n\n" UI.puts "All the specs passed validation.".green << "\n\n"
else else
raise Informative, "#{invalid_count} podspecs failed validation." raise Informative, "#{report.pods_by_error.count} podspecs failed validation."
end end
end end
end end
......
...@@ -142,35 +142,6 @@ module Pod ...@@ -142,35 +142,6 @@ module Pod
puts("\n[!] #{message}".green) puts("\n[!] #{message}".green)
end end
# Stores important warning to the user optionally followed by actions
# that the user should take. To print them use #{print_warnings}
#
# @param [String] message The message to print.
# @param [Array] actions The actions that the user should take.
#
# return [void]
#
def warn(message, actions = [], verbose_only = false)
warnings << { :message => message, :actions => actions, :verbose_only => verbose_only }
end
# Prints the stored warnings. This method is intended to be called at the
# end of the execution of the binary.
#
# @return [void]
#
def print_warnings
STDOUT.flush
warnings.each do |warning|
next if warning[:verbose_only] && !config.verbose?
STDERR.puts("\n[!] #{warning[:message]}".yellow)
warning[:actions].each do |action|
indented = wrap_string(action, " - ")
puts(indented)
end
end
end
# Returns a string containing relative location of a path from the Podfile. # Returns a string containing relative location of a path from the Podfile.
# The returned path is quoted. If the argument is nit it returns the # The returned path is quoted. If the argument is nit it returns the
# empty string. # empty string.
...@@ -226,14 +197,6 @@ module Pod ...@@ -226,14 +197,6 @@ module Pod
end end
end end
# @!group Basic printing
# Prints a message unless config is silent.
#
def puts(message = '')
super(message) unless config.silent?
end
# Prints a message respecting the current indentation level and # Prints a message respecting the current indentation level and
# wrapping it to the terminal width if necessary. # wrapping it to the terminal width if necessary.
# #
...@@ -242,9 +205,56 @@ module Pod ...@@ -242,9 +205,56 @@ module Pod
puts(indented) puts(indented)
end end
# Prints the stored warnings. This method is intended to be called at the
# end of the execution of the binary.
#
# @return [void]
#
def print_warnings
STDOUT.flush
warnings.each do |warning|
next if warning[:verbose_only] && !config.verbose?
STDERR.puts("\n[!] #{warning[:message]}".yellow)
warning[:actions].each do |action|
indented = wrap_string(action, " - ")
puts(indented)
end
end
end
public
# @!group Basic methods
#-----------------------------------------------------------------------#
# prints a message followed by a new line unless config is silent.
#
def puts(message = '')
STDOUT.puts(message) unless config.silent?
end
# prints a message followed by a new line unless config is silent.
#
def print(message)
STDOUT.print(message) unless config.silent?
end
# Stores important warning to the user optionally followed by actions
# that the user should take. To print them use {#print_warnings}.
#
# @param [String] message The message to print.
# @param [Array] actions The actions that the user should take.
#
# return [void]
#
def warn(message, actions = [], verbose_only = false)
warnings << { :message => message, :actions => actions, :verbose_only => verbose_only }
end
private private
# @!group Helpers # @!group Helpers
#-----------------------------------------------------------------------#
# @return [String] Wraps a string taking into account the width of the # @return [String] Wraps a string taking into account the width of the
# terminal and an option indent. Adapted from # terminal and an option indent. Adapted from
......
...@@ -76,7 +76,7 @@ module Pod ...@@ -76,7 +76,7 @@ module Pod
out.should.match /target_definitions:/ out.should.match /target_definitions:/
out.should.match /platform: ios/ out.should.match /platform: ios/
out.should.match /- SSZipArchive:/ out.should.match /- SSZipArchive:/
out.should.end_with?("\n\r") out.should.end_with?("\n\r\n")
end end
end end
......
...@@ -15,11 +15,15 @@ module Pod ...@@ -15,11 +15,15 @@ module Pod
attr_accessor :warnings attr_accessor :warnings
def puts(message = '') def puts(message = '')
@output << "#{message}" @output << "#{message}\n"
end end
def warn(message = '', actions = []) def warn(message = '', actions = [])
@warnings << "#{message}" @warnings << "#{message}\n"
end
def print(message)
@output << message
end end
end end
end end
......
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