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
b16f25cc
Commit
b16f25cc
authored
May 31, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Validator] Explain why linting failed
parent
9ab00867
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
6 deletions
+34
-6
lib.rb
lib/cocoapods/command/lib.rb
+1
-1
lint.rb
lib/cocoapods/command/spec/lint.rb
+10
-4
validator.rb
lib/cocoapods/validator.rb
+20
-0
spec_spec.rb
spec/functional/command/spec_spec.rb
+3
-1
No files found.
lib/cocoapods/command/lib.rb
View file @
b16f25cc
...
@@ -160,7 +160,7 @@ module Pod
...
@@ -160,7 +160,7 @@ module Pod
else
else
spec_name
=
podspec
spec_name
=
podspec
spec_name
=
validator
.
spec
.
name
if
validator
.
spec
spec_name
=
validator
.
spec
.
name
if
validator
.
spec
message
=
"
#{
spec_name
}
did not pass validation."
message
=
"
#{
spec_name
}
did not pass validation
, due to
#{
validator
.
failure_reason
}
."
if
@clean
if
@clean
message
<<
"
\n
You can use the `--no-clean` option to inspect "
\
message
<<
"
\n
You can use the `--no-clean` option to inspect "
\
...
...
lib/cocoapods/command/spec/lint.rb
View file @
b16f25cc
...
@@ -42,7 +42,7 @@ module Pod
...
@@ -42,7 +42,7 @@ module Pod
def
run
def
run
UI
.
puts
UI
.
puts
invalid_count
=
0
failure_reasons
=
[]
podspecs_to_lint
.
each
do
|
podspec
|
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
quick
=
@quick
validator
.
quick
=
@quick
...
@@ -53,7 +53,7 @@ module Pod
...
@@ -53,7 +53,7 @@ module Pod
validator
.
only_subspec
=
@only_subspec
validator
.
only_subspec
=
@only_subspec
validator
.
use_frameworks
=
@use_frameworks
validator
.
use_frameworks
=
@use_frameworks
validator
.
validate
validator
.
validate
invalid_count
+=
1
unless
validator
.
validated?
failure_reasons
<<
validator
.
failure_reason
unless
@clean
unless
@clean
UI
.
puts
"Pods project available at `
#{
validator
.
validation_dir
}
/Pods/Pods.xcodeproj` for inspection."
UI
.
puts
"Pods project available at `
#{
validator
.
validation_dir
}
/Pods/Pods.xcodeproj` for inspection."
...
@@ -63,11 +63,17 @@ module Pod
...
@@ -63,11 +63,17 @@ module Pod
count
=
podspecs_to_lint
.
count
count
=
podspecs_to_lint
.
count
UI
.
puts
"Analyzed
#{
count
}
#{
'podspec'
.
pluralize
(
count
)
}
.
\n\n
"
UI
.
puts
"Analyzed
#{
count
}
#{
'podspec'
.
pluralize
(
count
)
}
.
\n\n
"
if
invalid_count
==
0
failure_reasons
.
compact!
if
failure_reasons
.
empty?
lint_passed_message
=
count
==
1
?
"
#{
podspecs_to_lint
.
first
.
basename
}
passed validation."
:
'All the specs passed validation.'
lint_passed_message
=
count
==
1
?
"
#{
podspecs_to_lint
.
first
.
basename
}
passed validation."
:
'All the specs passed validation.'
UI
.
puts
lint_passed_message
.
green
<<
"
\n\n
"
UI
.
puts
lint_passed_message
.
green
<<
"
\n\n
"
else
else
raise
Informative
,
count
==
1
?
'The spec did not pass validation.'
:
"
#{
invalid_count
}
out of
#{
count
}
specs failed validation."
raise
Informative
,
if
count
==
1
"The spec did not pass validation, due to
#{
failure_reasons
.
first
}
."
else
"
#{
invalid_count
}
out of
#{
count
}
specs failed validation."
end
end
end
podspecs_tmp_dir
.
rmtree
if
podspecs_tmp_dir
.
exist?
podspecs_tmp_dir
.
rmtree
if
podspecs_tmp_dir
.
exist?
end
end
...
...
lib/cocoapods/validator.rb
View file @
b16f25cc
require
'active_support/core_ext/array'
require
'active_support/core_ext/string/inflections'
module
Pod
module
Pod
# Validates a Specification.
# Validates a Specification.
#
#
...
@@ -111,6 +114,23 @@ module Pod
...
@@ -111,6 +114,23 @@ module Pod
UI
.
puts
UI
.
puts
end
end
def
failure_reason
results_by_type
=
results
.
group_by
(
&
:type
)
results_by_type
.
default
=
[]
return
nil
if
validated?
reasons
=
[]
if
(
size
=
results_by_type
[
:error
].
size
)
&&
size
>
0
reasons
<<
"
#{
size
}
#{
'error'
.
pluralize
(
size
)
}
"
end
if
!
allow_warnings
&&
(
size
=
results_by_type
[
:warning
].
size
)
&&
size
>
0
reason
=
"
#{
size
}
#{
'warning'
.
pluralize
(
size
)
}
"
pronoun
=
size
==
1
?
'it'
:
'them'
reason
<<
" (but you can use `--allow-warnings` to ignore
#{
pronoun
}
)"
if
reasons
.
empty?
reasons
<<
reason
end
reasons
.
to_sentence
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
# @!group Configuration
# @!group Configuration
...
...
spec/functional/command/spec_spec.rb
View file @
b16f25cc
...
@@ -197,8 +197,10 @@ module Pod
...
@@ -197,8 +197,10 @@ module Pod
it
'lints a given podspec'
do
it
'lints a given podspec'
do
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
@spec_path
)
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
@spec_path
)
lambda
{
cmd
.
run
}.
should
.
raise
Informative
exception
=
lambda
{
cmd
.
run
}.
should
.
raise
Informative
UI
.
output
.
should
.
include
'Missing license type'
UI
.
output
.
should
.
include
'Missing license type'
exception
.
message
.
should
.
match
/due to 1 warning /
exception
.
message
.
should
.
match
/use `--allow-warnings` to ignore it\)/
end
end
it
'respects the --allow-warnings option'
do
it
'respects the --allow-warnings option'
do
...
...
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