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 8fffc28 commit 8118183
Show file tree
Hide file tree
Showing 134 changed files with 1,874 additions and 1,873 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
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ApplicationController < ActionController::Base
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 @@ -4,7 +4,7 @@ class CmsBaseController < ActionController::Base # rubocop:disable Rails/Applica
before_action :authenticate
before_action :set_controller_and_action_name

layout 'cms'
layout "cms"

helper_method :current_user
attr_reader :current_user
Expand All @@ -20,7 +20,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
2 changes: 1 addition & 1 deletion app/controllers/info_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def privacy; end

def set_cache_control_on_static_pages
# Varnish will cache the page for 43200 seconds = 12 hours:
response.headers['Cache-Control'] = 'public, max-age=43200'
response.headers["Cache-Control"] = "public, max-age=43200"
end
end
6 changes: 3 additions & 3 deletions app/controllers/listings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class ListingsController < ApplicationController
layout 'website'
layout "website"

caches_action :index, cache_path: 'website#index', layout: true, expires_in: 1.hour, race_condition_ttl: 10
caches_action :index, cache_path: "website#index", layout: true, expires_in: 1.hour, race_condition_ttl: 10
cache_sweeper :event_sweeper, only: :index

def index
# Varnish and users browsers 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"

@today = today
@classes = Event.listing_classes.includes(:venue, :class_organiser, :swing_cancellations)
Expand Down
Loading

0 comments on commit 8118183

Please sign in to comment.