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

Add new Style/RaiseString cop #3188

Closed
wants to merge 1 commit into from
Closed

Add new Style/RaiseString cop #3188

wants to merge 1 commit into from

Conversation

tjwp
Copy link
Contributor

@tjwp tjwp commented Jun 1, 2016

This cop checks if raise or fail is called with just a String
and suggests using an exception class.

This cop is disabled by default.

This change partly addresses #3066. There are some projects where I've wanted all raise calls to use custom errors and this would help to enforce that.

  • Wrote [good commit messages][1].
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

This cop checks if `raise` or `fail` is called with just a String
and suggests using an exception class.

This cop is disabled by default.
@jonas054
Copy link
Collaborator

jonas054 commented Jun 5, 2016

A very similar cop, Style/ImplicitRuntimeError, is added in #3182.

@alexdowad
Copy link
Contributor

A couple good things here: both raise and fail are caught, and with both str and dstr arguments. I neglected to handle a couple of those cases.

@jonas054
Copy link
Collaborator

So if you could rewrite this as an improvement of Style/ImplicitRuntimeError, which has been merged to master, that would be great, @tjwp.

@tjwp
Copy link
Contributor Author

tjwp commented Jun 14, 2016

I'm going to close this and will work on a separate PR with improvements for Style/ImplicitRuntimeError.

@tjwp tjwp closed this Jun 14, 2016
@tjwp
Copy link
Contributor Author

tjwp commented Jun 15, 2016

Added improvements here: #3225

@tjwp tjwp deleted the raise-string branch June 15, 2016 12:18
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.

None yet

3 participants