prototool icon indicating copy to clipboard operation
prototool copied to clipboard

V2 comment rule fails to recognize valid comments

Open Fleshgrinder opened this issue 6 years ago • 5 comments

I like Markdown because of its easy rules and plain text readability and I am sure others do to. I have the following simple comment:

// [ISO 4217] currency codes.
//
// [ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217
enum Currency {

However, this fails the comment rule telling me:

fleshgrinder/v1/country.proto:16:1:Enum "Currency" needs a comment with a complete sentence that starts on the first line of the comment.

I agree with the sentiment of this but I already have a comment. Anything we can do about this? ☺️

Fleshgrinder avatar Oct 01 '19 14:10 Fleshgrinder

The simple fix for this would be to add the following to your prototool.yaml file:

ignores:
   - id: ENUM_FIELDS_HAVE_SENTENCE_COMMENTS
      files:
      - <path/to/your/file>

smaye81 avatar Oct 11 '19 21:10 smaye81

But I like the check, it is a good check. The question is if we can make it a little more intelligent. Right now I rewrote the comment so that it passes which is imho the better workaround because managing all those ignores becomes a burden very fast.

Fleshgrinder avatar Oct 12 '19 06:10 Fleshgrinder

It's tough bc for things like:

// These are currency codes.
//
// a sentence fragment
enum Currency {

There's no easy way to tell. I suppose we could make exceptions for certain Markdown symbols, but that could get unwieldy and hard to manage very fast.

smaye81 avatar Oct 12 '19 22:10 smaye81

Why is allowing more a breaking change? The example of yours would still pass the lint check.

The amount of additional constructs to allow is also very limited:

  • ` to start a sentence in monospace
  • * and _ to start a sentence in italic
  • ** and __ to start a sentence in bold
  • #{1,6} to start a sentence with a heading
  • > to start a sentence with a quote
  • [ to start a sentence with a link
  • ![ to start a sentence with an image

Fleshgrinder avatar Oct 13 '19 09:10 Fleshgrinder

That's fair. I've also considered doing something along those lines for the TIME field linter because fields like runtime fail the lint check with a false positive. What I'll probably do is build the exemptions into the lint rule itself. Ideally, it would be cool to specify exemptions in your prototool.yaml but that can be a follow-up change.

smaye81 avatar Oct 13 '19 13:10 smaye81