Skip to content

Commit

Permalink
Use double quoted strings (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianna-chang-shopify authored Mar 19, 2021
1 parent 9dfd0fc commit afadabb
Show file tree
Hide file tree
Showing 66 changed files with 708 additions and 708 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Style/DocumentationMethod:
- lib/**/*.rb

Style/StringLiterals:
EnforcedStyle: single_quotes
EnforcedStyle: double_quotes

Style/SymbolArray:
EnforcedStyle: brackets
Expand Down
22 changes: 11 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# frozen_string_literal: true

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

gemspec

gem 'capybara'
gem 'mocha'
gem 'pry-byebug'
gem 'puma'
gem 'rails'
gem 'rubocop-shopify'
gem 'selenium-webdriver'
gem 'sqlite3'
gem 'webdrivers', require: false
gem 'yard'
gem "capybara"
gem "mocha"
gem "pry-byebug"
gem "puma"
gem "rails"
gem "rubocop-shopify"
gem "selenium-webdriver"
gem "sqlite3"
gem "webdrivers", require: false
gem "yard"
32 changes: 16 additions & 16 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# frozen_string_literal: true
begin
require 'bundler/setup'
require "bundler/setup"
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end

require 'rdoc/task'
require "rdoc/task"
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'MaintenanceTasks'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
rdoc.rdoc_dir = "rdoc"
rdoc.title = "MaintenanceTasks"
rdoc.options << "--line-numbers"
rdoc.rdoc_files.include("README.md")
rdoc.rdoc_files.include("lib/**/*.rb")
end

APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
load('rails/tasks/engine.rake')
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
load("rails/tasks/engine.rake")

load('rails/tasks/statistics.rake')
load("rails/tasks/statistics.rake")

require 'bundler/gem_tasks'
require "bundler/gem_tasks"

require 'rubocop/rake_task'
require "rubocop/rake_task"
RuboCop::RakeTask.new

task(test: 'app:test')
task('test:system' => 'app:test:system')
task(default: ['db:test:prepare', 'test', 'test:system', 'rubocop'])
task(test: "app:test")
task("test:system" => "app:test:system")
task(default: ["db:test:prepare", "test", "test:system", "rubocop"])
4 changes: 2 additions & 2 deletions app/controllers/maintenance_tasks/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module MaintenanceTasks
#
# Can be extended to add different authentication and authorization code.
class ApplicationController < ActionController::Base
BULMA_CDN = 'https://cdn.jsdelivr.net'
BULMA_CDN = "https://cdn.jsdelivr.net"

content_security_policy do |policy|
policy.style_src(BULMA_CDN)
Expand All @@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base
before_action do
request.content_security_policy_nonce_generator ||=
->(_request) { SecureRandom.base64(16) }
request.content_security_policy_nonce_directives = ['style-src']
request.content_security_policy_nonce_directives = ["style-src"]
end

protect_from_forgery with: :exception
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/maintenance_tasks/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module ApplicationHelper
# @param datetime [ActiveSupport::TimeWithZone] the time to be presented.
# @return [String] the HTML to render with the relative datetime in words.
def time_ago(datetime)
time_tag(datetime, title: datetime.utc.iso8601, class: 'is-clickable') do
time_ago_in_words(datetime) + ' ago'
time_tag(datetime, title: datetime.utc.iso8601, class: "is-clickable") do
time_ago_in_words(datetime) + " ago"
end
end
end
Expand Down
28 changes: 14 additions & 14 deletions app/helpers/maintenance_tasks/tasks_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true

require 'ripper'
require "ripper"

module MaintenanceTasks
# Helpers for formatting data in the maintenance_tasks views.
#
# @api private
module TasksHelper
STATUS_COLOURS = {
'new' => ['is-primary'],
'enqueued' => ['is-primary is-light'],
'running' => ['is-info'],
'interrupted' => ['is-info', 'is-light'],
'pausing' => ['is-warning', 'is-light'],
'paused' => ['is-warning'],
'succeeded' => ['is-success'],
'cancelling' => ['is-light'],
'cancelled' => ['is-dark'],
'errored' => ['is-danger'],
"new" => ["is-primary"],
"enqueued" => ["is-primary is-light"],
"running" => ["is-info"],
"interrupted" => ["is-info", "is-light"],
"pausing" => ["is-warning", "is-light"],
"paused" => ["is-warning"],
"succeeded" => ["is-success"],
"cancelling" => ["is-light"],
"cancelled" => ["is-dark"],
"errored" => ["is-danger"],
}

# Formats a run backtrace.
Expand Down Expand Up @@ -48,7 +48,7 @@ def progress(run)
value: progress.value,
max: progress.max,
title: progress.title,
class: ['progress'] + STATUS_COLOURS.fetch(run.status)
class: ["progress"] + STATUS_COLOURS.fetch(run.status)
)
end

Expand All @@ -59,7 +59,7 @@ def progress(run)
# @return [String] the span element containing the status, with the
# appropriate tag class attached.
def status_tag(status)
tag.span(status.capitalize, class: ['tag'] + STATUS_COLOURS.fetch(status))
tag.span(status.capitalize, class: ["tag"] + STATUS_COLOURS.fetch(status))
end

# Returns the distance between now and the Run's expected completion time,
Expand Down Expand Up @@ -100,7 +100,7 @@ def highlight_code(code)
when :on_nl, :on_sp, :on_ignored_nl
content
else
tag.span(content, class: type.to_s.sub('on_', 'ruby-').dasherize)
tag.span(content, class: type.to_s.sub("on_", "ruby-").dasherize)
end
end
safe_join(tokens)
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/maintenance_tasks/task_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class << self
# Overrides ActiveJob::Exceptions.retry_on to declare it unsupported.
# The use of rescue_from prevents retry_on from being usable.
def retry_on(*, **)
raise NotImplementedError, 'retry_on is not supported'
raise NotImplementedError, "retry_on is not supported"
end
end

Expand All @@ -38,7 +38,7 @@ def build_enumerator(_run, cursor:)
JobIteration::CsvEnumerator.new(collection).rows(cursor: cursor)
else
raise ArgumentError, "#{@task.class.name}#collection must be either "\
'an Active Record Relation, Array, or CSV.'
"an Active Record Relation, Array, or CSV."
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/maintenance_tasks/csv_collection.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'csv'
require "csv"

module MaintenanceTasks
# Module that is included into Task classes by Task.csv_collection for
Expand Down
4 changes: 2 additions & 2 deletions app/models/maintenance_tasks/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ def stuck?
# if the Run does not meet the above criteria.
def csv_attachment_presence
if Task.named(task_name) < CsvCollection && !csv_file.attached?
errors.add(:csv_file, 'must be attached to CSV Task.')
errors.add(:csv_file, "must be attached to CSV Task.")
elsif !(Task.named(task_name) < CsvCollection) && csv_file.present?
errors.add(:csv_file, 'should not be attached to non-CSV Task.')
errors.add(:csv_file, "should not be attached to non-CSV Task.")
end
rescue Task::NotFoundError
nil
Expand Down
4 changes: 2 additions & 2 deletions app/models/maintenance_tasks/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Runner
# @deprecated Use {Runner} directly instead.
def new
ActiveSupport::Deprecation.warn(
'Use Runner.run instead of Runner.new.run'
"Use Runner.run instead of Runner.new.run"
)
self
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def run(name:, csv_file: nil)
def enqueue(run)
unless MaintenanceTasks.job.constantize.perform_later(run)
raise "The job to perform #{run.task_name} could not be enqueued. "\
'Enqueuing has been prevented by a callback.'
"Enqueuing has been prevented by a callback."
end
rescue => error
run.persist_error(error)
Expand Down
2 changes: 1 addition & 1 deletion app/models/maintenance_tasks/runs_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize(runs, cursor)
def records
@records ||= begin
runs_after_cursor = if @cursor.present?
@runs.where('id < ?', @cursor)
@runs.where("id < ?", @cursor)
else
@runs
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/maintenance_tasks/task_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def available_tasks
task_names = Task.available_tasks.map(&:name)
available_task_runs = Run.where(task_name: task_names)
last_runs = Run.where(
id: available_task_runs.select('MAX(id) as id').group(:task_name)
id: available_task_runs.select("MAX(id) as id").group(:task_name)
)

task_names.map do |task_name|
Expand Down Expand Up @@ -111,7 +111,7 @@ def deleted?
#
# @return [String] the Task status.
def status
last_run&.status || 'new'
last_run&.status || "new"
end

