Skip to content

Commit 00bdc51

Browse files
chore(rubocop): Disable or fix last errors (#3179)
As I'm fixing the quotes for string literals, there are other errors showing up so let's fix those. I'm going to merge this one first before updating the quote PRs. Many of them are about old migrations that I don't think we should change. I simply disabled the rule for them. `Cops/ServiceCallCop` was renamed `Lago/ServiceCall` and I excluded the services failing. It's not so easy to fix in this kind of cosmetic PR but it should be done one day. > 3234 files inspected, no offenses detected ![CleanShot 2025-02-13 at 13 58 18@2x](https://github.com/user-attachments/assets/1ec3f073-152a-4219-b2fe-165b1565a983)
1 parent ec75a51 commit 00bdc51

10 files changed

+25
-12
lines changed

.rubocop.yml

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ AllCops:
2828
- 'coverage/**/*'
2929
- 'log/**/*'
3030

31+
# TODO: Fix these services
32+
Lago/ServiceCall:
33+
Exclude:
34+
- 'app/services/integration_mappings/create_service.rb'
35+
- 'app/services/integrations/anrok/create_service.rb'
36+
- 'app/services/integrations/okta/create_service.rb'
37+
- 'app/services/integrations/xero/create_service.rb'
38+
- 'app/services/invites/accept_service.rb'
39+
- 'app/services/invoices/finalize_batch_service.rb'
40+
- 'app/services/invoices/payments/retry_batch_service.rb'
41+
- 'app/services/invoices/retry_batch_service.rb'
42+
3143
# TODO: Enable when we have time to fix all the offenses
3244
Style/StringLiterals:
3345
Enabled: false

app/services/dunning_campaigns/update_service.rb

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def permitted_attributes
3737
end
3838

3939
def handle_thresholds
40-
thresholds_updated = false
41-
4240
input_threshold_ids = params[:thresholds].map { |t| t[:id] }.compact
4341

4442
# Delete thresholds not included in the payload

db/migrate/20221010142031_update_credit_notes.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ def change
1212
change_table :credit_notes, bulk: true do |t|
1313
t.bigint :total_amount_cents, null: false, default: 0
1414

15-
# NOTE: Disable rubocop comment as table is not used in production yet
16-
t.string :total_amount_currency, null: false
15+
t.string :total_amount_currency, null: false # rubocop:disable Rails/NotNullColumn
1716
end
1817
end
1918
end

db/migrate/20230216145442_change_webhooks_object_nullable.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class ChangeWebhooksObjectNullable < ActiveRecord::Migration[7.0]
44
def change
5-
change_column_null :webhooks, :object_id, true
6-
change_column_null :webhooks, :object_type, true
5+
change_column_null :webhooks, :object_id, true # rubocop:disable Rails/BulkChangeTable
6+
change_column_null :webhooks, :object_type, true # rubocop:disable Rails/BulkChangeTable
77
end
88
end

db/migrate/20231117123744_add_organization_id_to_quantified_events.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def down
3232
AND customers.organization_id = quantified_events.organization_id
3333
SQL
3434

35-
change_column_null :quantified_events, :customer_id, false
35+
change_column_null :quantified_events, :customer_id, false # rubocop:disable Rails/BulkChangeTable
3636
remove_column :quantified_events, :organization_id
3737
end
3838
end

db/migrate/20240314163426_add_multiple_values_to_charge_filter_values.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def up
1313
def down
1414
change_table :charge_filter_values, bulk: true do |t|
1515
t.remove :values
16-
t.string :value, null: false
16+
t.string :value, null: false # rubocop:disable Rails/NotNullColumn
1717
end
1818
end
1919
end

db/migrate/20240425131701_update_cached_aggregations.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class UpdateCachedAggregations < ActiveRecord::Migration[7.0]
44
def change
5-
change_column_null :cached_aggregations, :event_id, true
5+
change_column_null :cached_aggregations, :event_id, true # rubocop:disable Rails/BulkChangeTable
66
add_column :cached_aggregations, :current_amount, :decimal
77
end
88
end

db/migrate/20240808080611_remove_amount_currency_from_usage_tresholds.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def up
1111

1212
def down
1313
change_table :usage_thresholds, bulk: true do |t|
14-
t.string :amount_currency, null: false
14+
t.string :amount_currency, null: false # rubocop:disable Rails/NotNullColumn
1515
end
1616
end
1717
end

dev/cops/service_call_cop.rb

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class ServiceCallCop < ::RuboCop::Cop::Base
1212

1313
MSG = "Subclasses of Baseservice should have #call without arguments"
1414

15+
def self.badge
16+
@badge ||= ::RuboCop::Cop::Badge.for("Lago::ServiceCall") # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
17+
end
18+
1519
def on_def(node)
1620
return unless inherits_base_service?(node)
1721
return unless call_method?(node)

lib/tasks/tests/seed_plans.rake

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def generate_children_plans(plan, all_metrics, delete_charge_parents)
9292
# change plan, do not change charges
9393
res = Plans::OverrideService.call(plan: plan, params: {name: "Plan '#{plan.code}' child"})
9494
pl = res.plan
95-
pl.charges.update_all(parent_id: nil) if delete_charge_parents
95+
pl.charges.update_all(parent_id: nil) if delete_charge_parents # rubocop:disable Rails/SkipsModelValidations
9696

9797
# change charges models and properties (randomly)
9898
res = Plans::OverrideService.call(plan: plan, params: {charges: override_charges_rand(plan, all_metrics)})
9999
pl = res.plan
100-
pl.charges.update_all(parent_id: nil) if delete_charge_parents
100+
pl.charges.update_all(parent_id: nil) if delete_charge_parents # rubocop:disable Rails/SkipsModelValidations
101101
end
102102
end
103103

0 commit comments

Comments
 (0)