diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b8e7fac..59eea55 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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 @@ -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 @@ -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' @@ -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 diff --git a/bin/commands/pr.rb b/bin/commands/pr.rb index bf771a0..825d531 100644 --- a/bin/commands/pr.rb +++ b/bin/commands/pr.rb @@ -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 diff --git a/lib/github/pull_requests.rb b/lib/github/pull_requests.rb index ba10f27..5ab8562 100644 --- a/lib/github/pull_requests.rb +++ b/lib/github/pull_requests.rb @@ -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 @@ -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