Skip to content

Commit

Permalink
Switch to using double quotes by default
Browse files Browse the repository at this point in the history
I give up: I wanted to try to use the "community default", but all my
tooling (snippets etc) is set up using double quotes, so it's just
friction which is annoying.

Anyway it seems like the community is far from being in agreement on
this topic:

  rubocop/rubocop#5306
  • Loading branch information
dgmstuart committed Mar 25, 2023
1 parent ca47e39 commit e7be301
Show file tree
Hide file tree
Showing 132 changed files with 1,852 additions and 1,851 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Style/NumericLiterals:
- spec/support/**/*.rb

Style/StringLiterals:
EnforcedStyle: double_quotes
Exclude:
# Fully and mostly autogenerated config files
- config/environments/*.rb
Expand Down
116 changes: 58 additions & 58 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

ruby '3.2.1'
ruby "3.2.1"

gem 'rails', '~> 6.1.5', '>= 6.1.5.1'
gem "rails", "~> 6.1.5", ">= 6.1.5.1"

gem 'actionpack-action_caching' # to support pre rails-4 style action caching
gem 'audited'
gem 'bootsnap'
gem 'coffee-rails'
gem 'geocoder'
gem 'haml-rails'
gem 'http'
gem 'jbuilder'
gem 'jsbundling-rails'
gem 'memcachier'
gem 'net-imap', require: false
gem 'net-pop', require: false
gem 'net-smtp', require: false
gem 'omniauth-facebook'
gem 'omniauth-rails_csrf_protection'
gem 'pg'
gem 'pry-rails'
gem 'puma'
gem 'rack-attack'
gem 'rails-observers' # to support pre rails-4 style cache sweeping
gem 'redcarpet' # Markdown
gem 'rollbar'
gem 'rss'
gem 'sassc-rails'
gem 'sprockets'
gem 'stimulus-rails'
gem 'strip_attributes'
gem 'test-unit'
gem "actionpack-action_caching" # to support pre rails-4 style action caching
gem "audited"
gem "bootsnap"
gem "coffee-rails"
gem "geocoder"
gem "haml-rails"
gem "http"
gem "jbuilder"
gem "jsbundling-rails"
gem "memcachier"
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
gem "omniauth-facebook"
gem "omniauth-rails_csrf_protection"
gem "pg"
gem "pry-rails"
gem "puma"
gem "rack-attack"
gem "rails-observers" # to support pre rails-4 style cache sweeping
gem "redcarpet" # Markdown
gem "rollbar"
gem "rss"
gem "sassc-rails"
gem "sprockets"
gem "stimulus-rails"
gem "strip_attributes"
gem "test-unit"

group :development do
gem 'bullet'
gem 'listen'
gem 'rack-mini-profiler', require: false
gem "bullet"
gem "listen"
gem "rack-mini-profiler", require: false
end

group :development, :test do
gem 'dotenv-rails'
gem 'factory_bot_rails'
gem 'faker'
gem 'rb-fsevent'
gem 'rspec-rails'
gem 'rubocop', '~> 1.27.0', require: false
gem 'rubocop-faker', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', '~> 2.9.0', require: false
gem "dotenv-rails"
gem "factory_bot_rails"
gem "faker"
gem "rb-fsevent"
gem "rspec-rails"
gem "rubocop", "~> 1.27.0", require: false
gem "rubocop-faker", require: false
gem "rubocop-rails", require: false
gem "rubocop-rspec", "~> 2.9.0", require: false
end

group :test do
gem 'capybara'
gem 'climate_control'
gem 'elabs_matchers'
gem 'launchy'
gem 'rails-controller-testing' # TODO: refactor tests so that we don't need this
gem 'shoulda-matchers'
gem 'simplecov', require: false
gem 'timecop'
gem 'vcr'
gem 'webdrivers', require: false
gem 'webmock'
gem "capybara"
gem "climate_control"
gem "elabs_matchers"
gem "launchy"
gem "rails-controller-testing" # TODO: refactor tests so that we don't need this
gem "shoulda-matchers"
gem "simplecov", require: false
gem "timecop"
gem "vcr"
gem "webdrivers", require: false
gem "webmock"
end

group :production do
gem 'connection_pool'
gem 'dalli'
gem 'oj' # For Rollbar
gem 'rack-canonical-host'
gem "connection_pool"
gem "dalli"
gem "oj" # For Rollbar
gem "rack-canonical-host"
end
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require File.expand_path('config/application', __dir__)
require File.expand_path("config/application", __dir__)

task lint_styles: :environment do
system('yarn run stylelint app/assets/stylesheets') || exit($CHILD_STATUS.exitstatus)
system("yarn run stylelint app/assets/stylesheets") || exit($CHILD_STATUS.exitstatus)
end

if Rails.env.test?
require 'rubocop/rake_task'
require "rubocop/rake_task"
RuboCop::RakeTask.new

task default: %i[spec rubocop lint_styles]
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery

require 'digest/md5'
require "digest/md5"

def today
@today = if Date.local_today.midnight > Time.local_now.ago(4.hours)
Expand All @@ -17,7 +17,7 @@ def today
def sign_out; end

def not_found
head :not_found, 'content_type' => 'text/plain'
head :not_found, "content_type" => "text/plain"
end

protected
Expand Down
40 changes: 20 additions & 20 deletions app/controllers/audit_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ def show
end
end

require 'rss'
require "rss"

def audits_rss(audits) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
RSS::Maker.make('atom') do |maker|
maker.channel.author = 'Swing Out London'
RSS::Maker.make("atom") do |maker|
maker.channel.author = "Swing Out London"
maker.channel.updated = Audit.maximum(:created_at).iso8601
maker.channel.id = 'https://www.swingoutlondon.com/'
maker.channel.id = "https://www.swingoutlondon.com/"
link = maker.channel.links.new_link
link.href = 'https://www.swingoutlondon.com/audit_log.atom'
link.rel = 'self'
maker.channel.title = 'Swing Out London Audit Log'
maker.channel.description = 'Audit Log for Swing Out London'
link.href = "https://www.swingoutlondon.com/audit_log.atom"
link.rel = "self"
maker.channel.title = "Swing Out London Audit Log"
maker.channel.description = "Audit Log for Swing Out London"

audits.each do |audit|
editor = Editor.build(audit)
Expand All @@ -40,7 +40,7 @@ def audits_rss(audits) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
end

def audit_title(action, record)
if action == 'destroy'
if action == "destroy"
"Delete #{record.class} (id: #{record.id})"
else
"#{action.capitalize} #{auditable_name(record)} (id: #{record.id})"
Expand All @@ -49,37 +49,37 @@ def audit_title(action, record)

def record(class_name, id)
{
'Event' => -> { Event.find_by(id: id) || Event.new(id: id) },
'Venue' => -> { Venue.find_by(id: id) || Venue.new(id: id) },
'Organiser' => -> { Organiser.find_by(id: id) || Organiser.find(id: id) }
"Event" => -> { Event.find_by(id: id) || Event.new(id: id) },
"Venue" => -> { Venue.find_by(id: id) || Venue.new(id: id) },
"Organiser" => -> { Organiser.find_by(id: id) || Organiser.find(id: id) }
}.fetch(class_name).call
end

def auditable_name(record)
{
'Event' => -> { auditable_event_name(record) },
'Venue' => -> { "Venue: \"#{record.name}\"" },
'Organiser' => -> { "Organiser: \"#{record.name}\"" }
"Event" => -> { auditable_event_name(record) },
"Venue" => -> { "Venue: \"#{record.name}\"" },
"Organiser" => -> { "Organiser: \"#{record.name}\"" }
}.fetch(record.class.name).call
end

def auditable_event_name(record)
if record.title.blank? && record.has_class? && !record.has_social?
'Class'
"Class"
else
"Event: \"#{record.title}\""
end
end

def audit_show_link(record)
{
'Event' => -> { event_url(record) },
'Venue' => -> { venue_url(record) },
'Organiser' => -> { organiser_url(record) }
"Event" => -> { event_url(record) },
"Venue" => -> { venue_url(record) },
"Organiser" => -> { organiser_url(record) }
}.fetch(record.class.name).call
end

def authenticate
head :unauthorized unless params[:password] == ENV.fetch('AUDIT_LOG_PASSWORD')
head :unauthorized unless params[:password] == ENV.fetch("AUDIT_LOG_PASSWORD")
end
end
4 changes: 2 additions & 2 deletions app/controllers/cms_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CmsBaseController < ApplicationController
before_action :authenticate

layout 'cms'
layout "cms"

helper_method :current_user
attr_reader :current_user
Expand All @@ -19,7 +19,7 @@ def authenticate
end

def audit_user
{ 'auth_id' => current_user.auth_id, 'name' => current_user.name }
{ "auth_id" => current_user.auth_id, "name" => current_user.name }
end

def login_session
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

class EventsController < CmsBaseController
def index
@current_events = Event.current.includes(:venue, :social_organiser, :class_organiser).order('frequency, updated_at')
@gigs = Event.gigs.includes(:venue, :social_organiser, :class_organiser).order('title')
@archived_events = Event.archived.includes(:venue, :social_organiser, :class_organiser).order('title')
@current_events = Event.current.includes(:venue, :social_organiser, :class_organiser).order("frequency, updated_at")
@gigs = Event.gigs.includes(:venue, :social_organiser, :class_organiser).order("title")
@archived_events = Event.archived.includes(:venue, :social_organiser, :class_organiser).order("title")
end

def show
Expand All @@ -27,10 +27,10 @@ def create
@event = Event.new(event_params)

if @event.save
flash[:notice] = t('flash.success', model: 'Event', action: 'created')
flash[:notice] = t("flash.success", model: "Event", action: "created")
redirect_to(@event)
else
render action: 'new'
render action: "new"
end
end

Expand All @@ -41,10 +41,10 @@ def update
update_params = event_params.merge!(audit_comment)

if @event.update(update_params)
flash[:notice] = t('flash.success', model: 'Event', action: 'updated')
flash[:notice] = t("flash.success", model: "Event", action: "updated")
redirect_to(@event)
else
render action: 'edit'
render action: "edit"
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/external_events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ExternalEventsController < CmsBaseController
layout 'organiser'
layout "organiser"

def edit
@event = Event.find_by!(organiser_token: params[:id])
Expand All @@ -14,10 +14,10 @@ def update
update_params = event_params.merge!(audit_comment)

if @event.update(update_params)
flash[:success] = t('flash.success', model: 'Event', action: 'updated')
flash[:success] = t("flash.success", model: "Event", action: "updated")
redirect_to edit_external_event_path(@event.organiser_token)
else
render action: 'edit'
render action: "edit"
end
end

Expand Down
14 changes: 7 additions & 7 deletions app/controllers/maps_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class MapsController < ApplicationController
layout 'map'
layout "map"

caches_action :socials, :classes,
cache_path: proc { |c| c.params.permit(:day, :date, :venue_id) },
Expand All @@ -11,7 +11,7 @@ class MapsController < ApplicationController

def classes
# Varnish will cache the page for 3600 seconds = 1 hour:
response.headers['Cache-Control'] = 'public, max-age=3600'
response.headers["Cache-Control"] = "public, max-age=3600"

@day = Maps::Classes::DayParser.parse(params[:day], today)
venues = Maps::Classes::VenueQuery.new(@day).venues
Expand All @@ -24,18 +24,18 @@ def classes
venues: venues,
highlighted_venue_id: params[:venue_id].to_i,
marker_info_builder: marker_info_builder,
info_window_partial: 'classes_map_info',
info_window_partial: "classes_map_info",
renderer: self
)
rescue Maps::Classes::DayParser::NonDayError
flash[:warn] = t('flash.map.days_of_week')
flash[:warn] = t("flash.map.days_of_week")
logger.warn("Not a recognised day: #{@day}")
redirect_to map_classes_path
end

def socials
# Varnish will cache the page for 3600 seconds = 1 hour:
response.headers['Cache-Control'] = 'public, max-age=3600'
response.headers["Cache-Control"] = "public, max-age=3600"

@map_dates = Maps::Socials::Dates.new(params[:date], today)

Expand All @@ -48,11 +48,11 @@ def socials
venues: venues,
highlighted_venue_id: params[:venue_id].to_i,
marker_info_builder: marker_info_builder,
info_window_partial: 'socials_map_info',
info_window_partial: "socials_map_info",
renderer: self
)
rescue Maps::Socials::Dates::DateOutOfRangeError
flash[:warn] = t('flash.map.14_days')
flash[:warn] = t("flash.map.14_days")
logger.warn("Not a date in the visible range: #{@date}")
redirect_to map_socials_path
end
Expand Down
Loading

0 comments on commit e7be301

Please sign in to comment.