Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #7299] Implement Lint/RaiseException cop #7325

Merged
merged 2 commits into from Mar 21, 2020
Merged

Conversation

denys281
Copy link
Contributor

@denys281 denys281 commented Sep 1, 2019

Resolves #7299
Should go with rubocop/ruby-style-guide#775

Cop checks for:

  • raise Exception;
  • raise Exception, 'error message';
  • `raise Exception.new('Error message')
  • Also it works for fail and ::Exception

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

Copy link
Collaborator

@Drenmi Drenmi left a comment

Choose a reason for hiding this comment

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

LGTM! Just a small nit for the matcher. 🚀

lib/rubocop/cop/lint/raise_exception.rb Outdated Show resolved Hide resolved
@Drenmi
Copy link
Collaborator

Drenmi commented Sep 3, 2019

Thanks @denys281! 🙏

config/default.yml Outdated Show resolved Hide resolved
Lint/RaiseException:
Description: Checks for `raise` or `fail` statements which is raise `Exception` class.
Enabled: true
VersionAdded: '0.75'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this in the style guide? If so - let's add a link to the rule.

Copy link
Contributor Author

@denys281 denys281 Sep 5, 2019

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Guess we can add something on the subject there then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbatsov Did you mean in style guide?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bbatsov bbatsov merged commit 9eceed4 into rubocop:master Mar 21, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 21, 2020

Better late than never! :-) Thanks!

olleolleolle added a commit to barsoom/barsoom_utils that referenced this pull request Sep 14, 2020
olleolleolle added a commit to barsoom/barsoom_utils that referenced this pull request Sep 14, 2020
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.

alert on raise Exception usage
3 participants