Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linter] Cleanup the github sources checks #200

Merged
merged 3 commits into from
Nov 28, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,26 @@ def perform_github_source_checks(s)
if git = s[:git]
return unless git =~ /^#{URI.regexp}$/
git_uri = URI.parse(git)
if git_uri.host == 'www.github.com'
results.add_warning('github_sources', 'Github repositories should ' \
'not use `www` in their URL.')
end
if git_uri.host == 'github.com' || git_uri.host == 'gist.github.com'
unless git.end_with?('.git')
results.add_warning('github_sources', 'Github repositories ' \
'should end in `.git`.')
end
unless git_uri.scheme == 'https'
results.add_warning('github_sources', 'Github repositories ' \
'should use an `https` link.')
end
return unless git_uri.host.end_with?('github.com')
perform_github_uri_checks(git_uri)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perform_github_uri_checks(git_uri) if git_uri.host.end_with?('github.com')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

unless git.end_with?('.git')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

belongs in the helper method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

results.add_warning('github_sources', 'Github repositories ' \
'should end in `.git`.')
end
end
end

def perform_github_uri_checks(git_uri)
if git_uri.host.start_with?('www.')
results.add_warning('github_sources', 'Github repositories should ' \
'not use `www` in their URL.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second line of the method call should be indented 2 spaces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

end
unless git_uri.scheme == 'https'
results.add_warning('github_sources', 'Github repositories ' \
'should use an `https` link.')
end
end

# Performs validations related to SSH sources
#
def check_git_ssh_source(s)
Expand All @@ -377,8 +380,6 @@ def _validate_social_media_url(s)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a private label higher up in the file. I can add it back if we want it for consistencies sake.

# @!group All specs validation helpers

private

# Performs validations related to the `compiler_flags` attribute.
#
def _validate_compiler_flags(flags)
Expand Down
5 changes: 5 additions & 0 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ def result_should_include(*values)
result_should_include('Github', 'www')
end

it 'checks that Gist Github repositories do not use `www`' do
@spec.stubs(:source).returns(:git => 'https://www.gist.github.com/2823399.git', :tag => '1.0')
result_should_include('Github', 'www')
end

it 'checks that Github repositories end in .git (for compatibility)' do
@spec.stubs(:source).returns(:git => 'https://github.com/repo', :tag => '1.0')
result_should_include('Github', '.git')
Expand Down