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

Rails cops: referer vs referrer #1032

Closed
mockdeep opened this issue May 3, 2016 · 16 comments
Closed

Rails cops: referer vs referrer #1032

mockdeep opened this issue May 3, 2016 · 16 comments
Labels
feature request Request for new functionality good first issue Good for newcomers

Comments

@mockdeep
Copy link

mockdeep commented May 3, 2016

Rails supports both request.referer and request.referrer, and after perusing our codebase we discovered that we're using both. It would be great to have a cop to enforce one or the other for the sake of consistency.

@bbatsov
Copy link
Contributor

bbatsov commented May 4, 2016

Isn't referrer the only correct spelling of the word? :-) Yeah, guess we can have a cop for this. PR welcome!

@bbatsov bbatsov added feature request Request for new functionality good first issue Good for newcomers labels May 4, 2016
@mockdeep
Copy link
Author

mockdeep commented May 4, 2016

Haha, well technically speaking... https://en.wikipedia.org/wiki/HTTP_referer#Etymology

@bbatsov
Copy link
Contributor

bbatsov commented May 4, 2016

Good to know! :-)

@rrosenblum
Copy link
Contributor

@mockdeep, based on the wiki article, this is quite interesting. It appears that the misspelling has become the standard. It raises an interesting question of if referer or referrer should be used. I wonder which spelling other common libraries and frameworks prefer.

@mockdeep
Copy link
Author

mockdeep commented May 9, 2016

@rrosenblum something tells me it isn't very consistently spelled anywhere, though I think we'd go with referer in our codebase just for consistency with the spec.

@mockdeep
Copy link
Author

mockdeep commented May 9, 2016

I could see it being a configurable cop, though, so people can pick their flavor.

@rrosenblum
Copy link
Contributor

I think we'd go with referer in our codebase
I could see it being a configurable cop

I was thinking the same things.

@mockdeep
Copy link
Author

Nice, thanks!

@bquorning
Copy link
Contributor

bquorning commented Jun 20, 2016

Oh, the confusion: https://www.w3.org/TR/html5/links.html#link-type-noreferrer 😆

[…] the user agent must not include a Referer (sic) HTTP header […]

@leewaa
Copy link

leewaa commented Aug 7, 2019

Old issue I know however, this one killed my flow 😂 a cop against something like this is imho, useless! and it wants the incorrect spelling of the word.

The correct spelling is referrer !

@whchi
Copy link

whchi commented Jan 5, 2023

I think not to check is the best practice...

@leewaa
Copy link

leewaa commented Jun 19, 2023

I still can't believe that a cop like this even exists. Rubocop is a great concept, but the devs are taking it way to far with this one 😜

@mockdeep
Copy link
Author

@leewaa you know you can disable rules that aren't useful to you, right? You can also configure it to your preferred spelling. I've been happy with this rule. Having inconsistent spelling makes it harder to grep for references.

@koic koic transferred this issue from rubocop/rubocop Jun 19, 2023
@leewaa
Copy link

leewaa commented Jun 19, 2023

Yes, configuration is a must since everyone runs their own coding style / conventions and the default doesn't suit everyones needs.

I kinda get the reasoning to why this exists, however enforcing the incorrect spelling of a word per default is wrong 😄

@mockdeep
Copy link
Author

mockdeep commented Jun 19, 2023

@leewaa the reason it's enforcing a misspelling is because that is the way it is in the spec. There's nothing forcing you to do it that way in your codebase, but it's not "wrong" to follow the spec. It's perfectly reasonable to stick with the misspelling, since that's more consistent with most other places in the stack, including your browser.

referer

Take your pick, but to me its six of one and half a dozen of the other. It certainly doesn't seem worth fussing over one way or the other.

@leewaa
Copy link

leewaa commented Jun 19, 2023

@leewaa the reason it's enforcing a misspelling is because that is the way it is in the spec. There's nothing forcing you to do it that way in your codebase, but it's not "wrong" to follow the spec. It's perfectly reasonable to stick with the misspelling, since that's more consistent with most other places in the stack, including your browser.

referer

Take your pick, but to me its six of one and half a dozen of the other. It certainly doesn't seem worth fussing over one way or the other.

Thanks for your time, appreciate it. I am already aware of the history, something I had looked into before commenting on this back in 2019. It's actually what makes this so much worse for me 🙈. Why are we still plagued to continue with incorrectly spelling the word, and then even enforcing it per default. I find this is moving in the wrong direction. Just because it's in the spec, doesn't mean we have to cover for that. We already accept either spelling in rails, so why not choose the correct spelling as default?

Anyway Ill stop here, as you said it's not really worth the fuss, though I do like healthy discussion.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for new functionality good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants