Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3b261c3e
Commit
3b261c3e
authored
Jan 10, 2022
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
329ce025
96110427
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
53 deletions
+17
-53
lib/gitlab/error_tracking/processor/sidekiq_processor.rb
lib/gitlab/error_tracking/processor/sidekiq_processor.rb
+2
-0
rubocop/cop/migration/schedule_async.rb
rubocop/cop/migration/schedule_async.rb
+2
-25
spec/lib/gitlab/error_tracking/processor/sidekiq_processor_spec.rb
...gitlab/error_tracking/processor/sidekiq_processor_spec.rb
+9
-0
spec/rubocop/cop/migration/schedule_async_spec.rb
spec/rubocop/cop/migration/schedule_async_spec.rb
+4
-28
No files found.
lib/gitlab/error_tracking/processor/sidekiq_processor.rb
View file @
3b261c3e
...
...
@@ -53,6 +53,8 @@ module Gitlab
# 'args' in :job => from default error handler
job_holder
=
sidekiq
.
key?
(
'args'
)
?
sidekiq
:
sidekiq
[
:job
]
return
event
unless
job_holder
if
job_holder
[
'args'
]
job_holder
[
'args'
]
=
filter_arguments
(
job_holder
[
'args'
],
job_holder
[
'class'
]).
to_a
end
...
...
rubocop/cop/migration/schedule_async.rb
View file @
3b261c3e
...
...
@@ -11,9 +11,8 @@ module RuboCop
ENFORCED_SINCE
=
2020_02_12_00_00_00
MSG
=
<<~
MSG
Don't call the background migration worker directly, use the `#migrate_async`,
`#migrate_in`, `#bulk_migrate_async` or `#bulk_migrate_in` migration helpers
instead.
Don't call the background migration worker directly, use the `#migrate_in` or
`#queue_background_migration_jobs_by_range_at_intervals` migration helpers instead.
MSG
def_node_matcher
:calls_background_migration_worker?
,
<<~
PATTERN
...
...
@@ -26,28 +25,6 @@ module RuboCop
add_offense
(
node
,
location: :expression
)
if
calls_background_migration_worker?
(
node
)
end
def
autocorrect
(
node
)
# This gets rid of the receiver `BackgroundMigrationWorker` and
# replaces `perform` with `schedule`
schedule_method
=
method_name
(
node
).
to_s
.
sub
(
'perform'
,
'migrate'
)
arguments
=
arguments
(
node
).
map
(
&
:source
).
join
(
', '
)
replacement
=
"
#{
schedule_method
}
(
#{
arguments
}
)"
lambda
do
|
corrector
|
corrector
.
replace
(
node
.
source_range
,
replacement
)
end
end
private
def
method_name
(
node
)
node
.
children
.
second
end
def
arguments
(
node
)
node
.
children
[
2
..
]
end
end
end
end
...
...
spec/lib/gitlab/error_tracking/processor/sidekiq_processor_spec.rb
View file @
3b261c3e
...
...
@@ -178,5 +178,14 @@ RSpec.describe Gitlab::ErrorTracking::Processor::SidekiqProcessor do
expect
(
result_hash
.
dig
(
:extra
,
:sidekiq
)).
to
be_nil
end
end
context
'when there is Sidekiq data but no job'
do
let
(
:value
)
{
{
other:
'foo'
}
}
let
(
:wrapped_value
)
{
{
extra:
{
sidekiq:
value
}
}
}
it
'does nothing'
do
expect
(
result_hash
.
dig
(
:extra
,
:sidekiq
)).
to
eq
(
value
)
end
end
end
end
spec/rubocop/cop/migration/schedule_async_spec.rb
View file @
3b261c3e
...
...
@@ -43,24 +43,18 @@ RSpec.describe RuboCop::Cop::Migration::ScheduleAsync do
end
context
'BackgroundMigrationWorker.perform_async'
do
it
'adds an offense when calling `BackgroundMigrationWorker.peform_async`
and corrects'
,
:aggregate_failures
do
it
'adds an offense when calling `BackgroundMigrationWorker.peform_async`
'
do
expect_offense
(
<<~
RUBY
)
def up
BackgroundMigrationWorker.perform_async(ClazzName, "Bar", "Baz")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Don't call [...]
end
RUBY
expect_correction
(
<<~
RUBY
)
def up
migrate_async(ClazzName, "Bar", "Baz")
end
RUBY
end
end
context
'BackgroundMigrationWorker.perform_in'
do
it
'adds an offense
and corrects'
,
:aggregate_failures
do
it
'adds an offense
'
do
expect_offense
(
<<~
RUBY
)
def up
BackgroundMigrationWorker
...
...
@@ -68,17 +62,11 @@ RSpec.describe RuboCop::Cop::Migration::ScheduleAsync do
.perform_in(delay, ClazzName, "Bar", "Baz")
end
RUBY
expect_correction
(
<<~
RUBY
)
def up
migrate_in(delay, ClazzName, "Bar", "Baz")
end
RUBY
end
end
context
'BackgroundMigrationWorker.bulk_perform_async'
do
it
'adds an offense
and corrects'
,
:aggregate_failures
do
it
'adds an offense
'
do
expect_offense
(
<<~
RUBY
)
def up
BackgroundMigrationWorker
...
...
@@ -86,17 +74,11 @@ RSpec.describe RuboCop::Cop::Migration::ScheduleAsync do
.bulk_perform_async(jobs)
end
RUBY
expect_correction
(
<<~
RUBY
)
def up
bulk_migrate_async(jobs)
end
RUBY
end
end
context
'BackgroundMigrationWorker.bulk_perform_in'
do
it
'adds an offense
and corrects'
,
:aggregate_failures
do
it
'adds an offense
'
do
expect_offense
(
<<~
RUBY
)
def up
BackgroundMigrationWorker
...
...
@@ -104,12 +86,6 @@ RSpec.describe RuboCop::Cop::Migration::ScheduleAsync do
.bulk_perform_in(5.minutes, jobs)
end
RUBY
expect_correction
(
<<~
RUBY
)
def up
bulk_migrate_in(5.minutes, jobs)
end
RUBY
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment