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