Skip to content

Commit

Permalink
Exclude website authors that skews numbers.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Oct 9, 2023
1 parent d493d96 commit 24bc6f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-08-16 20:46:04 UTC using RuboCop version 1.36.0.
# on 2023-10-09 16:15:45 UTC using RuboCop version 1.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -52,7 +52,7 @@ Lint/UselessAssignment:
Metrics/ClassLength:
Max: 105

# Offense count: 2
# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 9
Expand All @@ -62,12 +62,13 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 10

# Offense count: 4
# Offense count: 5
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, db, id, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/github/item.rb'
- 'lib/github/pull_requests.rb'
- 'lib/github/repo.rb'
- 'lib/github/repos.rb'

Expand Down Expand Up @@ -187,11 +188,12 @@ Style/FrozenStringLiteralComment:
- 'spec/support/github.rb'
- 'spec/support/without_data_files.rb'

# Offense count: 1
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
Style/HashEachMethods:
Exclude:
- 'bin/commands/pr.rb'
- 'lib/github/repos.rb'

# Offense count: 2
Expand Down
2 changes: 1 addition & 1 deletion bin/commands/pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Commands

if !options['ignore-unknown'] && prs.contributors[:unknown]&.any?
puts 'Add the following users to either data/users/members.txt, external.txt, students.txt or contractors.txt and re-run.'
prs.contributors[:unknown].keys.take(10).each do |user|
prs.contributors[:unknown].keys.each do |user|
puts user
system "open https://github.com/#{user}"
end
Expand Down
12 changes: 11 additions & 1 deletion lib/github/pull_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def page(options)
raise 'There are 1000+ PRs returned from a single query, reduce --page.' if data.size >= 1000

data.reject do |pr|
pr.user.type == 'Bot' || GitHub::Data.backports.any? { |b| pr.title&.downcase&.include?(b) }
pr.user.type == 'Bot' || GitHub::Data.backports.any? { |b| pr.title&.downcase&.include?(b) } || project_website_authors?(pr)
end
end

Expand All @@ -44,5 +44,15 @@ def query(options = {})
].compact
).compact.join(' ')
end

# exclude a high number of misleading contributions from a student program
# modifying https://github.com/opensearch-project/project-website/commits/main/_authors
def project_website_authors?(pr)
return false unless pr.repository_url == 'https://api.github.com/repos/opensearch-project/project-website'

repo = pr.repository_url.split('/')[4, 2].join('/')
files = $github.pull_request_files(repo, pr.number)
files.all? { |file| file.filename.start_with?('_authors/') }
end
end
end

0 comments on commit 24bc6f3

Please sign in to comment.