Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cop idea: prefer symbol proc to if: and unless: filter lambdas #335

Open
@vlad-pisanov

Description

Model hooks and controller filters that receive if: and unless: lambdas can be written more succinctly using symbols if the lambda consists of a single method call. This cop would enforce either style consistently based on configuration.

# bad
before_save :log, if: -> { name_changed? }
around_destroy :baz, if: -> (user) { user.new? }
after_action :foo, unless: -> { self.bar? }
# good
before_save :log, if: :name_changed?
around_destroy :baz, if: :new?
after_action :foo, unless: :bar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /