Skip to content

Commit e29be31

Browse files
committed
style(): run rubocop -a
1 parent fd2e856 commit e29be31

34 files changed

+77
-68
lines changed

app/inputs/active_admin/inputs/select_input.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def input_html_options
99

1010
def raw_collection
1111
field_value = begin
12-
object.send(method)
13-
rescue NoMethodError
14-
nil
15-
end
12+
object.send(method)
13+
rescue NoMethodError
14+
nil
15+
end
1616

1717
@options[:tags].present? && field_value.present? ? (super.to_a << field_value).uniq : super
1818
end

app/inputs/nested_level_input.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def render_custom_input
1313

1414
private
1515

16+
# rubocop:disable Metrics/MethodLength
1617
def load_control_attributes
1718
load_class(@options[:class])
1819
load_data_attr(:association, value: association_name)
@@ -26,14 +27,16 @@ def load_control_attributes
2627
load_data_attr(:response_root, default: tableize_method)
2728
load_data_attr(:width)
2829
load_data_attr(:order,
29-
value: @options[:order_by],
30-
default: get_data_attr_value(:fields).first.to_s + "_desc")
30+
value: @options[:order_by],
31+
default: "#{get_data_attr_value(:fields).first}_desc")
3132
load_parent_data_options
3233
load_collection_data
3334
end
35+
# rubocop:enable Metrics/MethodLength
3436

3537
def load_parent_data_options
3638
return unless @options[:parent_attribute]
39+
3740
load_data_attr(:parent, value: @options[:parent_attribute])
3841
load_data_attr(:parent_id, value: @object.send(@options[:parent_attribute]), default: -1)
3942
end

app/inputs/search_select_input.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ class SearchSelectInput < ActiveAdminAddons::InputBase
33

44
def render_custom_input
55
concat(label_html)
6-
concat(builder.select(input_method,
7-
initial_collection_to_select_options, {}, input_html_options))
6+
concat(
7+
builder.select(input_method, initial_collection_to_select_options, {}, input_html_options)
8+
)
89
end
910

1011
def input_method
@@ -23,7 +24,7 @@ def load_control_attributes
2324
load_data_attr(
2425
:order,
2526
value: @options[:order_by],
26-
default: get_data_attr_value(:fields).first.to_s + "_desc"
27+
default: "#{get_data_attr_value(:fields).first}_desc"
2728
)
2829
end
2930
end

lib/activeadmin_addons.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ module ActiveadminAddons
55

66
def default_select
77
return "slim-select" unless @default_select
8+
89
@default_select
910
end
1011

1112
def datetime_picker_default_options
1213
return {} unless @datetime_picker_default_options
14+
1315
@datetime_picker_default_options
1416
end
1517

1618
def datetime_picker_input_format
1719
return "%Y-%m-%d %H:%M" unless @datetime_picker_input_format
20+
1821
@datetime_picker_input_format
1922
end
2023

lib/activeadmin_addons/addons/state_builder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class StateBuilder < CustomBuilder
1111
def render
1212
raise "you need to install AASM gem first" unless defined? AASM
1313
raise "the #{attribute} is not an AASM state" unless state_attribute?
14+
1415
context.status_tag(model.aasm(machine_name).human_state, class: status_class_for_model)
1516
end
1617

lib/activeadmin_addons/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Engine < ::Rails::Engine
44
require "xdan-datetimepicker-rails"
55
require "require_all"
66

7-
initializer "initialize addons" do |app|
7+
initializer "initialize addons" do |_app|
88
require_rel "support"
99
require_rel "addons"
1010
require_rel "active_admin_config"

lib/activeadmin_addons/support/custom_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def attribute
7979
end
8080

8181
def has_label?
82-
has_opts? ? args.length == 3 : args.length == 2
82+
args.length == (has_opts? ? 3 : 2)
8383
end
8484

8585
def has_opts?

lib/activeadmin_addons/support/input_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def to_html
1313
load_control_attributes
1414
render_custom_input
1515
if parts.any?
16-
return input_wrapping { parts_to_html }
16+
input_wrapping { parts_to_html }
1717
else
1818
super
1919
end

lib/activeadmin_addons/support/input_helpers/filter_input_methods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def input_value
1414
end
1515

1616
return unless result
17+
1718
result.values.first.value
1819
end
1920

lib/activeadmin_addons/support/input_helpers/select_helpers.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,19 @@ def active_record_select?
5757
end
5858

5959
def selected_collection
60-
@selected_collection ||= begin
61-
if active_record_relation?(collection)
62-
collection.model.where(id: input_value)
63-
else
64-
method_model.where(id: input_value)
65-
end
66-
end
60+
@selected_collection ||= if active_record_relation?(collection)
61+
collection.model.where(id: input_value)
62+
else
63+
method_model.where(id: input_value)
64+
end
6765
end
6866

6967
def selected_item
7068
@selected_item ||= begin
71-
input_association_value
72-
rescue NoMethodError
73-
selected_collection.first
74-
end
69+
input_association_value
70+
rescue NoMethodError
71+
selected_collection.first
72+
end
7573
end
7674

7775
private

0 commit comments

Comments
 (0)