Skip to content

Commit ff0b8a6

Browse files
authored
Update Rubocop to newest standards (#1043)
* updated rubocop * fix Lint * Update .rubocop.yml * Update .rubocop.yml * Update .rubocop.yml
1 parent 1bd3c91 commit ff0b8a6

103 files changed

Lines changed: 172 additions & 144 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rubocop.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
require:
1+
plugins:
2+
- rubocop-factory_bot
3+
- rubocop-performance
24
- rubocop-rails
35
- rubocop-rspec
4-
- rubocop-performance
6+
- rubocop-rspec_rails
57

68
AllCops:
79
TargetRailsVersion: 7.1
810
TargetRubyVersion: 3.3
911
Exclude:
1012
- 'bin/**/*'
1113
- 'db/schema.rb'
14+
- 'db/migrate/archive/**/*'
1215
- 'config/initializers/simple_form.rb'
1316
- 'config/initializers/simple_form_bootstrap.rb'
1417
- 'node_modules/**/*'
@@ -100,8 +103,5 @@ Style/StringMethods:
100103
Naming/MemoizedInstanceVariableName:
101104
Enabled: false
102105

103-
RSpec/FilePath:
104-
Enabled: false
105-
106-
Rails/BulkChangeTable:
106+
RSpec/SpecFilePathFormat:
107107
Enabled: false

Gemfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ end
7272

7373
group :test do
7474
gem 'rails-controller-testing', '~> 1.0.5'
75-
gem 'rubocop', '~> 1.75.1', require: false
76-
gem 'rubocop-performance'
77-
gem 'rubocop-rails'
78-
gem 'rubocop-rspec'
75+
gem 'rubocop', '~> 1.75.3', require: false
76+
gem 'rubocop-factory_bot', '~> 2.27.1', require: false
77+
gem 'rubocop-performance', '~> 1.25', require: false
78+
gem 'rubocop-rails', '~> 2.31', require: false
79+
gem 'rubocop-rspec', '~> 3.5', require: false
80+
gem 'rubocop-rspec_rails', '~> 2.31', require: false
7981
gem 'simplecov', require: false
8082
gem 'simplecov-lcov', '~> 0.8.0', require: false
8183
gem 'terminal-notifier-guard'

Gemfile.lock

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ GEM
215215
rails-dom-testing (>= 1, < 3)
216216
railties (>= 4.2.0)
217217
thor (>= 0.14, < 2.0)
218-
json (2.10.2)
218+
json (2.11.3)
219219
jwt (2.4.1)
220220
kaminari (1.2.2)
221221
activesupport (>= 4.1.0)
@@ -310,10 +310,10 @@ GEM
310310
paper_trail (16.0.0)
311311
activerecord (>= 6.1)
312312
request_store (~> 1.4)
313-
parallel (1.26.3)
313+
parallel (1.27.0)
314314
paranoia (3.0.1)
315315
activerecord (>= 6, < 8.1)
316-
parser (3.3.7.3)
316+
parser (3.3.8.0)
317317
ast (~> 2.4.1)
318318
racc
319319
pg (1.5.9)
@@ -450,29 +450,40 @@ GEM
450450
rspec-mocks (~> 3.12)
451451
rspec-support (~> 3.12)
452452
rspec-support (3.12.0)
453-
rubocop (1.75.1)
453+
rubocop (1.75.3)
454454
json (~> 2.3)
455455
language_server-protocol (~> 3.17.0.2)
456456
lint_roller (~> 1.1.0)
457457
parallel (~> 1.10)
458458
parser (>= 3.3.0.2)
459459
rainbow (>= 2.2.2, < 4.0)
460460
regexp_parser (>= 2.9.3, < 3.0)
461-
rubocop-ast (>= 1.43.0, < 2.0)
461+
rubocop-ast (>= 1.44.0, < 2.0)
462462
ruby-progressbar (~> 1.7)
463463
unicode-display_width (>= 2.4.0, < 4.0)
464-
rubocop-ast (1.43.0)
464+
rubocop-ast (1.44.1)
465465
parser (>= 3.3.7.2)
466466
prism (~> 1.4)
467-
rubocop-performance (1.14.2)
468-
rubocop (>= 1.7.0, < 2.0)
469-
rubocop-ast (>= 0.4.0)
470-
rubocop-rails (2.14.2)
467+
rubocop-factory_bot (2.27.1)
468+
lint_roller (~> 1.1)
469+
rubocop (~> 1.72, >= 1.72.1)
470+
rubocop-performance (1.25.0)
471+
lint_roller (~> 1.1)
472+
rubocop (>= 1.75.0, < 2.0)
473+
rubocop-ast (>= 1.38.0, < 2.0)
474+
rubocop-rails (2.31.0)
471475
activesupport (>= 4.2.0)
476+
lint_roller (~> 1.1)
472477
rack (>= 1.1)
473-
rubocop (>= 1.7.0, < 2.0)
474-
rubocop-rspec (2.11.1)
475-
rubocop (~> 1.19)
478+
rubocop (>= 1.75.0, < 2.0)
479+
rubocop-ast (>= 1.38.0, < 2.0)
480+
rubocop-rspec (3.6.0)
481+
lint_roller (~> 1.1)
482+
rubocop (~> 1.72, >= 1.72.1)
483+
rubocop-rspec_rails (2.31.0)
484+
lint_roller (~> 1.1)
485+
rubocop (~> 1.72, >= 1.72.1)
486+
rubocop-rspec (~> 3.5)
476487
ruby-progressbar (1.13.0)
477488
ruby2_keywords (0.0.5)
478489
rufus-scheduler (3.8.2)
@@ -550,7 +561,9 @@ GEM
550561
unf (0.1.4)
551562
unf_ext
552563
unf_ext (0.0.8.2)
553-
unicode-display_width (2.6.0)
564+
unicode-display_width (3.1.4)
565+
unicode-emoji (~> 4.0, >= 4.0.4)
566+
unicode-emoji (4.0.4)
554567
uniform_notifier (1.16.0)
555568
validates_timeliness (7.1.0)
556569
activemodel (>= 7.0.0, < 8)
@@ -629,10 +642,12 @@ DEPENDENCIES
629642
redis-rails (~> 5.0.2)
630643
rest-client (~> 2.1.0)
631644
rspec-rails
632-
rubocop (~> 1.75.1)
633-
rubocop-performance
634-
rubocop-rails
635-
rubocop-rspec
645+
rubocop (~> 1.75.3)
646+
rubocop-factory_bot (~> 2.27.1)
647+
rubocop-performance (~> 1.25)
648+
rubocop-rails (~> 2.31)
649+
rubocop-rspec (~> 3.5)
650+
rubocop-rspec_rails (~> 2.31)
636651
sassc-rails (~> 2.1.2)
637652
sentry-rails (~> 5.23)
638653
sentry-ruby (~> 5.23)

README.md

Lines changed: 5 additions & 0 deletions

app/controllers/activities_controller.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ def index
2222
@price_lists_json = PriceList.unarchived.to_json(only: %i[id name])
2323
end
2424

25+
def show # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26+
@activity = Activity.includes(:price_list,
27+
{ orders: [{ order_rows: :product }, :user, :created_by] }).find(params[:id])
28+
authorize @activity
29+
30+
@price_list = @activity.price_list
31+
@bartenders = @activity.bartenders
32+
@orders = @activity.orders
33+
34+
@credit_mutations = @activity.credit_mutations
35+
@credit_mutations_total = @activity.credit_mutations_total
36+
37+
@revenue_by_category = @activity.revenue_by_category
38+
@revenue_with_cash = @activity.revenue_with_cash
39+
@revenue_with_pin = @activity.revenue_with_pin
40+
@revenue_with_credit = @activity.revenue_with_credit
41+
@cash_total = @activity.cash_total
42+
@revenue_total = @activity.revenue_total
43+
44+
@count_per_product = @activity.count_per_product
45+
end
46+
2547
def create
2648
@activity = Activity.new(permitted_attributes.merge(created_by: current_user))
2749
authorize @activity
@@ -61,28 +83,6 @@ def destroy
6183
redirect_to Activity
6284
end
6385

64-
def show # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
65-
@activity = Activity.includes(:price_list,
66-
{ orders: [{ order_rows: :product }, :user, :created_by] }).find(params[:id])
67-
authorize @activity
68-
69-
@price_list = @activity.price_list
70-
@bartenders = @activity.bartenders
71-
@orders = @activity.orders
72-
73-
@credit_mutations = @activity.credit_mutations
74-
@credit_mutations_total = @activity.credit_mutations_total
75-
76-
@revenue_by_category = @activity.revenue_by_category
77-
@revenue_with_cash = @activity.revenue_with_cash
78-
@revenue_with_pin = @activity.revenue_with_pin
79-
@revenue_with_credit = @activity.revenue_with_credit
80-
@cash_total = @activity.cash_total
81-
@revenue_total = @activity.revenue_total
82-
83-
@count_per_product = @activity.count_per_product
84-
end
85-
8686
def order_screen # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
8787
authorize Activity
8888

app/controllers/payments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class PaymentsController < ApplicationController
33
after_action :verify_authorized, only: %i[index create add]
44

55
def index
6-
@payments = Payment.all.order(created_at: :desc)
6+
@payments = Payment.order(created_at: :desc)
77
authorize @payments
88
end
99

app/controllers/price_lists_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def index
88
authorize PriceList
99

1010
price_lists = policy_scope(PriceList.order(created_at: :desc))
11-
products = Product.all.order(:id).includes(:product_prices)
11+
products = Product.order(:id).includes(:product_prices)
1212

1313
@price_list = PriceList.new
1414

app/models/invoice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Invoice < ApplicationRecord
22
has_secure_token
33

4-
enum status: { pending: 0, sent: 1, paid: 3 }
4+
enum :status, { pending: 0, sent: 1, paid: 3 }
55

66
belongs_to :user
77
belongs_to :activity

app/models/payment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class << self
66
undef_method :open
77
end
88
# See: https://docs.mollie.com/payments/status-changes
9-
enum status: { open: 0, pending: 1, paid: 2, failed: 3, canceled: 4, expired: 5 }
9+
enum :status, { open: 0, pending: 1, paid: 2, failed: 3, canceled: 4, expired: 5 }
1010
COMPLETE_STATUSES = %w[paid failed canceled expired].freeze
1111

1212
belongs_to :user, optional: true

app/models/product.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Product < ApplicationRecord
2-
enum category: { beer: 0, low_alcohol_beer: 9, craft_beer: 6, non_alcoholic: 1, distilled: 2, whiskey: 8, wine: 3, food: 4, tobacco: 5,
3-
donation: 7 }
2+
enum :category, { beer: 0, low_alcohol_beer: 9, craft_beer: 6, non_alcoholic: 1, distilled: 2, whiskey: 8, wine: 3, food: 4, tobacco: 5,
3+
donation: 7 }
44

55
has_many :product_prices, dependent: :destroy
66
has_many :price_lists, through: :product_prices, dependent: :restrict_with_error

0 commit comments

Comments
 (0)