dart-code-metrics icon indicating copy to clipboard operation
dart-code-metrics copied to clipboard

[BUG] `format-comment` false positive

Open FMorschel opened this issue 2 years ago • 3 comments

Environment and configuration

DCM version: 5.7.3 Dart SDK version: 3.0.0

Configuration
dart_code_metrics:
  rules:
    - double-literal-format
    - format-comment
    - member-ordering-extended:
        alphabetize: false
        order:
          - constructors
          - named-constructors
          - factory-constructors
          - static-getters-setters
          - static-const-public-fields
          - static-const-private-fields
          - static-final-public-fields
          - static-final-private-fields
          - static-late-final-public-fields
          - static-late-final-private-fields
          - static-late-public-fields
          - static-late-private-fields
          - static-public-fields
          - static-private-fields
          - const-public-fields
          - const-private-fields
          - final-public-fields
          - final-private-fields
          - late-final-public-fields
          - late-final-private-fields
          - late-public-fields
          - late-private-fields
          - public-fields
          - private-fields
          - overridden-public-fields
          - overriden-public-methods
          - static-public-methods
          - static-private-methods
          - public-methods
          - private-methods
          - getters-setters
    - prefer-commenting-analyzer-ignores
    - prefer-first
    - prefer-immediate-return
    - prefer-last

    - always-remove-listener
    - avoid-border-all
    - avoid-returning-widgets:
        ignored-names:
          - testFunction
        ignored-annotations:
          - allowedAnnotation
    - avoid-unnecessary-setstate
    - avoid-wrapping-in-padding
    - prefer-const-border-radius

What did you do?

  // TODO: home.
  // TODO: login.

What did you expect to happen?

No line should trigger since I'm actually formatting them like sentences.

What actually happened?

When I have two lines of comment one after another, this lint triggers. When there is only one, the lint doesn't trigger.

Participation

  • [ ] I am willing to submit a pull request for this issue.

Additional comments

No response

FMorschel avatar May 15 '23 16:05 FMorschel

@FMorschel for multiline comments the rule treats TODO: as separate parts of the sentences (which is probably incorrect) and expects an uppercase letter to be the first after the :.

So this version won't trigger the lint:

// TODO: Home.
// TODO: Login.

incendial avatar May 15 '23 17:05 incendial

The more I look at various examples of todos, the more I'm not sure whether any change should be done here. Most of them start with the uppercase after :.

@FMorschel and you expected for the rule to accept a lowercase letter as the first sentence letter?

incendial avatar May 16 '23 08:05 incendial

Yes, but obviously this is just team standards. This could be solved by, for example, the lint warning about that. That would make us self aware and we could solve that by simply changing the first letter. If we are willing to use DCM, we should be considered of it's boundaries.

FMorschel avatar May 16 '23 09:05 FMorschel