Skip to content

False positive in unintended_html_in_doc_comment lint #56465

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

Closed
natebosch opened this issue Aug 13, 2024 · 3 comments
Closed

False positive in unintended_html_in_doc_comment lint #56465

natebosch opened this issue Aug 13, 2024 · 3 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@natebosch
Copy link
Member

The lint fires on references to generic classes in square braces.

/// [List<int>]

In dart doc this generates valid HTML that links to the List class. The lint should allow this (even if `List<int>` with backticks may be better style for these cases).

@natebosch natebosch added legacy-area-analyzer Use area-devexp instead. devexp-linter Issues with the analyzer's support for the linter package labels Aug 13, 2024
@lrhn
Copy link
Member

lrhn commented Aug 14, 2024

This is tricky because [List<int>] is special DartDoc syntax, not CommonMark syntax.

The CommonMark interpretation is to treat the [ and ] literally, unless you have a

[List<int>]: linkTarget

declaration somewhere in the file. Then it is a shorthand link. (Which means parsing is not context free.)

In either case the <int> will be considered an HTML tag when rendered.

If DartDoc replaces remaining [List<int>]s by something else, then ... we probably need to figure out which criteria are used for that, and which approach is used to find the tags in the DartDoc code.
(Does it do Commonmark parsing first, then look for remaining [...]s which were not parsed as a link? if so, is the contents of [...] already markdown parsed too? Has it removed the unknown HTML tag <int> like it would remove <int> outside of a [...]? Is that why it works? Does [List<div>] work the same?)

Doesn't feel like a slam-dunk, but we probably can recognize \[[^`[\]]*\](?![([]) to ignore the contents of the [...]. It just won't find

Is [foo<upper>2</upper>] valid?

[foo<upper>2</upper>]: https://example.com

where you intended to write <sup> instead of <upper>.

@keertip keertip added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Aug 14, 2024
@natebosch
Copy link
Member Author

I found an example where this might be the best way to write it.

https://github.com/dart-lang/tools/blob/d563c38c7cfb03bbf5d1f9360b49c36ba45b97ef/pkgs/graphs/lib/src/topological_sort.dart#L38

Here its useful to link to the exception since it's novel, and it's useful to include the detail of the generic matching the generic on the method call. I can't find a way like prefer to phrase it where these aren't the same word.

natebosch added a commit to dart-lang/tools that referenced this issue Aug 14, 2024
Wait for the false positives to be resolved.
dart-lang/sdk#56465

Referring to an exception with a generic worth specifying for the first
time in a doc seems to me to be a valid reason to use this pattern.
natebosch added a commit to dart-lang/tools that referenced this issue Aug 14, 2024
Wait for the false positives to be resolved.
dart-lang/sdk#56465

Referring to an exception with a generic worth specifying for the first
time in a doc seems to me to be a valid reason to use this pattern.
@natebosch
Copy link
Member Author

Closing in favor of #59516

@natebosch natebosch closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants