Skip to content

THREESCALE-9973: Bullet unused eager loading offences [Not Ready for Review]#4282

Open
Madnialihussain wants to merge 11 commits intomasterfrom
buller-unused-eager-loading-offences
Open

THREESCALE-9973: Bullet unused eager loading offences [Not Ready for Review]#4282
Madnialihussain wants to merge 11 commits intomasterfrom
buller-unused-eager-loading-offences

Conversation

@Madnialihussain
Copy link
Copy Markdown
Contributor

@Madnialihussain Madnialihussain commented Apr 20, 2026

What this PR does / why we need it:

Fixes all unused_eager_loading offences in the Bullet safelist. The safelist is reduced from ~50 unused_eager_loading entries down to 3 intentional ones (Bullet's limitation with polymorphic_url).

Which issue(s) this PR fixes:

https://issues.redhat.com/browse/THREESCALE-9973

Verification steps:

  • Run the test suite: all unused_eager_loading Bullet offences pass without safelist entries
  • The 3 remaining entries (Metric :owner, Metric :parent, UsageLimit :metric) are intentional, the includes are needed to prevent N+1 but Bullet cannot detect their use because they are passed as arguments to polymorphic_url

Notes for your reviewer:
32a1a0c: Fix ApiDocs::Service :service false positive, test setup used service: nil, updated to use a real service
7f3546e: Move application_plans include to plans_for_filter and make pricing_rules conditional on finance.allowed?
431a175: Remove unused [:original] from bought_plans, Plan#xml_builder never accesses it
a6abedc: Remove .includes(:issuer) from ApplicationPlansController#collection, only plan.issuer_id (a column) is ever read
18739a7: Remove plan: [:service] from ApplicationPlanLimitsController, plan is already in memory via Rails inverse association
9656bfc: Decouple application finder from applications collection in BuyersApplicationsController, single-record actions were inheriting collection-level includes unnecessarily
86f5457: Fix Invoice unused eager loading, remove buyer_account, decouple invoice finders, use cached line_items sum instead of SQL aggregate
6d38f08: Make admin_user include conditional on buyer context, remove obsolete ServicePlan :pricing_rules entry, deduplicate Metric entries

@Madnialihussain Madnialihussain changed the title Buller unused eager loading offences THREESCALE-9973 Bullet unused eager loading offences Apr 20, 2026
@Madnialihussain Madnialihussain changed the title THREESCALE-9973 Bullet unused eager loading offences THREESCALE-9973: Bullet unused eager loading offences Apr 20, 2026
@Madnialihussain Madnialihussain changed the title THREESCALE-9973: Bullet unused eager loading offences THREESCALE-9973: Bullet unused eager loading offences [Not Ready for Review] Apr 21, 2026
@qltysh
Copy link
Copy Markdown

qltysh Bot commented Apr 21, 2026

❌ 3 blocking issues (4 total)

Tool Category Rule Count
rubocop Style Use %i or %I for an array of symbols. 1
reek Lint Cinstance#self.serialization_preloading is controlled by argument 'format' 1
rubocop Lint Block has too many lines. [146/25] 1
qlty Structure Function with high complexity (count = 5): index 1

@akostadinov
Copy link
Copy Markdown
Contributor

Your work looks great! Could you please stop extending this PR and file new ones. It will become impossible to review if many exceptions are handled at the same time. It is already too big with 21 files. Ideally we would have 1 removed exception per PR. I'm looking at this PR now.

Bullet.add_safelist class_name: "Cinstance", type: :unused_eager_loading, association: :user_account
Bullet.add_safelist class_name: "Invoice", type: :counter_cache, association: :payment_transactions
Bullet.add_safelist class_name: "Invoice", type: :unused_eager_loading, association: :line_items
Bullet.add_safelist class_name: "Invoice", type: :unused_eager_loading, association: :provider_account
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you verify these were false positives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants