Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
28c50294
Commit
28c50294
authored
Aug 06, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Linter] Extracted the Linter and added `pod repo lint`.
Closes #423.
parent
f500613a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
42 deletions
+92
-42
command.rb
lib/cocoapods/command.rb
+1
-0
linter.rb
lib/cocoapods/command/linter.rb
+0
-0
repo.rb
lib/cocoapods/command/repo.rb
+53
-3
spec.rb
lib/cocoapods/command/spec.rb
+0
-0
repo_spec.rb
spec/functional/command/repo_spec.rb
+11
-0
spec_spec.rb
spec/functional/command/spec_spec.rb
+0
-11
linter_spec.rb
spec/unit/command/linter_spec.rb
+27
-28
No files found.
lib/cocoapods/command.rb
View file @
28c50294
...
@@ -5,6 +5,7 @@ module Pod
...
@@ -5,6 +5,7 @@ module Pod
autoload
:ErrorReport
,
'cocoapods/command/error_report'
autoload
:ErrorReport
,
'cocoapods/command/error_report'
autoload
:Install
,
'cocoapods/command/install'
autoload
:Install
,
'cocoapods/command/install'
autoload
:List
,
'cocoapods/command/list'
autoload
:List
,
'cocoapods/command/list'
autoload
:Linter
,
'cocoapods/command/linter'
autoload
:Presenter
,
'cocoapods/command/presenter'
autoload
:Presenter
,
'cocoapods/command/presenter'
autoload
:Push
,
'cocoapods/command/push'
autoload
:Push
,
'cocoapods/command/push'
autoload
:Repo
,
'cocoapods/command/repo'
autoload
:Repo
,
'cocoapods/command/repo'
...
...
lib/cocoapods/command/linter.rb
0 → 100644
View file @
28c50294
This diff is collapsed.
Click to expand it.
lib/cocoapods/command/repo.rb
View file @
28c50294
...
@@ -11,10 +11,16 @@ module Pod
...
@@ -11,10 +11,16 @@ module Pod
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
Clones `URL' in the local spec-repos directory at `~/.cocoapods'. The
remote can later be referred to by `NAME'.
remote can later be referred to by `NAME'.
$ pod repo update
NAME
$ pod repo update
[NAME]
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.}
this will update all spec-repos in `~/.cocoapods'.
$ pod repo update [NAME | DIRECTORY]
Lints the spec-repo `NAME'. If a directory is provided it is assumed
to be the root of a repo. Finally, if NAME is not provided this will
lint all the spec-repos known to CocoaPods.}
end
end
extend
Executable
extend
Executable
...
@@ -27,7 +33,7 @@ module Pod
...
@@ -27,7 +33,7 @@ module Pod
raise
Informative
,
"
#{
@action
==
'add'
?
'Adding'
:
'Updating the remote of'
}
a repo needs a `name' and a `url'."
raise
Informative
,
"
#{
@action
==
'add'
?
'Adding'
:
'Updating the remote of'
}
a repo needs a `name' and a `url'."
end
end
@branch
=
argv
.
arguments
[
3
]
@branch
=
argv
.
arguments
[
3
]
when
'update'
when
'update'
,
'lint'
@name
=
argv
.
arguments
[
1
]
@name
=
argv
.
arguments
[
1
]
else
else
super
super
...
@@ -66,6 +72,50 @@ module Pod
...
@@ -66,6 +72,50 @@ module Pod
end
end
end
end
def
lint
if
@name
dirs
=
File
.
exists?
(
@name
)
?
[
Pathname
.
new
(
@name
)
]
:
[
dir
]
else
dirs
=
config
.
repos_dir
.
children
.
select
{
|
c
|
c
.
directory?
}
end
dirs
.
each
do
|
dir
|
check_versions
(
dir
)
puts
"
\n
Linting spec repo `
#{
dir
.
realpath
.
basename
}
'
\n
"
.
yellow
podspecs
=
dir
.
glob
(
'**/*.podspec'
)
invalid_count
=
0
podspecs
.
each
do
|
podspec
|
linter
=
Linter
.
new
(
podspec
)
linter
.
lenient
=
true
linter
.
quick
=
true
linter
.
lint
unless
linter
.
result_type
==
:success
invalid_count
+=
1
case
linter
.
result_type
when
:error
color
=
:red
when
:warning
color
=
:yellow
end
puts
" -> "
.
send
(
color
)
<<
linter
.
spec_name
print_messages
(
'ERROR'
,
linter
.
errors
)
print_messages
(
'WARN'
,
linter
.
warnings
)
print_messages
(
'NOTE'
,
linter
.
notes
)
puts
unless
config
.
silent?
end
end
puts
"Analyzed
#{
podspecs
.
count
}
podspecs files.
\n\n
"
unless
config
.
silent?
invalid_count
end
end
def
print_messages
(
type
,
messages
)
return
if
config
.
silent?
messages
.
each
{
|
msg
|
puts
" -
#{
type
.
ljust
(
5
)
}
|
#{
msg
}
"
}
end
def
check_versions
(
dir
)
def
check_versions
(
dir
)
versions
=
versions
(
dir
)
versions
=
versions
(
dir
)
unless
is_compatilbe
(
versions
)
unless
is_compatilbe
(
versions
)
...
...
lib/cocoapods/command/spec.rb
View file @
28c50294
This diff is collapsed.
Click to expand it.
spec/functional/command/repo_spec.rb
View file @
28c50294
...
@@ -9,6 +9,7 @@ describe "Pod::Command::Repo" do
...
@@ -9,6 +9,7 @@ describe "Pod::Command::Repo" do
it
"runs with correct parameters"
do
it
"runs with correct parameters"
do
lambda
{
run_command
(
'repo'
,
'add'
,
'NAME'
,
'URL'
)
}.
should
.
not
.
raise
lambda
{
run_command
(
'repo'
,
'add'
,
'NAME'
,
'URL'
)
}.
should
.
not
.
raise
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
not
.
raise
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
not
.
raise
lambda
{
run_command
(
'repo'
,
'lint'
,
temporary_directory
.
to_s
)
}.
should
.
not
.
raise
end
end
it
"complains for wrong parameters"
do
it
"complains for wrong parameters"
do
...
@@ -49,6 +50,16 @@ describe "Pod::Command::Repo" do
...
@@ -49,6 +50,16 @@ describe "Pod::Command::Repo" do
(
repo2
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo2
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo3
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo3
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
end
end
before
do
config
.
repos_dir
=
fixture
(
'spec-repos'
)
end
it
"lints a repo"
do
cmd
=
command
(
'repo'
,
'lint'
,
'master'
)
lambda
{
cmd
.
run
}.
should
.
not
.
raise
Pod
::
Informative
cmd
.
output
.
should
.
include
"Missing license type"
end
end
end
describe
"Concerning a repo support"
do
describe
"Concerning a repo support"
do
...
...
spec/functional/command/spec_spec.rb
View file @
28c50294
...
@@ -97,17 +97,6 @@ describe "Pod::Command::Spec#lint" do
...
@@ -97,17 +97,6 @@ describe "Pod::Command::Spec#lint" do
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryRepos
extend
SpecHelper
::
TemporaryRepos
before
do
config
.
repos_dir
=
fixture
(
'spec-repos'
)
end
it
"lints a repo"
do
# The fixture has warnings so it raises
cmd
=
command
(
'spec'
,
'lint'
,
"
#{
config
.
repos_dir
}
/master"
)
lambda
{
cmd
.
run
}.
should
.
raise
Pod
::
Informative
cmd
.
output
.
should
.
include
"WARN"
end
it
"complains if it can't find any spec to lint"
do
it
"complains if it can't find any spec to lint"
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
lambda
{
command
(
'spec'
,
'lint'
).
run
}.
should
.
raise
Pod
::
Informative
lambda
{
command
(
'spec'
,
'lint'
).
run
}.
should
.
raise
Pod
::
Informative
...
...
spec/unit/command/
spec
_spec.rb
→
spec/unit/command/
linter
_spec.rb
View file @
28c50294
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
describe
"Pod::Command::
Spec::
Linter"
do
describe
"Pod::Command::Linter"
do
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryDirectory
def
write_podspec
(
text
,
name
=
'JSONKit.podspec'
)
def
write_podspec
(
text
,
name
=
'JSONKit.podspec'
)
file
=
temporary_directory
+
'JSONKit.podspec'
file
=
temporary_directory
+
'JSONKit.podspec'
File
.
open
(
file
,
'w'
)
{
|
f
|
f
.
write
(
text
)
}
File
.
open
(
file
,
'w'
)
{
|
f
|
f
.
write
(
text
)
}
spec
=
Pod
::
Specification
.
from_file
(
file
)
file
[
spec
,
file
]
end
end
def
stub_podspec
(
pattern
=
nil
,
replacement
=
nil
)
def
stub_podspec
(
pattern
=
nil
,
replacement
=
nil
)
...
@@ -18,16 +17,16 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -18,16 +17,16 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"fails a specifications that does not contain the minimum required attributes"
do
it
"fails a specifications that does not contain the minimum required attributes"
do
spec
,
file
=
write_podspec
(
'Pod::Spec.new do |s| end'
)
file
=
write_podspec
(
'Pod::Spec.new do |s| end'
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
errors
.
join
(
' | '
)
=~
/name.*version.*summary.*homepage.*authors.*(source.*part_of).*source_files/
linter
.
errors
.
join
(
' | '
)
=~
/name.*version.*summary.*homepage.*authors.*(source.*part_of).*source_files/
end
end
it
"fails specifications if the name does not match the name of the file"
do
it
"fails specifications if the name does not match the name of the file"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKitAAA'"
))
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKitAAA'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
linter
.
errors
.
count
.
should
==
1
...
@@ -35,8 +34,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -35,8 +34,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"fails a specification if a path starts with a slash"
do
it
"fails a specification if a path starts with a slash"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.source_files = 'JSONKit\.\*'/
,
"s.source_files = '/JSONKit.*'"
))
file
=
write_podspec
(
stub_podspec
(
/s.source_files = 'JSONKit\.\*'/
,
"s.source_files = '/JSONKit.*'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
linter
.
errors
.
count
.
should
==
1
...
@@ -44,8 +43,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -44,8 +43,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"fails a specification if the platform is unrecognized"
do
it
"fails a specification if the platform is unrecognized"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKit'
\n
s.platform = :iososx
\n
"
))
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKit'
\n
s.platform = :iososx
\n
"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
linter
.
errors
.
count
.
should
==
1
...
@@ -53,8 +52,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -53,8 +52,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"fails validation if the specification contains warnings"
do
it
"fails validation if the specification contains warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/.*license.*/
,
""
))
file
=
write_podspec
(
stub_podspec
(
/.*license.*/
,
""
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
errors
.
should
.
be
.
empty
linter
.
errors
.
should
.
be
.
empty
...
@@ -62,8 +61,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -62,8 +61,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"validates in lenient mode if there are no errors but there are warnings"
do
it
"validates in lenient mode if there are no errors but there are warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/.*license.*/
,
""
))
file
=
write_podspec
(
stub_podspec
(
/.*license.*/
,
""
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
true
linter
.
lint
.
should
==
true
linter
.
errors
.
should
.
be
.
empty
linter
.
errors
.
should
.
be
.
empty
...
@@ -71,8 +70,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -71,8 +70,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"respects quick mode"
do
it
"respects quick mode"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
expects
(
:peform_multiplatform_analysis
).
never
linter
.
expects
(
:peform_multiplatform_analysis
).
never
linter
.
expects
(
:install_pod
).
never
linter
.
expects
(
:install_pod
).
never
linter
.
expects
(
:xcodebuild_output_for_platfrom
).
never
linter
.
expects
(
:xcodebuild_output_for_platfrom
).
never
...
@@ -82,25 +81,25 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -82,25 +81,25 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"produces deprecation notices"
do
it
"produces deprecation notices"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
if config.ios?
\n
end"
))
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
if config.ios?
\n
end"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
error
s
.
should
.
be
.
empty
linter
.
warning
s
.
should
.
be
.
empty
linter
.
warning
s
.
join
(
' | '
).
should
=~
/`config.ios\?' and `config.osx\?' are deprecated/
linter
.
error
s
.
join
(
' | '
).
should
=~
/`config.ios\?' and `config.osx\?' are deprecated/
end
end
it
"uses xcodebuild to generate notes and warnings"
do
it
"uses xcodebuild to generate notes and warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
linter
.
notes
.
join
(
' | '
).
should
.
include
"JSONKit/JSONKit.m:1640:27: warning: equality comparison with extraneous parentheses"
unless
`which xcodebuild`
.
strip
.
empty?
linter
.
notes
.
join
(
' | '
).
should
.
include
"JSONKit/JSONKit.m:1640:27: warning: equality comparison with extraneous parentheses"
unless
`which xcodebuild`
.
strip
.
empty?
end
end
it
"checks for file patterns"
do
it
"checks for file patterns"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
s.resources = 'WRONG_FOLDER'"
))
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
s.resources = 'WRONG_FOLDER'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
.
stubs
(
:xcodebuild_output
).
returns
([])
linter
.
stubs
(
:xcodebuild_output
).
returns
([])
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lint
.
should
==
false
linter
.
lint
.
should
==
false
...
@@ -108,9 +107,8 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -108,9 +107,8 @@ describe "Pod::Command::Spec::Linter" do
end
end
it
"uses the deployment target of the specification"
do
it
"uses the deployment target of the specification"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKit'; s.platform = :ios, '5.0'"
))
spec
.
stubs
(
:available_platforms
).
returns
([
Pod
::
Platform
.
new
(
:ios
,
"5.0"
)])
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
quick
=
true
linter
.
quick
=
true
linter
.
lint
linter
.
lint
podfile
=
linter
.
podfile_from_spec
podfile
=
linter
.
podfile_from_spec
...
@@ -118,3 +116,4 @@ describe "Pod::Command::Spec::Linter" do
...
@@ -118,3 +116,4 @@ describe "Pod::Command::Spec::Linter" do
deployment_target
.
to_s
.
should
==
"5.0"
deployment_target
.
to_s
.
should
==
"5.0"
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment