Skip to content

Commit bdc1d65

Browse files
committed
chore: Address Rubocop offenses (2)
1 parent 5be71eb commit bdc1d65

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins:
1010
AllCops:
1111
Exclude:
1212
- bin/*
13+
- extra/**/*
1314
- spec/dummy_rails/**/*
1415
- vendor/**/*
1516
NewCops: enable

extra/sample_features_app/admin/items.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module Admin
1212

1313
class ItemsRepo < ::TinyAdmin::Plugins::BaseRepository
1414
def fields(options: nil)
15-
COLUMNS.each_with_object({}) do |name, result|
16-
result[name] = TinyAdmin::Field.create_field(name: name)
15+
COLUMNS.to_h do |name|
16+
[name, TinyAdmin::Field.create_field(name: name)]
1717
end
1818
end
1919

@@ -28,7 +28,7 @@ def index_title
2828
def list(page: 1, limit: 10, filters: nil, sort: ['id'])
2929
page_offset = page.positive? ? (page - 1) * limit : 0
3030
[
31-
RECORDS[page_offset...page_offset + limit],
31+
RECORDS[page_offset...(page_offset + limit)],
3232
RECORDS.size
3333
]
3434
end

lib/tiny_admin/actions/index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def evaluate_options(options)
5151

5252
def prepare_filters(fields)
5353
filters = (options[:filters] || []).map { _1.is_a?(Hash) ? _1 : { field: _1 } }
54-
filters = filters.each_with_object({}) { |filter, result| result[filter[:field]] = filter }
54+
filters = filters.to_h { |filter| [filter[:field], filter] }
5555
values = params['q'] || {}
5656
fields.each_with_object({}) do |(name, field), result|
5757
result[field] = { value: values[name], filter: filters[name] } if filters.key?(name)

lib/tiny_admin/plugins/no_auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def configure(_app, _opts = {}); end
88
end
99

1010
module InstanceMethods
11-
def authenticate_user!
11+
def authenticate_user! # rubocop:disable Naming/PredicateMethod
1212
true
1313
end
1414

lib/tiny_admin/views/components/pagination.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def view_template
2222
pages_range((current > pages - 4 ? current - 2 : pages - 2)..pages)
2323
else
2424
pages_range(1..1, with_dots: true)
25-
pages_range(current - 2..current + 2, with_dots: true)
25+
pages_range((current - 2)..(current + 2), with_dots: true)
2626
pages_range(pages..pages)
2727
end
2828
}

spec/lib/tiny_admin/route_for_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe "TinyAdmin.route_for" do
3+
RSpec.describe "TinyAdmin.route_for" do # rubocop:disable RSpec/DescribeClass
44
before do
55
allow(TinyAdmin.settings).to receive(:root_path).and_return("/admin")
66
end

spec/rails_helper.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
# If you are not using ActiveRecord, you can remove these lines.
1515
begin
1616
ActiveRecord::Migration.maintain_test_schema!
17-
rescue ActiveRecord::PendingMigrationError => e
18-
puts e.to_s.strip
17+
rescue ActiveRecord::PendingMigrationError
1918
exit 1
2019
end
2120
end

0 commit comments

Comments
 (0)