Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebarrie committed Oct 12, 2021
1 parent 780de7c commit b3a495d
Show file tree
Hide file tree
Showing 72 changed files with 83 additions and 13 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

begin
require "bundler/setup"
rescue LoadError
Expand Down
1 change: 1 addition & 0 deletions app/helpers/maintenance_tasks/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Module for common view helpers.
#
Expand Down
1 change: 1 addition & 0 deletions app/jobs/concerns/maintenance_tasks/task_job_concern.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Concern that holds the behaviour of the job that runs the tasks. It is
# included in {TaskJob} and if MaintenanceTasks.job is overridden, it must be
Expand Down
1 change: 1 addition & 0 deletions app/models/maintenance_tasks/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Base class for all records used by this engine.
#
Expand Down
1 change: 1 addition & 0 deletions app/models/maintenance_tasks/run.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Model that persists information related to a task being run from the UI.
#
Expand Down
1 change: 1 addition & 0 deletions app/models/maintenance_tasks/runs_page.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# This class is responsible for handling cursor-based pagination for Run
# records.
Expand Down
1 change: 1 addition & 0 deletions app/models/maintenance_tasks/task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Base class that is inherited by the host application's task classes.
class Task
Expand Down
1 change: 1 addition & 0 deletions app/models/maintenance_tasks/task_data.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Class that represents the data related to a Task. Such information can be
# sourced from a Task or from existing Run records for a Task that was since
Expand Down
1 change: 1 addition & 0 deletions app/validators/maintenance_tasks/run_status_validator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Custom validator class responsible for ensuring that transitions between
# Run statuses are valid.
Expand Down
1 change: 1 addition & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

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

MaintenanceTasks::Engine.routes.draw do
resources :tasks, only: [:index, :show], format: false do
member do
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20201211151756_create_maintenance_tasks_runs.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreateMaintenanceTasksRuns < ActiveRecord::Migration[6.0]
def change
create_table(:maintenance_tasks_runs) do |t|
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20210225152418_remove_index_on_task_name.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class RemoveIndexOnTaskName < ActiveRecord::Migration[6.0]
def up
change_table(:maintenance_tasks_runs) do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class AddArgumentsToMaintenanceTasksRuns < ActiveRecord::Migration[6.0]
def change
add_column(:maintenance_tasks_runs, :arguments, :text)
Expand Down
1 change: 1 addition & 0 deletions lib/generators/maintenance_tasks/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module MaintenanceTasks
# Generator used to set up the engine in the host application. It handles
# mounting the engine and installing migrations.
Expand Down
3 changes: 2 additions & 1 deletion lib/maintenance_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "action_controller"
require "action_view"
require "active_job"
Expand Down Expand Up @@ -73,7 +74,7 @@ def self.error_handler=(error_handler)
unless error_handler.arity == 3
ActiveSupport::Deprecation.warn(
"MaintenanceTasks.error_handler should be a lambda that takes three "\
"arguments: error, task_context, and errored_element."
"arguments: error, task_context, and errored_element."
)
@error_handler = ->(error, _task_context, _errored_element) do
error_handler.call(error)
Expand Down
11 changes: 6 additions & 5 deletions lib/maintenance_tasks/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ def exit_on_failure?
LONGDESC

# Specify the CSV file to process for CSV Tasks
option :csv, desc: "Supply a CSV file to be processed by a CSV Task, "\
'--csv "path/to/csv/file.csv"'

desc = "Supply a CSV file to be processed by a CSV Task, "\
"--csv path/to/csv/file.csv"
option :csv, desc: desc
# Specify arguments to supply to a Task supporting parameters
option :arguments, type: :hash, desc: "Supply arguments for a Task that "\
"accepts parameters as a set of <key>:<value> pairs."
desc = "Supply arguments for a Task that accepts parameters as a set of "\
"<key>:<value> pairs."
option :arguments, type: :hash, desc: desc

# Command to run a Task.
#
Expand Down
1 change: 1 addition & 0 deletions lib/maintenance_tasks/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "active_record/railtie"

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

require "active_support"
require "active_support/test_case"
require "yard"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
1 change: 1 addition & 0 deletions test/dummy/app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]

Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
1 change: 1 addition & 0 deletions test/dummy/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: "[email protected]"
layout "mailer"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
1 change: 1 addition & 0 deletions test/dummy/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class Post < ApplicationRecord
validates :title, presence: true
validates :content, presence: true
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/callback_test_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class CallbackTestTask < MaintenanceTasks::Task
after_start :after_start_callback
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/cancelled_enqueue_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
# Any job enqueued for this task gets cancelled, see CustomTaskJob.
class CancelledEnqueueTask < MaintenanceTasks::Task
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/enqueue_error_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
# Any job enqueued for this task errors, see CustomTaskJob.
class EnqueueErrorTask < MaintenanceTasks::Task
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/error_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class ErrorTask < MaintenanceTasks::Task
def collection
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/import_posts_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class ImportPostsTask < MaintenanceTasks::Task
csv_collection
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/params_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class ParamsTask < MaintenanceTasks::Task
attribute :post_ids, :string
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/test_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class TestTask < MaintenanceTasks::Task
def collection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class UpdatePostsInBatchesTask < MaintenanceTasks::Task
def collection
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/tasks/maintenance/update_posts_task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class UpdatePostsTask < MaintenanceTasks::Task
class << self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Maintenance
class UpdatePostsThrottledTask < MaintenanceTasks::Task
class << self
Expand Down
1 change: 1 addition & 0 deletions test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
1 change: 1 addition & 0 deletions test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../config/boot"
require "rake"
Rake.application.run
1 change: 1 addition & 0 deletions test/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"

# path to your application root.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require_relative "config/environment"
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require_relative "boot"

verbose = $VERBOSE
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)

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

# Load the Rails application.
require_relative "application"

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

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/assets.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.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/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
Expand Down
1 change: 1 addition & 0 deletions test/dummy/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 test/dummy/config/initializers/cookies_serializer.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.

# Specify a serializer for the signed and encrypted cookie jars.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/filter_parameter_logging.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.

# Configure sensitive parameters which will be filtered from the log file.
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/wrap_parameters.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 settings for ActionController::ParamsWrapper which
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

Rails.application.routes.draw do
mount MaintenanceTasks::Engine => "/maintenance_tasks"
resources :posts
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/spring.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

Spring.watch(
".ruby-version",
".rbenv-vars",
Expand Down
1 change: 1 addition & 0 deletions test/dummy/db/migrate/20200923173403_create_posts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class CreatePosts < ActiveRecord::Migration[6.0]
def change
create_table(:posts) do |t|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
Expand Down
1 change: 1 addition & 0 deletions test/dummy/db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

10.times do |i|
Post.create!(title: "Post ##{i}", content: "Content ##{i}")
end
Expand Down
1 change: 1 addition & 0 deletions test/helpers/maintenance_tasks/application_helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"

module MaintenanceTasks
Expand Down
3 changes: 2 additions & 1 deletion test/jobs/maintenance_tasks/task_job_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "test_helper"
require "job-iteration"

Expand Down Expand Up @@ -132,7 +133,7 @@ class TaskJobTest < ActiveJob::TestCase
run.expects(:persist_error).with do |exception|
assert_kind_of ArgumentError, exception
assert_equal "Something went wrong", exception.message
expected = "app/tasks/maintenance/error_task.rb:9:in `process'"
expected = "app/tasks/maintenance/error_task.rb:10:in `process'"
assert_match expected, exception.backtrace.first
end

Expand Down
Loading

0 comments on commit b3a495d

Please sign in to comment.