Skip to content

Commit f488a50

Browse files
Fix further
Signed-off-by: David A. Wheeler <[email protected]>
1 parent e6d773d commit f488a50

15 files changed

+32
-35
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ plugins:
3333

3434
AllCops:
3535
EnabledByDefault: true
36-
TargetRubyVersion: 2.5
36+
TargetRubyVersion: 3.3
3737
DisplayCopNames: true
3838
DisplayStyleGuide: true
3939
Include:

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def append_info_to_payload(payload)
101101

102102
# Combined cache control header value for CDN surrogate control
103103
BADGE_CACHE_SURROGATE_CONTROL =
104-
"max-age=#{BADGE_CACHE_MAX_AGE}, stale-if-error=#{BADGE_CACHE_STALE_AGE}"
104+
"max-age=#{BADGE_CACHE_MAX_AGE}, stale-if-error=#{BADGE_CACHE_STALE_AGE}".freeze
105105

106106
# Set default cache control - don't externally cache.
107107
# This is the safe behavior, so we make it the default.

app/controllers/projects_controller.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
require 'addressable/uri'
88
require 'net/http'
9+
require 'set'
910

1011
# rubocop:disable Metrics/ClassLength
1112
class ProjectsController < ApplicationController
@@ -53,7 +54,7 @@ class ProjectsController < ApplicationController
5354
).freeze
5455

5556
# Used to validate deletion rationale.
56-
AT_LEAST_15_NON_WHITESPACE = /\A\s*(\S\s*){15}.*/.freeze
57+
AT_LEAST_15_NON_WHITESPACE = /\A\s*(\S\s*){15}.*/
5758

5859
# as= values, which redirect to alternative views
5960
ALLOWED_AS = %w[badge entry].freeze
@@ -428,7 +429,7 @@ def reminders_summary
428429

429430
# Regex pattern for validating repository rights changes.
430431
# Rights changes, if provided, must match this pattern.
431-
VALID_ADD_RIGHTS_CHANGES = /\A *[+-] *\d+ *(, *\d+)*\z/.freeze
432+
VALID_ADD_RIGHTS_CHANGES = /\A *[+-] *\d+ *(, *\d+)*\z/
432433

433434
# Number of days before a user may change repo_url.
434435
# NOTE: If you change this value, you may also need to change
@@ -590,7 +591,7 @@ def require_adequate_deletion_rationale
590591
# rubocop:disable Metrics/MethodLength
591592
def update_additional_rights_forced(id, new_additional_rights)
592593
command = new_additional_rights.first
593-
new_list = new_additional_rights[1..-1].split(',').map(&:to_i).uniq.sort
594+
new_list = new_additional_rights.drop(1).split(',').map(&:to_i).uniq.sort
594595
if command == '-'
595596
AdditionalRight.where(project_id: id, user_id: new_list).destroy_all
596597
else # '+'
@@ -769,7 +770,7 @@ def repo_data(github = nil)
769770

770771
repos.map do |repo|
771772
[repo.full_name, repo.fork, repo.homepage, repo.html_url]
772-
end.compact
773+
end
773774
end
774775
# rubocop:enable Metrics/AbcSize
775776
# rubocop:enable Style/MethodCalledOnDoEndBlock, Metrics/MethodLength

app/helpers/projects_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def tiered_percent_as_string(value)
165165
# rubocop:enable Metrics/MethodLength
166166

167167
# We sometimes insert <wbr> after sequences of these characters.
168-
WORD_BREAK_DIVIDERS = /([,_\-.]+)/.freeze
168+
WORD_BREAK_DIVIDERS = /([,_\-.]+)/
169169

170170
# This text is considered safe, so we can directly mark it as such.
171171
# rubocop:disable Rails/OutputSafety

app/helpers/sessions_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module SessionsHelper
1010
RESET_SESSION_TIMER = 1.hour # Active sessions older than this reset timer
1111
GITHUB_PATTERN = %r{
1212
\Ahttps://github.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/?\Z
13-
}x.freeze
13+
}x
1414
require 'uri'
1515

1616
# Remove the "locale=value", if any, from the url_query provided

app/lib/hardened_sites_detective.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Determine if project sites support HTTPS
88

9+
require 'set'
10+
911
class HardenedSitesDetective < Detective
1012
# All of the security-hardening headers that need to be present to pass.
1113
# They're listed in the same order as the criteria text.

app/lib/how_access_repo_files_detective.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class HowAccessRepoFilesDetective < Detective
1313
INPUTS = [:repo_url].freeze
1414
OUTPUTS = [:repo_files].freeze # Ask :repo_files.get("FILENAME") for files.
1515

16-
GITHUB_REPO = %r{https?://github.com/([\w\.-]*)/([\w\.-]*)(.git|/)?}.freeze
16+
GITHUB_REPO = %r{https?://github.com/([\w\.-]*)/([\w\.-]*)(.git|/)?}
1717
def analyze(_evidence, current)
1818
repo_url = current[:repo_url]
1919
return {} if repo_url.blank?

app/models/project.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Project < ApplicationRecord
4848

4949
# All badge levels as IDs. Useful for enumerating "all levels" as:
5050
# Project::LEVEL_IDS.each do |level| ... end
51-
LEVEL_ID_NUMBERS = (0..(COMPLETED_BADGE_LEVELS.length - 1)).freeze
51+
LEVEL_ID_NUMBERS = (0..(COMPLETED_BADGE_LEVELS.length - 1))
5252
LEVEL_IDS = LEVEL_ID_NUMBERS.map(&:to_s)
5353

5454
PROJECT_OTHER_FIELDS = %i[
@@ -173,7 +173,7 @@ class Project < ApplicationRecord
173173
# We have to allow embedded spaces, e.g., "Jupyter Notebook".
174174
VALID_LANGUAGE_LIST =
175175
%r{\A(|-| ([A-Za-z0-9!\#$%'()*+.\/\:;=?@\[\]^~ -]+
176-
(,\ ?[A-Za-z0-9!\#$%'()*+.\/\:;=?@\[\]^~ -]+)*))\Z}x.freeze
176+
(,\ ?[A-Za-z0-9!\#$%'()*+.\/\:;=?@\[\]^~ -]+)*))\Z}x
177177
validates :implementation_languages,
178178
length: { maximum: MAX_SHORT_STRING_LENGTH },
179179
format: {
@@ -536,8 +536,7 @@ def self.projects_to_remind
536536
.where('badge_percentage_0 < 100')
537537
.where('lost_passing_at IS NULL OR lost_passing_at < ?',
538538
LOST_PASSING_REMINDER.days.ago)
539-
.where('projects.updated_at < ?',
540-
LAST_UPDATED_REMINDER.days.ago)
539+
.where('projects.updated_at < ?', LAST_UPDATED_REMINDER.days.ago)
541540
.where('last_reminder_at IS NULL OR last_reminder_at < ?',
542541
LAST_SENT_REMINDER.days.ago)
543542
.joins(:user).references(:user) # Need this to check email address
@@ -576,7 +575,7 @@ def self.recently_reminded
576575
.select('projects.*, users.encrypted_email as user_encrypted_email')
577576
.joins(:user).references(:user) # Need this to check email address
578577
.where('last_reminder_at IS NOT NULL')
579-
.where('last_reminder_at >= ?', 14.days.ago)
578+
.where(last_reminder_at: 14.days.ago..)
580579
.reorder('last_reminder_at')
581580
end
582581

app/models/project_stat.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,9 @@ def stamp
4444
next if completion.to_i.zero? # Don't record percentage "0" > level 0
4545

4646
public_send :"percent_1_ge_#{completion}=",
47-
Project.where(
48-
'badge_percentage_1 >= ?',
49-
completion.to_i
50-
).count
47+
Project.where(badge_percentage_1: completion.to_i..).count
5148
public_send :"percent_2_ge_#{completion}=",
52-
Project.where(
53-
'badge_percentage_2 >= ?',
54-
completion.to_i
55-
).count
49+
Project.where(badge_percentage_2: completion.to_i..).count
5650
end
5751
self.projects_edited = Project.where('created_at < updated_at').count
5852

@@ -142,8 +136,8 @@ def stamp
142136
# Note that created_at is an index, so this should be extremely fast.
143137
def self.last_in_month(query_date)
144138
ProjectStat
145-
.where('created_at >= ?', query_date.beginning_of_month)
146-
.where('created_at <= ?', query_date.end_of_month)
139+
.where(created_at: query_date.beginning_of_month..)
140+
.where(created_at: ..query_date.end_of_month)
147141
.reorder(:created_at).last
148142
end
149143

app/validators/text_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# SPDX-License-Identifier: MIT
66

77
class TextValidator < ActiveModel::EachValidator
8-
INVALID_CONTROL = /[\x01-\x08\x0b\x0c\x0e-\x1f]/.freeze
8+
INVALID_CONTROL = /[\x01-\x08\x0b\x0c\x0e-\x1f]/
99
def text_acceptable?(value)
1010
return true if value.nil?
1111
return false unless value.valid_encoding?

0 commit comments

Comments
 (0)