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 #8431] Add Safety
section to documentation for all cops that are Safe: false
or SafeAutoCorrect: false
#10094
Conversation
Register a `@safety` custom YARD tag, and uses it to create a new section to the documentation about cop safety. Also updates the `new_cop` template to add the `@safety` tag section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work! This looks very user friendly! IMO, it's better to have a project_spec for this, but this PR changes themself are well worth!
…false` or `SafeAutoCorrect: false`.
02513cc
to
39b6d91
Compare
So as far as I can tell, we need YARD to have regenerated the However, if If we can solve these, here is a scaffold for a test: https://gist.github.com/dvandersluis/0d692eafd4696f542f5bd6abd1840043. We can conceivably extend this to check for missing |
Thank you for investigating. Unfortunately I'm not sure about it right away 💦 (and so far I don't have a strong opinion yet.)
Yeah, I think we can add that spec later when we are really in trouble. First of all, I think the content of the current PR is sufficient 😃 |
Sounds good to me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic change!
I agreed. I've long wanted to automate checking the docs for some required structure and it'd be great to eventually get there. Step by step... :-) |
Follow up to rubocop/rubocop#10094.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Follow up to rubocop/rubocop#10094. This PR adds safety section to documentation for all cops that are `Safe: false` or `SafeAutoCorrect: false`.
Documents safety concerns for every cop that is either
Safe: false
orSafeAutoCorrect: false
. This documentation will show up as a separate subsection in each cop's documentation once the .adoc files are generated.For example:
In order to make this happen, I added a custom
@safety
YARD tag that is used to process the documentation, which should make it simple when creating a new unsafe cop (I also updated therake new_cop
template) or changing a cop to be unsafe.The text for the safety section comes either from the text that already existed in the cop (🙌 to everyone who added a reason when marking a cop unsafe); looking through many old PRs in order to try to determine why the cop was made unsafe; or using my best guess if I could not find a better reason. While I was going through documentation I took the opportunity to make some minor tweaks as well.
I tried writing a
project_spec
test to ensure a@safety
block is added for cops that are unsafe, but could not find a way to get the yard code object for a class (the documentation generator relies on yard's generation rake task, which I did not want to run in a spec). If anyone has any suggestions please let me know!Altogether, 66 cops were updated by this change.
Fixes #8431.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.