Skip to content

Commit 3584e11

Browse files
committed
Autocorrect Rubocop offenses in OP components
1 parent 98c3106 commit 3584e11

6 files changed

Lines changed: 23 additions & 25 deletions

File tree

app/components/primer/open_project/fieldset.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Fieldset < Primer::Component
1818
# @param legend_text [String] A legend should be short and concise. The String will also be read by assistive technology.
1919
# @param visually_hide_legend [Boolean] Controls if the legend is visible. If `true`, screen reader only text will be added.
2020
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
21-
def initialize(legend_text: nil, visually_hide_legend: false, **system_arguments) # rubocop:disable Lint/MissingSuper
21+
def initialize(legend_text: nil, visually_hide_legend: false, **system_arguments)
2222
@legend_text = legend_text
2323
@visually_hide_legend = visually_hide_legend
2424
@system_arguments = deny_tag_argument(**system_arguments)
@@ -40,7 +40,7 @@ class LegendComponent < Primer::Component
4040

4141
attr_reader :text
4242

43-
def initialize(text: nil, visually_hide_legend: false, **system_arguments) # rubocop:disable Lint/MissingSuper
43+
def initialize(text: nil, visually_hide_legend: false, **system_arguments)
4444
@text = text
4545

4646
@system_arguments = deny_tag_argument(**system_arguments)

app/components/primer/open_project/flex_layout.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def render?
2929
# no slot provided
3030
return false if rows.empty? && columns.empty? && boxes.empty?
3131

32-
if [rows, columns, boxes].count { |arr| !arr.empty? } == 1
32+
if [rows, columns, boxes].one? { |arr| !arr.empty? }
3333
# only rows or columns or boxes are used
3434
true
35-
elsif [rows, columns, boxes].count { |arr| !arr.empty? } > 1
35+
elsif [rows, columns, boxes].many? { |arr| !arr.empty? }
3636
# rows, columns and boxes are used together, which is not allowed
3737
raise ArgumentError, "You can't mix row, column and box slots"
3838
end

app/components/primer/open_project/inline_message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class InlineMessage < Primer::Component
3333
# @param scheme [Symbol] <%= one_of(Primer::OpenProject::InlineMessage::SCHEME_OPTIONS) %>
3434
# @param size [Symbol] <%= one_of(Primer::OpenProject::InlineMessage::SIZE_OPTIONS) %>
3535
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
36-
def initialize(scheme:, size: DEFAULT_SIZE, **system_arguments) # rubocop:disable Lint/MissingSuper
36+
def initialize(scheme:, size: DEFAULT_SIZE, **system_arguments)
3737
resolved_scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme)
3838
resolved_size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)
3939

app/components/primer/open_project/page_header.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def render?
288288
end
289289

290290
def render_mobile_menu?
291-
actions.count > 1
291+
actions.many?
292292
end
293293

294294
def show_state?

app/components/primer/open_project/pagination.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ def build_component_data(page)
269269
key = :"page-#{page[:num]}-break"
270270
content = "…"
271271

272-
props.merge!(
273-
role: "presentation"
274-
)
272+
props[:role] = "presentation"
275273
end
276274

277275
props[:class] = class_names("Page", props[:class])

app/components/primer/open_project/sub_header.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SubHeader < Primer::Component
4040
@mobile_actions ||= []
4141
mobile_component = Primer::Beta::IconButton.new(display: MOBILE_ACTIONS_DISPLAY,
4242
**icon_args)
43-
@mobile_actions.push({ component: mobile_component, block: block})
43+
@mobile_actions.push({ component: mobile_component, block: block })
4444

4545
Primer::OpenProject::SubHeader::Button.new(display: DESKTOP_ACTIONS_DISPLAY, **kwargs)
4646
end
@@ -65,9 +65,9 @@ class SubHeader < Primer::Component
6565
mobile_component = Primer::OpenProject::SubHeader::Menu.new(icon_only: true,
6666
display: MOBILE_ACTIONS_DISPLAY,
6767
**kwargs)
68-
@mobile_actions.push({ component: mobile_component, block: block})
68+
@mobile_actions.push({ component: mobile_component, block: block })
6969

70-
Primer::OpenProject::SubHeader::Menu.new(icon_only: icon_only,display: DESKTOP_ACTIONS_DISPLAY, **kwargs)
70+
Primer::OpenProject::SubHeader::Menu.new(icon_only: icon_only, display: DESKTOP_ACTIONS_DISPLAY, **kwargs)
7171
},
7272
}
7373
}
@@ -146,7 +146,7 @@ class SubHeader < Primer::Component
146146
if icon_only
147147
Primer::Beta::IconButton.new(**icon_args)
148148
else
149-
@mobile_filter_button = Primer::Beta::IconButton.new(display: MOBILE_ACTIONS_DISPLAY,
149+
@mobile_filter_button = Primer::Beta::IconButton.new(display: MOBILE_ACTIONS_DISPLAY,
150150
**icon_args)
151151

152152
Primer::OpenProject::SubHeader::Button.new(display: DESKTOP_ACTIONS_DISPLAY, **kwargs)
@@ -194,18 +194,18 @@ class SubHeader < Primer::Component
194194
}
195195

196196
renders_one :segmented_control, lambda { |**system_arguments, &block|
197-
deny_tag_argument(**system_arguments)
198-
system_arguments[:mr] ||= 2
199-
system_arguments = set_as_hidden_filter_target(system_arguments)
200-
201-
@segmented_control_block = block
202-
@mobile_segmented_control = Primer::OpenProject::SubHeader::SegmentedControl.new(
203-
hide_labels: true,
204-
display: MOBILE_ACTIONS_DISPLAY,
205-
**system_arguments
206-
)
207-
208-
Primer::OpenProject::SubHeader::SegmentedControl.new(display: DESKTOP_ACTIONS_DISPLAY, **system_arguments)
197+
deny_tag_argument(**system_arguments)
198+
system_arguments[:mr] ||= 2
199+
system_arguments = set_as_hidden_filter_target(system_arguments)
200+
201+
@segmented_control_block = block
202+
@mobile_segmented_control = Primer::OpenProject::SubHeader::SegmentedControl.new(
203+
hide_labels: true,
204+
display: MOBILE_ACTIONS_DISPLAY,
205+
**system_arguments
206+
)
207+
208+
Primer::OpenProject::SubHeader::SegmentedControl.new(display: DESKTOP_ACTIONS_DISPLAY, **system_arguments)
209209
}
210210

211211
renders_one :text, lambda { |**system_arguments|

0 commit comments

Comments
 (0)