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 sub-department cop doc generation #10013

Merged
merged 1 commit into from Aug 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rubocop/cop/documentation.rb
Expand Up @@ -8,7 +8,7 @@ module Documentation

# @api private
def department_to_basename(department)
"cops_#{department.downcase}"
"cops_#{department.to_s.downcase.tr('/', '_')}"
Copy link
Member

Choose a reason for hiding this comment

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

Is to_s needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. department is surprisingly a Symbol. downcase (not less surprisingly to me) works on Symbol, but tr doesn't.
I don't have a strong preference where to add .to_s, before or after downcase.
Also, I'll be happy to extract this transformation to a variable for better readability if you see fit.

Copy link
Member

Choose a reason for hiding this comment

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

I get it! This is fine, thank you for your explanation.

end

# @api private
Expand Down