rubocop / rubocop/ruby-style-guide

DIscourage rescue error message checking

Open
#951 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
16.5k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Description

I proposed PR https://github.com/rubocop/rubocop/pull/13352 to add a new Lint/NoRescueErrorMessageChecking cop that discourages rescue error matching. We built a custom cop at my company and thought it might be useful to roll it out as built in cop.

I was suggested by @dvandersluis to reach out to the community for feedback whether its a useful cop or not.

# bad
begin
  something
rescue => e
  if e.message.match?(/Duplicate entry/)
    handle_error
  end
end

# bad
begin
  something
rescue => e
  unless e.message.match?(/Duplicate entry/)
    handle_error
  end
end

# good
begin
  something
rescue ActiveRecord::RecordNotUnique => e
  handle_error
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the linked PR #13352 and the Ruby examples in this issue. Assess whether the proposed cop should be part of RuboCop and whether its behavior is sufficiently defined; done means the community has reached a decision on its usefulness and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.