# Retrieves the Task's category, which is one of active, new, or completed.
Expand Down
22 changes: 11 additions & 11 deletions app/validators/maintenance_tasks/run_status_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RunStatusValidator < ActiveModel::Validator
# before starting.
# enqueued -> errored occurs when the task job fails to be enqueued, or
# if the Task is deleted before is starts running.
'enqueued' => ['running', 'pausing', 'cancelling', 'errored'],
"enqueued" => ["running", "pausing", "cancelling", "errored"],
# pausing -> paused occurs when the task actually halts performing and
# occupies a status of paused.
# pausing -> cancelling occurs when the user cancels a task immediately
Expand All @@ -24,14 +24,14 @@ class RunStatusValidator < ActiveModel::Validator
# nothing in its collection to process.
# pausing -> errored occurs when the job raises an exception after the
# user has paused it.
'pausing' => ['paused', 'cancelling', 'succeeded', 'errored'],
"pausing" => ["paused", "cancelling", "succeeded", "errored"],
# cancelling -> cancelled occurs when the task actually halts performing
# and occupies a status of cancelled.
# cancelling -> succeeded occurs when the task completes immediately after
# being cancelled. See description for pausing -> succeeded.
# cancelling -> errored occurs when the job raises an exception after the
# user has cancelled it.
'cancelling' => ['cancelled', 'succeeded', 'errored'],
"cancelling" => ["cancelled", "succeeded", "errored"],
# running -> succeeded occurs when the task completes successfully.
# running -> pausing occurs when a user pauses the task as
# it's performing.
Expand All @@ -40,17 +40,17 @@ class RunStatusValidator < ActiveModel::Validator
# running -> interrupted occurs when the job infra shuts down the task as
# it's performing.
# running -> errored occurs when the job raises an exception when running.
'running' => [
'succeeded',
'pausing',
'cancelling',
'interrupted',
'errored',
"running" => [
"succeeded",
"pausing",
"cancelling",
"interrupted",
"errored",
],
# paused -> enqueued occurs when the task is resumed after being paused.
# paused -> cancelling when the user cancels the task after it is paused.
# paused -> cancelled when the user cancels the task after it is paused.
'paused' => ['enqueued', 'cancelling', 'cancelled'],
"paused" => ["enqueued", "cancelling", "cancelled"],
# interrupted -> running occurs when the task is resumed after being
# interrupted by the job infrastructure.
# interrupted -> pausing occurs when the task is paused by the user while
Expand All @@ -59,7 +59,7 @@ class RunStatusValidator < ActiveModel::Validator
# while it is interrupted.
# interrupted -> errored occurs when the task is deleted while it is
# interrupted.
'interrupted' => ['running', 'pausing', 'cancelling', 'errored'],
"interrupted" => ["running", "pausing", "cancelling", "errored"],
}

# Validate whether a transition from one Run status
Expand Down
12 changes: 6 additions & 6 deletions bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/maintenance_tasks/engine', __dir__)
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
ENGINE_ROOT = File.expand_path("..", __dir__)
ENGINE_PATH = File.expand_path("../lib/maintenance_tasks/engine", __dir__)
APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require 'rails/engine/commands'
require "rails/engine/commands"
8 changes: 4 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
MaintenanceTasks::Engine.routes.draw do
resources :tasks, only: [:index, :show], format: false do
member do
put 'run'
put "run"
end

resources :runs, only: [], format: false do
member do
put 'pause'
put 'cancel'
put "pause"
put "cancel"
end
end
end

root to: 'tasks#index'
root to: "tasks#index"
end
4 changes: 2 additions & 2 deletions exe/maintenance_tasks
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# frozen_string_literal: true

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

Rails.application.require_environment!

require 'maintenance_tasks/cli'
require "maintenance_tasks/cli"

module MaintenanceTasks
CLI.start(ARGV)
Expand Down
8 changes: 4 additions & 4 deletions lib/generators/maintenance_tasks/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ module MaintenanceTasks
#
# @api private
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
source_root File.expand_path("templates", __dir__)

# Mounts the engine in the host application's config/routes.rb
def mount_engine
route("mount MaintenanceTasks::Engine => '/maintenance_tasks'")
route("mount MaintenanceTasks::Engine => \"/maintenance_tasks\"")
end

# Copies engine migrations to host application and migrates the database
def install_migrations
rake('maintenance_tasks:install:migrations')
rake('db:migrate')
rake("maintenance_tasks:install:migrations")
rake("db:migrate")
end
end
end
Loading

0 comments on commit afadabb

Please sign in to comment.