-
-
Notifications
You must be signed in to change notification settings - Fork 849
Support Ruby 3 #949
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
Support Ruby 3 #949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ def include_issues_by_labels(issues) | |
filter_wo_labels(filtered_issues) | ||
end | ||
|
||
# @param [Array] issues Issues & PRs to filter when without labels | ||
# @param [Array] items Issues & PRs to filter when without labels | ||
# @return [Array] Issues & PRs without labels or empty array if | ||
# add_issues_wo_labels or add_pr_wo_labels are false | ||
def filter_wo_labels(items) | ||
|
@@ -170,6 +170,7 @@ def filter_wo_labels(items) | |
end | ||
|
||
# @todo Document this | ||
# @param [Object] issues | ||
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 enumerable is probably an Array |
||
def filter_by_include_labels(issues) | ||
if options[:include_labels].nil? | ||
issues | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,9 @@ def get_all_tags | |
# Returns the number of pages for a API call | ||
# | ||
# @return [Integer] number of pages for this API call in total | ||
# @param [Object] request_options | ||
# @param [Object] method | ||
# @param [Object] client | ||
def calculate_pages(client, method, request_options) | ||
# Makes the first API call so that we can call last_response | ||
check_github_response do | ||
|
@@ -161,7 +164,7 @@ def fetch_closed_issues_and_pr | |
page_i = 0 | ||
count_pages = calculate_pages(client, "issues", closed_pr_options) | ||
|
||
iterate_pages(client, "issues", closed_pr_options) do |new_issues| | ||
iterate_pages(client, "issues", **closed_pr_options) do |new_issues| | ||
page_i += PER_PAGE_NUMBER | ||
print_in_same_line("Fetching issues... #{page_i}/#{count_pages * PER_PAGE_NUMBER}") | ||
issues.concat(new_issues) | ||
|
@@ -185,7 +188,7 @@ def fetch_closed_pull_requests | |
page_i = 0 | ||
count_pages = calculate_pages(client, "pull_requests", options) | ||
|
||
iterate_pages(client, "pull_requests", options) do |new_pr| | ||
iterate_pages(client, "pull_requests", **options) do |new_pr| | ||
page_i += PER_PAGE_NUMBER | ||
log_string = "Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}" | ||
print_in_same_line(log_string) | ||
|
@@ -215,7 +218,7 @@ def fetch_events_async(issues) | |
issues.each do |issue| | ||
semaphore.async do | ||
issue["events"] = [] | ||
iterate_pages(client, "issue_events", issue["number"], preview) do |new_event| | ||
iterate_pages(client, "issue_events", issue["number"], **preview) do |new_event| | ||
issue["events"].concat(new_event) | ||
end | ||
issue["events"] = issue["events"].map { |event| stringify_keys_deep(event.to_hash) } | ||
|
@@ -335,6 +338,7 @@ def default_branch | |
@default_branch ||= client.repository(user_project)[:default_branch] | ||
end | ||
|
||
# @param [Object] name | ||
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. Name is String. |
||
def commits_in_branch(name) | ||
@branches ||= client.branches(user_project).map { |branch| [branch[:name], branch] }.to_h | ||
|
||
|
@@ -357,6 +361,8 @@ def fetch_tag_shas(tags) | |
|
||
private | ||
|
||
# @param [Set] shas | ||
# @param [Object] sha | ||
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. The sha is String, I think. |
||
def commits_in_tag(sha, shas = Set.new) | ||
# Reduce multiple runs for the same tag | ||
return @commits_in_tag_cache[sha] if @commits_in_tag_cache.key?(sha) | ||
|
@@ -382,6 +388,7 @@ def commits_in_tag(sha, shas = Set.new) | |
shas | ||
end | ||
|
||
# @param [Object] indata | ||
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. These are super cool additions, and type descriptions in Yard can use a comma to separate each matching type like [Array, Hash] etc. |
||
def stringify_keys_deep(indata) | ||
case indata | ||
when Array | ||
|
@@ -405,10 +412,13 @@ def stringify_keys_deep(indata) | |
# | ||
# @param [Octokit::Client] client | ||
# @param [String] method (eg. 'tags') | ||
# @param [Array] arguments | ||
# @param [Async::Semaphore] parent | ||
# | ||
# @yield [Sawyer::Resource] An OctoKit-provided response (which can be empty) | ||
# | ||
# @return [void] | ||
# @param [Hash] options | ||
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. Minor: this param should be placed before th return Yard directive. |
||
def iterate_pages(client, method, *arguments, parent: nil, **options) | ||
options = DEFAULT_REQUEST_OPTIONS.merge(options) | ||
|
||
|
@@ -442,6 +452,7 @@ def iterate_pages(client, method, *arguments, parent: nil, **options) | |
# This is wrapper with rescue block | ||
# | ||
# @return [Object] returns exactly the same, what you put in the block, but wrap it with begin-rescue block | ||
# @param [Proc] block | ||
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. Yard probably has some notation for you here, specific to blocks. We don't want the docs to show that this method takes a positional argument. Does the rendered Yard docs HTML show that? |
||
def check_github_response(&block) | ||
Retriable.retriable(retry_options, &block) | ||
rescue MovedPermanentlyError => e | ||
|
@@ -453,6 +464,8 @@ def check_github_response(&block) | |
end | ||
|
||
# Presents the exception, and the aborts with the message. | ||
# @param [Object] message | ||
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. Message is a String. |
||
# @param [Object] error | ||
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. Error is Exception I guess. |
||
def fail_with_message(error, message) | ||
Helper.log.error("#{error.class}: #{error.message}") | ||
sys_abort(message) | ||
|
@@ -483,6 +496,7 @@ def retry_callback | |
end | ||
end | ||
|
||
# @param [Object] msg | ||
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 type is String. |
||
def sys_abort(msg) | ||
abort(msg) | ||
end | ||
|
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.
It's debatable whether this commit belongs in this PR.
I would probably prefer a Rubocop cop or something that auto-corrects this.
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.
Yard-junk is a tool for this. Finding errors and presenting them in a small report.