-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Better warning message for which Swift version was used during validation #7131
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,7 +256,7 @@ def validation_dir | |
# @return [String] the SWIFT_VERSION to use for validation. | ||
# | ||
def swift_version | ||
return @swift_version if defined?(@swift_version) | ||
return @swift_version unless @swift_version.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the regression fix. |
||
if version = dot_swift_version | ||
@swift_version = version | ||
else | ||
|
@@ -277,11 +277,10 @@ def dot_swift_version | |
swift_version_path.read.strip | ||
end | ||
|
||
# @return [String] A string representing the Swift version used during linting | ||
# or nil, if Swift was not used. | ||
# @return [Boolean] Whether any of the pod targets part of this validator use Swift or not. | ||
# | ||
def used_swift_version | ||
swift_version if @installer.pod_targets.any?(&:uses_swift?) | ||
def uses_swift? | ||
@installer.pod_targets.any?(&:uses_swift?) | ||
end | ||
|
||
#-------------------------------------------------------------------------# | ||
|
@@ -318,7 +317,7 @@ def perform_extensive_analysis(spec) | |
download_pod | ||
check_file_patterns | ||
install_pod | ||
validate_dot_swift_version | ||
validate_swift_version | ||
add_app_project_import | ||
validate_vendored_dynamic_frameworks | ||
build_pod | ||
|
@@ -394,14 +393,21 @@ def validate_documentation_url(spec) | |
validate_url(spec.documentation_url) if spec.documentation_url | ||
end | ||
|
||
def validate_dot_swift_version | ||
if !used_swift_version.nil? && @swift_version.nil? | ||
# Performs validation for which version of Swift is used during validation. | ||
# | ||
# The user will be warned that the default version of Swift was used if the following things are true: | ||
# - The project uses Swift at all | ||
# - The user did not supply a Swift version via a parameter | ||
# - There is no `.swift-version` file present either. | ||
# | ||
def validate_swift_version | if uses_swift? && @swift_version.nil? && dot_swift_version.nil? | |
warning(:swift_version, | ||
'The validator for Swift projects uses ' \ | ||
'Swift 3.0 by default, if you are using a different version of ' \ | ||
'swift you can use a `.swift-version` file to set the version for ' \ | ||
"your Pod. For example to use Swift 2.3, run: \n" \ | ||
' `echo "2.3" > .swift-version`') | ||
'The validator used ' \ | ||
"Swift #{DEFAULT_SWIFT_VERSION} by default because no Swift version was specified. " \ | ||
'If you want to use a different version of Swift during validation, then either use the `--swift-version` parameter ' \ | ||
'or use a `.swift-version` file to set the version of Swift to use for ' \ | ||
'your Pod. For example to use Swift 2.3, run: `echo "2.3" > .swift-version`.') | ||
end | ||
end | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed link