ruby-style-guide icon indicating copy to clipboard operation
ruby-style-guide copied to clipboard

Recommendation for a comment that contains a very long url

Open jonahx opened this issue 7 years ago • 5 comments

For example:

# for a detailed explanation of the history of this prefix see:
# https://github.com/bbatsov/some-really-really-really-really-really-really-longer-than-80-chars-url
name_prefix = "SDF_"

In code, we have multiple methods to split up a long literal string across lines while respecting the 80 character limit.

Is there a solution in this case? If not, does the style guide have a recommendation?

jonahx avatar Apr 23 '18 01:04 jonahx

I didn't find anything in the style guide, but some part-solution options that could be considered alone or together:

  • Use a trusted URL shortener
  • Move the URL to the commit message
  • Use a custom annotation like WHY or HISTORY to hint to the developer to refer to the commit history

eliotsykes avatar Apr 23 '18 08:04 eliotsykes

Related, the AllowURI option of Rubocop's LineLength rule http://rubocop.readthedocs.io/en/latest/cops_metrics/#metricslinelength

eliotsykes avatar Apr 24 '18 09:04 eliotsykes

@eliotsykes thanks. does that mean that the default for rubocop is to ignore violations of the 80 char limit if those violations are a URI?

jonahx avatar Apr 24 '18 14:04 jonahx

@jonahx That's what those docs suggest.

eliotsykes avatar Apr 24 '18 14:04 eliotsykes

I guess we should mention this in the guide as well.

bbatsov avatar Jun 12 '19 09:06 bbatsov