Fix Style/CombinableLoops
cop (#27429)
This commit is contained in:
parent
eb5ebdbd1b
commit
a730517f90
3 changed files with 16 additions and 14 deletions
|
@ -523,12 +523,6 @@ Style/ClassVars:
|
|||
Exclude:
|
||||
- 'config/initializers/devise.rb'
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/CombinableLoops:
|
||||
Exclude:
|
||||
- 'app/models/form/custom_emoji_batch.rb'
|
||||
- 'app/models/form/ip_block_batch.rb'
|
||||
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: AllowedVars.
|
||||
Style/FetchEnvVar:
|
||||
|
|
|
@ -34,7 +34,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def update!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :update?) }
|
||||
verify_authorization(:update?)
|
||||
|
||||
category = if category_id.present?
|
||||
CustomEmojiCategory.find(category_id)
|
||||
|
@ -50,7 +50,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def list!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :update?) }
|
||||
verify_authorization(:update?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
custom_emoji.update(visible_in_picker: true)
|
||||
|
@ -59,7 +59,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def unlist!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :update?) }
|
||||
verify_authorization(:update?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
custom_emoji.update(visible_in_picker: false)
|
||||
|
@ -68,7 +68,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def enable!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :enable?) }
|
||||
verify_authorization(:enable?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
custom_emoji.update(disabled: false)
|
||||
|
@ -77,7 +77,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def disable!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :disable?) }
|
||||
verify_authorization(:disable?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
custom_emoji.update(disabled: true)
|
||||
|
@ -86,7 +86,7 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def copy!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :copy?) }
|
||||
verify_authorization(:copy?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
copied_custom_emoji = custom_emoji.copy!
|
||||
|
@ -95,11 +95,15 @@ class Form::CustomEmojiBatch
|
|||
end
|
||||
|
||||
def delete!
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, :destroy?) }
|
||||
verify_authorization(:destroy?)
|
||||
|
||||
custom_emojis.each do |custom_emoji|
|
||||
custom_emoji.destroy
|
||||
log_action :destroy, custom_emoji
|
||||
end
|
||||
end
|
||||
|
||||
def verify_authorization(permission)
|
||||
custom_emojis.each { |custom_emoji| authorize(custom_emoji, permission) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,11 +21,15 @@ class Form::IpBlockBatch
|
|||
end
|
||||
|
||||
def delete!
|
||||
ip_blocks.each { |ip_block| authorize(ip_block, :destroy?) }
|
||||
verify_authorization(:destroy?)
|
||||
|
||||
ip_blocks.each do |ip_block|
|
||||
ip_block.destroy
|
||||
log_action :destroy, ip_block
|
||||
end
|
||||
end
|
||||
|
||||
def verify_authorization(permission)
|
||||
ip_blocks.each { |ip_block| authorize(ip_block, permission) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue