Decrease ABC threshold to 55.25
This commit is contained in:
parent
6d6223ecdb
commit
d807d3810f
3 changed files with 49 additions and 42 deletions
|
@ -624,7 +624,7 @@ Style/PredicateName:
|
||||||
# branches, and conditions.
|
# branches, and conditions.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Max: 56.96
|
Max: 55.25
|
||||||
|
|
||||||
# This cop checks if the length of a block exceeds some maximum value.
|
# This cop checks if the length of a block exceeds some maximum value.
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Decrease ABC threshold to 55.25
|
||||||
|
merge_request: 13904
|
||||||
|
author: Maxim Rydkin
|
||||||
|
type: other
|
|
@ -226,52 +226,54 @@ module Github
|
||||||
while url
|
while url
|
||||||
response = Github::Client.new(options).get(url, state: :all, sort: :created, direction: :asc)
|
response = Github::Client.new(options).get(url, state: :all, sort: :created, direction: :asc)
|
||||||
|
|
||||||
response.body.each do |raw|
|
response.body.each { |raw| populate_issue(raw) }
|
||||||
representation = Github::Representation::Issue.new(raw, options)
|
|
||||||
|
|
||||||
begin
|
|
||||||
# Every pull request is an issue, but not every issue
|
|
||||||
# is a pull request. For this reason, "shared" actions
|
|
||||||
# for both features, like manipulating assignees, labels
|
|
||||||
# and milestones, are provided within the Issues API.
|
|
||||||
if representation.pull_request?
|
|
||||||
next unless representation.has_labels?
|
|
||||||
|
|
||||||
merge_request = MergeRequest.find_by!(target_project_id: project.id, iid: representation.iid)
|
|
||||||
merge_request.update_attribute(:label_ids, label_ids(representation.labels))
|
|
||||||
else
|
|
||||||
next if Issue.where(iid: representation.iid, project_id: project.id).exists?
|
|
||||||
|
|
||||||
author_id = user_id(representation.author, project.creator_id)
|
|
||||||
issue = Issue.new
|
|
||||||
issue.iid = representation.iid
|
|
||||||
issue.project_id = project.id
|
|
||||||
issue.title = representation.title
|
|
||||||
issue.description = format_description(representation.description, representation.author)
|
|
||||||
issue.state = representation.state
|
|
||||||
issue.label_ids = label_ids(representation.labels)
|
|
||||||
issue.milestone_id = milestone_id(representation.milestone)
|
|
||||||
issue.author_id = author_id
|
|
||||||
issue.assignee_ids = [user_id(representation.assignee)]
|
|
||||||
issue.created_at = representation.created_at
|
|
||||||
issue.updated_at = representation.updated_at
|
|
||||||
issue.save!(validate: false)
|
|
||||||
|
|
||||||
# Fetch comments
|
|
||||||
if representation.has_comments?
|
|
||||||
comments_url = "/repos/#{repo}/issues/#{issue.iid}/comments"
|
|
||||||
fetch_comments(issue, :comment, comments_url)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
error(:issue, representation.url, e.message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
url = response.rels[:next]
|
url = response.rels[:next]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def populate_issue(raw)
|
||||||
|
representation = Github::Representation::Issue.new(raw, options)
|
||||||
|
|
||||||
|
begin
|
||||||
|
# Every pull request is an issue, but not every issue
|
||||||
|
# is a pull request. For this reason, "shared" actions
|
||||||
|
# for both features, like manipulating assignees, labels
|
||||||
|
# and milestones, are provided within the Issues API.
|
||||||
|
if representation.pull_request?
|
||||||
|
return unless representation.has_labels?
|
||||||
|
|
||||||
|
merge_request = MergeRequest.find_by!(target_project_id: project.id, iid: representation.iid)
|
||||||
|
merge_request.update_attribute(:label_ids, label_ids(representation.labels))
|
||||||
|
else
|
||||||
|
return if Issue.where(iid: representation.iid, project_id: project.id).exists?
|
||||||
|
|
||||||
|
author_id = user_id(representation.author, project.creator_id)
|
||||||
|
issue = Issue.new
|
||||||
|
issue.iid = representation.iid
|
||||||
|
issue.project_id = project.id
|
||||||
|
issue.title = representation.title
|
||||||
|
issue.description = format_description(representation.description, representation.author)
|
||||||
|
issue.state = representation.state
|
||||||
|
issue.label_ids = label_ids(representation.labels)
|
||||||
|
issue.milestone_id = milestone_id(representation.milestone)
|
||||||
|
issue.author_id = author_id
|
||||||
|
issue.assignee_ids = [user_id(representation.assignee)]
|
||||||
|
issue.created_at = representation.created_at
|
||||||
|
issue.updated_at = representation.updated_at
|
||||||
|
issue.save!(validate: false)
|
||||||
|
|
||||||
|
# Fetch comments
|
||||||
|
if representation.has_comments?
|
||||||
|
comments_url = "/repos/#{repo}/issues/#{issue.iid}/comments"
|
||||||
|
fetch_comments(issue, :comment, comments_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
error(:issue, representation.url, e.message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_comments(noteable, type, url, klass = Note)
|
def fetch_comments(noteable, type, url, klass = Note)
|
||||||
while url
|
while url
|
||||||
comments = Github::Client.new(options).get(url)
|
comments = Github::Client.new(options).get(url)
|
||||||
|
|
Loading…
Reference in a new issue