Skip to content
Snippets Groups Projects
Commit f474f16f authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch '50414-rubocop-rule-to-enforce-class-methods-over-module' into 'master'

Resolve "Make a Rubocop cop to prefer class_methods over ClassMethods for ActiveSupport::Concern"

Closes #50414

See merge request gitlab-org/gitlab-ce!21379
parents f4d04ee9 4a37cd0d
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 20 deletions
Loading
Loading
@@ -26,7 +26,7 @@
module AtomicInternalId
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def has_internal_id(column, scope:, init:, presence: true) # rubocop:disable Naming/PredicateName
# We require init here to retain the ability to recalculate in the absence of a
# InternaLId record (we may delete records in `internal_ids` for example).
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module Awardable
end
end
 
module ClassMethods
class_methods do
def awarded(user, name)
sql = <<~EOL
EXISTS (
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@
module CaseSensitivity
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
# Queries the given columns regardless of the casing used.
#
# Unlike other ActiveRecord methods this method only operates on a Hash.
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module EachBatch
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
# Iterates over the rows in a relation in batches, similar to Rails'
# `in_batches` but in a more efficient way.
#
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
module IgnorableColumn
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def columns
super.reject { |column| ignored_columns.include?(column.name) }
end
Loading
Loading
Loading
Loading
@@ -118,7 +118,7 @@ module Issuable
end
end
 
module ClassMethods
class_methods do
# Searches for records with a matching title.
#
# This method uses ILIKE on PostgreSQL and LIKE on MySQL.
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module LoadedInGroupList
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def with_counts(archived:)
selects_including_counts = [
'namespaces.*',
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module ManualInverseAssociation
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def manual_inverse_association(association, inverse)
define_method(association) do |*args|
super(*args).tap do |value|
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@
module Mentionable
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
# Indicate which attributes of the Mentionable to search for GFM references.
def attr_mentionable(attr, options = {})
attr = attr.to_s
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module OptionallySearch
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def search(*)
raise(
NotImplementedError,
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@
module Participable
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
# Adds a list of participant attributes. Attributes can either be symbols or
# Procs.
#
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ module Referable
end
end
 
module ClassMethods
class_methods do
# The character that prefixes the actual reference identifier
#
# This should be overridden by the including class.
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ module ResolvableNote
scope :unresolved, -> { resolvable.where(resolved_at: nil) }
end
 
module ClassMethods
class_methods do
# This method must be kept in sync with `#resolve!`
def resolve!(current_user)
unresolved.update_all(resolved_at: Time.now, resolved_by_id: current_user.id)
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module SelectForProjectAuthorization
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def select_for_project_authorization
select("projects.id AS project_id, members.access_level")
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module ShaAttribute
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def sha_attribute(name)
return if ENV['STATIC_VERIFICATION']
 
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module Sortable
scope :order_name_desc, -> { reorder(Arel::Nodes::Descending.new(arel_table[:name].lower)) }
end
 
module ClassMethods
class_methods do
def order_by(method)
case method.to_s
when 'created_asc' then order_created_asc
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module Spammable
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def attr_spammable(attr, options = {})
spammable_attrs << [attr.to_s, options]
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
module StripAttribute
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
def strip_attributes(*attrs)
strip_attrs.concat(attrs)
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ module ApplicationWorker
set_queue
end
 
module ClassMethods
class_methods do
def inherited(subclass)
subclass.set_queue
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module WaitableWorker
extend ActiveSupport::Concern
 
module ClassMethods
class_methods do
# Schedules multiple jobs and waits for them to be completed.
def bulk_perform_and_wait(args_list, timeout: 10)
# Short-circuit: it's more efficient to do small numbers of jobs inline
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment