Commit 03138241 authored by Fabio Pelosin's avatar Fabio Pelosin

[Command::Spec::Linter] Error for name mismatch.

Related to [#239]
parent 04bb26a7
......@@ -196,7 +196,7 @@ module Pod
end
def errors
@errors ||= file_patterns_errors + build_errors
@errors ||= podspec_errors + file_patterns_errors + build_errors
end
def warnings
......@@ -247,25 +247,28 @@ module Pod
tmp_dir + 'Pods' + spec.name
end
# It checks a spec for minor non fatal defects
#
# It returns a array of strings
#
# @return [Array<String>] List of the fatal defects detected in a podspec
def podspec_errors
messages = []
messages << "The name of the spec should match the name of the file" unless names_match?
messages
end
# @return [Array<String>] List of the **non** fatal defects detected in a podspec
def podspec_warnings
license = @spec.license || {}
source = @spec.source || {}
text = @file.read
warnings = []
warnings << "The name of the spec should match the name of the file" unless names_match?
warnings << "Missing license[:type]" unless license[:type]
warnings << "Missing license[:file] or [:text]" unless license[:file] || license[:text]
warnings << "The summary should end with a dot" if @spec.summary !~ /.*\./
warnings << "The description should end with a dot" if @spec.description !~ /.*\./ && @spec.description != @spec.summary
warnings << "Git sources should specify either a tag or a commit" if source[:git] && ( !source[:commit] || !source[:tag] )
warnings << "Github repositories should end in `.git'" if github_source? && source[:git] !~ /.*\.git/
warnings << "Github repositories should start with `https'" if github_source? && source[:git] !~ /https:\/\/github.com/
warnings << "Comments must be deleted" if text =~ /^\w*#\n\w*#/ # allow a single line comment as it is generally used in subspecs
warnings
messages = []
messages << "Missing license[:type]" unless license[:type]
messages << "Missing license[:file] or [:text]" unless license[:file] || license[:text]
messages << "The summary should end with a dot" if @spec.summary !~ /.*\./
messages << "The description should end with a dot" if @spec.description !~ /.*\./ && @spec.description != @spec.summary
messages << "Git sources should specify either a tag or a commit" if source[:git] && ( !source[:commit] || !source[:tag] )
messages << "Github repositories should end in `.git'" if github_source? && source[:git] !~ /.*\.git/
messages << "Github repositories should start with `https'" if github_source? && source[:git] !~ /https:\/\/github.com/
messages << "Comments must be deleted" if text =~ /^\w*#\n\w*#/ # allow a single line comment as it is generally used in subspecs
messages
end
def names_match?
......
......@@ -109,9 +109,11 @@ describe "Pod::Command::Spec lint" do
end
it "lints a repo with --only-errors option and show the warnings" do
output = run_command('spec', 'lint', 'master', '--only-errors')
output.should.include "passed validation"
output.should.include "WARN"
# The fixture has an error due to name mismatch
cmd = command('spec', 'lint', 'master', '--only-errors')
lambda { cmd.run }.should.raise Pod::Informative
cmd.output.should.include "InAppSettingKit (0.0.1)\n - ERROR | The name of the spec should match the name of the file"
cmd.output.should.include "WARN"
end
it "complains if no repo name or url are provided and there a no specs in the current working directory" do
......
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