8000 Enable `Style/ParallelAssignment` cop by deivid-rodriguez · Pull Request #5803 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Enable Style/ParallelAssignment cop #5803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Style/FrozenStringLiteralComment:
Style/HashSyntax:
Enabled: true

Style/ParallelAssignment:
Enabled: true

Layout/IndentationConsistency:
Enabled: true

Expand Down
3 changes: 2 additions & 1 deletion features/step_definitions/batch_action_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
page.find("#batch_action", visible: false).set action
form = page.find "#collection_selection"
params = page.all("#main_content input", visible: false).each_with_object({}) do |input, obj|
key, value = input['name'], input['value']
key = input['name']
value = input['value']
if key == 'collection_selection[]'
(obj[key] ||= []).push value if input.checked?
else
Expand Down
6 changes: 5 additions & 1 deletion lib/active_admin/batch_actions/resource_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ class BatchAction
# => You can pass a hash of options to `:form` that will be rendered as form input fields for the user to fill out.
#
def initialize(sym, title, options = {}, &block)
@sym, @title, @options, @block, @confirm = sym, title, options, block, options[:confirm]
@sym = sym
@title = title
@options = options
@block = block
@confirm = options[:confirm]
@block ||= proc {}
end

Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/controller_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module ActiveAdmin
class ControllerAction
attr_reader :name
def initialize(name, options = {})
@name, @options = name, options
@name = name
@options = options
end

def http_verb
Expand Down
4 changes: 3 additions & 1 deletion lib/active_admin/csv_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def self.default_for_resource(resource)

def initialize(options = {}, &block)
@resource = options.delete(:resource)
@columns, @options, @block = [], options, block
@columns = []
@options = options
@block = block
end

def column(name, options = {}, &block)
Expand Down
4 changes: 3 additions & 1 deletion lib/active_admin/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class AccessDenied < StandardError
attr_reader :user, :action, :subject

def initialize(user, action, subject = nil)
@user, @action, @subject = user, action, subject
@user = user
@action = action
@subject = subject

super()
end
Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/page_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class PagePresenter
delegate :has_key?, :fetch, to: :options

def initialize(options = {}, &block)
@options, @block = options, block
@options = options
@block = block
end

def [](key)
Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def initialize(namespace, resource_class, options = {})
@resource_class_name = "::#{resource_class.name}"
@options = options
@sort_order = options[:sort_order]
@member_actions, @collection_actions = [], []
@member_actions = []
@collection_actions = []
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/active_admin/resource/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def initialize(key, namespace)
attr_reader :owner

def initialize(owner, target_name, options = {})
@owner, @target_name, @options = owner, target_name, options
@owner = owner
@target_name = target_name
@options = options
end

# Returns the target resource class or raises an exception if it doesn't exist
Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class Router
attr_reader :namespaces, :router

def initialize(router:, namespaces:)
@router, @namespaces = router, namespaces
@router = router
@namespaces = namespaces
end

def apply
Expand Down
10 changes: 7 additions & 3 deletions lib/active_admin/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Scope
# # => Scope with the group :status
#
def initialize(name, method = nil, options = {}, &block)
@name, @scope_method = name, method.try(:to_sym)
@name = name
@scope_method = method.try(:to_sym)

if name.is_a? Proc
raise "A string/symbol is required as the second argument if your label is a proc." unless method
Expand All @@ -38,8 +39,11 @@ def initialize(name, method = nil, options = {}, &block)
@id = name.to_s.parameterize(separator: "_")
end

@scope_method = nil if @scope_method == :all
@scope_method, @scope_block = nil, block if block_given?
@scope_method = nil if @scope_method == :all
if block_given?
@scope_method = nil
@scope_block = block
end

@localizer = options[:localizer]
@show_count = options.fetch(:show_count, true)
Expand Down
4 changes: 3 additions & 1 deletion lib/active_admin/sidebar_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class SidebarSection
attr_accessor :name, :options, :block

def initialize(name, options = {}, &block)
@name, @options, @block = name.to_s, options, block
@name = name.to_s
@options = options
@block = block
normalize_display_options!
end

Expand Down
3 changes: 2 additions & 1 deletion lib/active_admin/view_helpers/display_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module ViewHelpers
module DisplayHelper

DISPLAY_NAME_FALLBACK = -> {
name, klass = "", self.class
name = ""
klass = self.class
name << klass.model_name.human if klass.respond_to? :model_name
name << " ##{send(klass.primary_key)}" if klass.respond_to? :primary_key
name.present? ? name : to_s
Expand Down
0