Skip to content

Commit

Permalink
chore: Update rubocop and apply new cops (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimadactyl authored Nov 5, 2024
1 parent 015073e commit c572fc1
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ group :development do
gem 'letter_opener'
gem 'rails-erd'
gem 'rdoc'
gem 'rubocop', '1.62.0', require: false
gem 'rubocop', '1.68.0', require: false
gem 'rubocop-graphql', '1.5.4', require: false
gem 'rubocop-minitest', '0.35.1', require: false
gem 'rubocop-performance', '1.22.1', require: false
gem 'rubocop-rails', '2.24.1', require: false
gem 'rubocop-rails', '2.27.0', require: false
gem 'rubocop-rake', require: false
gem 'spring'
# gem 'spring-watcher-listen'
Expand Down
32 changes: 17 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (0.4.5)
rexml
Expand Down Expand Up @@ -219,16 +219,16 @@ GEM
invisible_captcha (2.2.0)
rails (>= 5.2)
io-console (0.7.2)
irb (1.11.2)
rdoc
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jquery-rails (4.5.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jsbundling-rails (1.0.2)
railties (>= 6.0.0)
json (2.7.2)
json (2.7.5)
json-canonicalization (0.3.0)
json-ld (3.2.3)
htmlentities (~> 4.3)
Expand All @@ -253,8 +253,11 @@ GEM
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.7.1)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.4)
matrix (0.4.2)
method_source (1.0.0)
Expand All @@ -265,9 +268,9 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.22.3)
minitest-rails (7.1.0)
minitest-rails (7.1.1)
minitest (~> 5.20)
railties (~> 7.1.0)
railties (>= 7.1.0, < 8.0.0)
minitest-rails-capybara (0.0.2)
capybara
minitest-rails
Expand Down Expand Up @@ -385,15 +388,14 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.7)
rubocop (1.62.0)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
Expand All @@ -406,10 +408,10 @@ GEM
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rails (2.24.1)
rubocop-rails (2.27.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
Expand Down Expand Up @@ -555,11 +557,11 @@ DEPENDENCIES
rails-controller-testing
rails-erd
rdoc
rubocop (= 1.62.0)
rubocop (= 1.68.0)
rubocop-graphql (= 1.5.4)
rubocop-minitest (= 0.35.1)
rubocop-performance (= 1.22.1)
rubocop-rails (= 2.24.1)
rubocop-rails (= 2.27.0)
rubocop-rake
sass-rails (= 6.0.0)
select2-rails
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/event_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def events_by_filter(**args)
end
end

query = query.where('dtstart >= ?', from_date)
query = query.where(dtstart: from_date..)

if args[:to_date].present?
if args[:to_date] =~ /^\s*(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/
Expand All @@ -80,7 +80,7 @@ def events_by_filter(**args)
raise GraphQL::ExecutionError, "toDate not in 'YYYY-MM-DD HH:MM' format"
end

query = query.where('dtstart < ?', to_date)
query = query.where(dtstart: ...to_date)
end

if args[:neighbourhood_id].present?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def next_url(next_event)
period: @period,
sort: @sort,
repeating: @repeating
}.keep_if { |_key, value| value.present? }
}.compact_blank!

events_by_date_path(opts)
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/calendar_importer/events/linked_data_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LinkedDataEvent < Base
attr_reader :uid, :start_time, :end_time, :summary, :description, :location

def initialize(data)
super data
super

@url = data['url']
@description = data['description']
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/calendar_importer/parsers/ld_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class LdJson < Base
KEY = 'ld-json'

def initialize(calendar, options = {})
super calendar, options
super
end

DOMAINS = ['various'].freeze
Expand Down
8 changes: 2 additions & 6 deletions app/jobs/calendar_importer/parsers/manchester_uni.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ def self.allowlist_pattern
end

def import_events_from(data)
events = []

data.xpath('//ns:event').each do |event|
events << CalendarImporter::Events::ManchesterUniEvent.new(event)
events = data.xpath('//ns:event').map do |event|
CalendarImporter::Events::ManchesterUniEvent.new(event)
end

events
end
end
end
2 changes: 1 addition & 1 deletion app/models/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def requires_default_location?
# This uses PaperTrail to get historical records of the Event models, including deletes
# It does this to show a "event added" / "event removed" thing
def recent_activity
versions = PaperTrail::Version.with_item_keys('Event', event_ids).where('created_at >= ?', 2.weeks.ago)
versions = PaperTrail::Version.with_item_keys('Event', event_ids).where(created_at: 2.weeks.ago..)
versions = versions.or(PaperTrail::Version.destroys
.where("item_type = 'Event' AND object @> ? AND created_at >= ?",
{ calendar_id: id }.to_json, 2.weeks.ago))
Expand Down
11 changes: 5 additions & 6 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class Event < ApplicationRecord
# Find by day onwards
scope :future, lambda { |day|
day_start = day.midnight # 2024-04-01 00:00:00 +0100
where('dtstart >= ?',
day_start)
where(dtstart: day_start..)
}

# For the API eventFilter find by neighbourhood
Expand Down Expand Up @@ -81,7 +80,7 @@ class Event < ApplicationRecord
'lower(addresses.postcode) in (:partner_postcodes))',
partner_ids: partners.map(&:id),
partner_names: partners.map { |p| p.name.downcase },
partner_postcodes: partners.map(&:address).keep_if(&:present?).map { |a| a.postcode.downcase }
partner_postcodes: partners.map(&:address).compact_blank!.map { |a| a.postcode.downcase }
)
else
left_joins(:address)
Expand Down Expand Up @@ -115,11 +114,11 @@ class Event < ApplicationRecord
scope :one_off_events_only, -> { where(rrule: false) }
scope :one_off_events_first, -> { order(rrule: :asc) }

scope :upcoming, -> { where('dtstart >= ?', DateTime.current.beginning_of_day) }
scope :past, -> { where('dtstart <= ?', DateTime.current.beginning_of_day) }
scope :upcoming, -> { where(dtstart: DateTime.current.beginning_of_day..) }
scope :past, -> { where(dtstart: ..DateTime.current.beginning_of_day) }

# Global feed
scope :ical_feed, -> { where('dtstart >= ?', Time.now - 1.week).where('dtend < ?', Time.now + 1.month) }
scope :ical_feed, -> { where(dtstart: (Time.now - 1.week)..).where(dtend: ...(Time.now + 1.month)) }

def repeat_frequency
rrule[0]['table']['frequency'].titleize if rrule
Expand Down
1 change: 1 addition & 0 deletions config/initializers/application_controller_renderer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# ActiveSupport::Reloader.to_prepare do
Expand Down
1 change: 1 addition & 0 deletions config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
Expand Down
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 1 addition & 0 deletions config/initializers/new_framework_defaults_6_0.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 6.0 upgrade.
Expand Down
4 changes: 2 additions & 2 deletions test/integration/robots_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class RobotsIntegrationTest < ActionDispatch::IntegrationTest

test 'robots.txt blocks site if site is unpublished' do
get "http://#{@unpublished_site.slug}.lvh.me:3000/robots.txt"
assert_response 200
assert_response :ok
assert_equal forbid_string, response.body
end

test 'robots.txt has default comment if site is published' do
get "http://#{@published_site.slug}.lvh.me:3000/robots.txt"
assert_response 200
assert_response :ok
assert_equal '# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file', response.body
end

Expand Down
1 change: 1 addition & 0 deletions test/system/collections_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

## frozen_string_literal: true
#
# require 'application_system_test_case'
Expand Down

0 comments on commit c572fc1

Please sign in to comment.