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
e0e3b73f
Commit
e0e3b73f
authored
May 31, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3628 from CocoaPods/seg-linter-message
[Validator] Explain why linting failed
parents
85298a09
b16f25cc
Show 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 @
e0e3b73f
...
...
@@ -160,7 +160,7 @@ module Pod
else
spec_name
=
podspec
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
message
<<
"
\n
You can use the `--no-clean` option to inspect "
\
...
...
lib/cocoapods/command/spec/lint.rb
View file @
e0e3b73f
...
...
@@ -42,7 +42,7 @@ module Pod
def
run
UI
.
puts
invalid_count
=
0
failure_reasons
=
[]
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
quick
=
@quick
...
...
@@ -53,7 +53,7 @@ module Pod
validator
.
only_subspec
=
@only_subspec
validator
.
use_frameworks
=
@use_frameworks
validator
.
validate
invalid_count
+=
1
unless
validator
.
validated?
failure_reasons
<<
validator
.
failure_reason
unless
@clean
UI
.
puts
"Pods project available at `
#{
validator
.
validation_dir
}
/Pods/Pods.xcodeproj` for inspection."
...
...
@@ -63,11 +63,17 @@ module Pod
count
=
podspecs_to_lint
.
count
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.'
UI
.
puts
lint_passed_message
.
green
<<
"
\n\n
"
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
podspecs_tmp_dir
.
rmtree
if
podspecs_tmp_dir
.
exist?
end
...
...
lib/cocoapods/validator.rb
View file @
e0e3b73f
require
'active_support/core_ext/array'
require
'active_support/core_ext/string/inflections'
module
Pod
# Validates a Specification.
#
...
...
@@ -111,6 +114,23 @@ module Pod
UI
.
puts
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
...
...
spec/functional/command/spec_spec.rb
View file @
e0e3b73f
...
...
@@ -197,8 +197,10 @@ module Pod
it
'lints a given podspec'
do
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'
exception
.
message
.
should
.
match
/due to 1 warning /
exception
.
message
.
should
.
match
/use `--allow-warnings` to ignore it\)/
end
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