Skip to content

Commit

Permalink
Bump rubocop from 1.40.0 to 1.42.0 (Shopify#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored and lawrencewong committed Apr 29, 2023
1 parent 25725bf commit 87e9b68
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if defined?(@rails_gem_requirement) && @rails_gem_requirement
else
gem "rails"
end
gem "rubocop", "1.40.0"
gem "rubocop", "1.42.0"
gem "rubocop-shopify"
gem "selenium-webdriver"
gem "sprockets-rails"
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@ GEM
rake (13.0.6)
regexp_parser (2.6.1)
rexml (3.2.5)
rubocop (1.40.0)
rubocop (1.42.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
rubocop-ast (>= 1.24.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.24.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
rubocop-shopify (2.10.1)
rubocop (~> 1.35)
Expand Down Expand Up @@ -266,7 +266,7 @@ DEPENDENCIES
pry-byebug
puma (< 7.0)
rails
rubocop (= 1.40.0)
rubocop (= 1.42.0)
rubocop-shopify
selenium-webdriver
sprockets-rails
Expand Down
6 changes: 3 additions & 3 deletions app/models/maintenance_tasks/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class Run < ApplicationRecord

enum status: STATUSES.to_h { |status| [status, status.to_s] }

validates :task_name, on: :create, inclusion: { in: ->(_) {
Task.available_tasks.map(&:to_s)
} }
validates :task_name, on: :create, inclusion: {
in: ->(_) { Task.available_tasks.map(&:to_s) },
}
validate :csv_attachment_presence, on: :create
validate :csv_content_type, on: :create
validate :validate_task_arguments, on: :create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

class AddLockVersionToMaintenanceTasksRuns < ActiveRecord::Migration[6.0]
def change
add_column(:maintenance_tasks_runs, :lock_version, :integer,
default: 0, null: false)
add_column(
:maintenance_tasks_runs,
:lock_version,
:integer,
default: 0,
null: false,
)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

class AddIndexOnTaskNameAndStatusToRuns < ActiveRecord::Migration[6.0]
def change
remove_index(:maintenance_tasks_runs,
column: [:task_name, :created_at], order: { created_at: :desc },
name: :index_maintenance_tasks_runs_on_task_name_and_created_at)
remove_index(
:maintenance_tasks_runs,
column: [:task_name, :created_at],
order: { created_at: :desc },
name: :index_maintenance_tasks_runs_on_task_name_and_created_at,
)

add_index(:maintenance_tasks_runs, [:task_name, :status, :created_at],
add_index(
:maintenance_tasks_runs,
[:task_name, :status, :created_at],
name: :index_maintenance_tasks_runs,
order: { created_at: :desc })
order: { created_at: :desc },
)
end
end
8 changes: 6 additions & 2 deletions lib/generators/maintenance_tasks/task_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ class TaskGenerator < Rails::Generators::NamedBase
desc "This generator creates a task file at app/tasks and a corresponding "\
"test."

class_option :csv, type: :boolean, default: false,
class_option :csv,
type: :boolean,
default: false,
desc: "Generate a CSV Task."

class_option :no_collection, type: :boolean, default: false,
class_option :no_collection,
type: :boolean,
default: false,
desc: "Generate a collection-less Task."

check_class_collision suffix: "Task"
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
config.active_support.disallowed_deprecation_warnings = []

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def change

t.index(
[:record_type, :record_id, :name, :blob_id],
name: "index_active_storage_attachments_uniqueness", unique: true,
name: "index_active_storage_attachments_uniqueness",
unique: true,
)
t.foreign_key(:active_storage_blobs, column: :blob_id)
end
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/maintenance_tasks/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module MaintenanceTasks
class ApplicationHelperTest < ActionView::TestCase
test "#time_ago returns a time element with the given datetime worded as relative to now and ISO 8601 UTC time in title attribute" do
travel_to Time.zone.local(2020, 1, 9, 9, 41, 44)
time = Time.zone.local(2020, 01, 01, 01, 00, 00)
time = Time.zone.local(2020, 1, 1, 1, 0, 0)

expected = '<time datetime="2020-01-01T01:00:00Z" '\
'title="2020-01-01T01:00:00Z" class="is-clickable">8 days ago</time>'
Expand Down
6 changes: 4 additions & 2 deletions test/helpers/maintenance_tasks/tasks_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ class TasksHelperTest < ActionView::TestCase

test "#highlight_code does not wrap whitespace" do
assert_equal '<span class="ruby-int">1</span>' + "\n"\
'<span class="ruby-int">2</span>', highlight_code("1\n2")
'<span class="ruby-int">2</span>',
highlight_code("1\n2")
assert_equal '<span class="ruby-int">1</span>' + " "\
'<span class="ruby-int">2</span>', highlight_code("1 2")
'<span class="ruby-int">2</span>',
highlight_code("1 2")
assert_equal "\n", highlight_code("\n")
end

Expand Down
24 changes: 16 additions & 8 deletions test/models/maintenance_tasks/run_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ class RunTest < ActiveSupport::TestCase

test "invalid if content_type is not text/csv" do
run = Run.new(task_name: "Maintenance::ImportPostsTask")
tsv = Rack::Test::UploadedFile.new(file_fixture("sample.tsv"),
"text/tab-separated-values")
tsv = Rack::Test::UploadedFile.new(
file_fixture("sample.tsv"),
"text/tab-separated-values",
)
run.csv_file.attach(tsv)
refute_predicate run, :valid?
end
Expand Down Expand Up @@ -66,8 +68,10 @@ class RunTest < ActiveSupport::TestCase
end

test "#persist_transition calls the interrupt callback" do
run = Run.create!(task_name: "Maintenance::CallbackTestTask",
status: "running")
run = Run.create!(
task_name: "Maintenance::CallbackTestTask",
status: "running",
)
run.status = :interrupted
run.task.expects(:after_interrupt_callback)
run.persist_transition
Expand All @@ -81,8 +85,10 @@ class RunTest < ActiveSupport::TestCase
end

test "#persist_transition calls the cancel callback" do
run = Run.create!(task_name: "Maintenance::CallbackTestTask",
status: "cancelling")
run = Run.create!(
task_name: "Maintenance::CallbackTestTask",
status: "cancelling",
)
run.status = :cancelled
run.task.expects(:after_cancel_callback)
run.persist_transition
Expand Down Expand Up @@ -555,8 +561,10 @@ class RunTest < ActiveSupport::TestCase
end

test "#cancel calls the cancel callback if the job was paused" do
run = Run.create!(task_name: "Maintenance::CallbackTestTask",
status: "paused")
run = Run.create!(
task_name: "Maintenance::CallbackTestTask",
status: "paused",
)
run.task.expects(:after_cancel_callback)
run.cancel
end
Expand Down
13 changes: 10 additions & 3 deletions test/models/maintenance_tasks/task_data_show_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ class TaskDataShowTest < ActiveSupport::TestCase
test "#parameter_names returns list of parameter names for Tasks supporting parameters" do
assert_equal(
[
"post_ids", "content", "integer_attr", "big_integer_attr",
"float_attr", "decimal_attr", "datetime_attr", "date_attr",
"time_attr", "boolean_attr",
"post_ids",
"content",
"integer_attr",
"big_integer_attr",
"float_attr",
"decimal_attr",
"datetime_attr",
"date_attr",
"time_attr",
"boolean_attr",
],
TaskDataShow.new("Maintenance::ParamsTask").parameter_names,
)
Expand Down

0 comments on commit 87e9b68

Please sign in to comment.