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 Rails/SafeNavigationWithBlank cop #133

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

gyfis
Copy link
Contributor

@gyfis gyfis commented Oct 1, 2019

This PR adds a new Rails/SafeNavigatinoWithBlank cop.

It's a clone of the base Ruby cop Lint/SafeNavigationWithEmpty updated for .blank? in Rails, which has the same issue.

It's up for discussion if the cop should cover all usages of safe operator &. and .blank?, and not be limited only to conditionals. This could also be an option of the cop.


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.

@gyfis gyfis force-pushed the th/safe-nagivation-with-blank branch 2 times, most recently from 4ed4fb3 to 5ee1d23 Compare November 10, 2019 10:14
@gyfis
Copy link
Contributor Author

gyfis commented Nov 10, 2019

@koic Thanks a lot for the review!

I fixed the obvious remarks and also took a shot at implementing autocorrect for the cop - during that, I also fixed the pattern matcher a bit (I think it was wrong before).

Let me know if I can do more on this PR!

@gyfis gyfis force-pushed the th/safe-nagivation-with-blank branch from cf22223 to 0a4e377 Compare November 11, 2019 17:11
@gyfis gyfis force-pushed the th/safe-nagivation-with-blank branch from 0a4e377 to 35b9cc0 Compare November 11, 2019 17:12
@koic koic merged commit eb02e64 into rubocop:master Nov 12, 2019
@koic
Copy link
Member

koic commented Nov 12, 2019

Thanks!

koic added a commit that referenced this pull request Nov 16, 2019
Follow up of #133.
koic added a commit that referenced this pull request Nov 16, 2019
Follow up of #133.
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.

3 participants