Skip to content

Update MailLaterLinter to only check UserMailer#7187

Merged
zachmargolis merged 3 commits intomainfrom
margolis-update-mail-later-linter
Oct 21, 2022
Merged

Update MailLaterLinter to only check UserMailer#7187
zachmargolis merged 3 commits intomainfrom
margolis-update-mail-later-linter

Conversation

@zachmargolis
Copy link
Contributor

🎫 Ticket

N/A

🛠 Summary of changes

Follow-up to #7155 (comment)

Basically, ReportMailer.something.deliver_now is fine, but we still want to ensure consistency for UserMailer

Comment on lines +23 to +32
receiver = node.children.first&.receiver
return if !receiver

mailer_name = if receiver.const_type?
# MailerClass.email.send_later
receiver.const_name
elsif receiver.method_name == :with
# MailerClass.with(...).email.send_later
receiver.receiver.const_name
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another approach would be to get smarter about matching expressions... something like...

(send
  (send
    (send
      (const nil :UserMailer) :with
      $...) $...) :deliver_now)

where we have a regex capture for :deliver_now and also check :deliver_later

or maybe two regexes?

anyways this was something I could brute-force via specs

[skip changelog]
@zachmargolis zachmargolis assigned aduth and unassigned aduth Oct 21, 2022
@zachmargolis zachmargolis requested a review from aduth October 21, 2022 19:45
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@zachmargolis zachmargolis merged commit 9454cbf into main Oct 21, 2022
@zachmargolis zachmargolis deleted the margolis-update-mail-later-linter branch October 21, 2022 20:11
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