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

Warn against shortened URLs in comments #306

Open
Krinkle opened this issue Jun 28, 2020 · 1 comment
Open

Warn against shortened URLs in comments #306

Krinkle opened this issue Jun 28, 2020 · 1 comment

Comments

@Krinkle
Copy link
Member

Krinkle commented Jun 28, 2020

URLs in code comment should always be unobfuscated.

Various reasons:

  • Ensure longer time survival (as link shorteners haven't been the most stable services in our time).
  • Improve availability of the URL (e.g. the uptime of w.wiki isn't as important as that of wikipedia.org, not knowing what something is meant to point at during critical times can waste valuable time).
  • Allow recognition and graceful degredation. For example, if your URL points to Wikitech, the reader may know that there is a mirror at wikitech-stastic for use during outages. Or if it points to a page you know you've visited before it will either help you find it again because you realise thats the page you're looking for, or you'll know to skip it if you know it doesn't contain what you're looking for.
  • Allow predicting of its purpose, thus helping you decide whether it is going to be useful in answering your question.
  • Communicates value by itself, useful even when offline or if the URL stops working.

Consider the following examples and how they set different expectations.

#! extensions/FooBar/src/quux.js

// This is based on CP agency – <https://www.mediawiki.org/wiki/Manual:CP_Agency>
let exec = this.estimate( args[ i -2 ] / 4.2 );

CP Agency might be a mediawiki feature? I can (also) look for that my mediawiki checkout and its docs pages.

// This is based on CP agency – <https://www.mediawiki.org/wiki/Extension:CP_Agency>

.. or some extension? Perhaps I have a copy of it.

// This is based on CP agency – <https://en.wikipedia.org/wiki/Chronology_Protection_Agent_(computer_science)>

Ah, that's what CP stands for, and it's a general principle in programming? I might remember what it means based on that, or might speculate the Wikipedia article won't help me if my question is about an internal thing to MW.

// This is based on CP agency – <https://w.wiki/123>
let exec = this.estimate( args[ i -2 ] / 4.2 );

Who knows?


Proposal

We could start with a short list of common/known url shorteners and pattern check against them with a rule that applies to Comment nodes in the source code model exposed by ESLint.

My main motivation for this rule is documentation blocks (those with /** syntax) since the generated output of that will be versioned and archived for years, accesible through permalinks (example). However, it seems useful for inline comments as well for the same reasons. It's just that inline comments are less widely exposed and can be fixed more easily if needed.

@edg2s
Copy link
Member

edg2s commented Jun 28, 2020

I don't expect w.wiki links to be any more short-lived than other links at this point, but all the other points make this a good idea anyway.

As this will require new code, it will need to go in eslint-plugin-mediawiki.

Also this rule is completely independent of code, so we will need to check every code block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants