kisstkondoros / codemetrics

VSCode extension which shows the complexity information for TypeScript class members
Other
402 stars 20 forks source link

Wouldn't be great if there is a feature which check if a function has been properly commented. (Feature request) #94

Closed navanshu closed 1 year ago

navanshu commented 3 years ago

Hi Codemetrics is quite a good tools and helps manage a clean codebase., but people still have a habbit of skipping comments and then regretting it later. If there was an implementation of whether one has commented of not and comment score would be good.

spartanatreyu commented 3 years ago

There's no real way for code to determine what a good comment is. A substantial amount of developers can't write good comments to begin with.

If you force developers to write comments in their functions, you might end up with bad commenting like this: (taken from here):

function hashIt(data) {
  // The hash
  let hash = 0;

  // Length of string
  const length = data.length;

  // Loop through every character in data
  for (let i = 0; i < length; i++) {
    // Get character code.
    const char = data.charCodeAt(i);
    // Make the hash
    hash = (hash << 5) - hash + char;
    // Convert to 32-bit integer
    hash &= hash;
  }
}

Looking at something like JSDoc/Javadoc/whateverdoc might be more useful but sometimes even that is just noise. I don't think there is a proper way to mandate comments across all languages (and sometimes even within one langauge), just because so many different code styles would support useful comments in different ways.