Skip to content

Commit

Permalink
[linter] Add since info for 'missing_code_block_language_in_doc_comment'
Browse files Browse the repository at this point in the history
Change-Id: I87199e1ccea45907e7974309cedd2b064bfa6478
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356980
Reviewed-by: Phil Quitslund <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Kallen Tu <[email protected]>
  • Loading branch information
parlough authored and Commit Queue committed Mar 18, 2024
1 parent 77ac59a commit 3cf6ac9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions pkg/linter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.4.0-wip

- new lint: `missing_code_block_language_in_doc_comment`

# 3.3.0

- removed lint: `always_require_non_null_named_parameters`
Expand Down
27 changes: 19 additions & 8 deletions pkg/linter/tool/machine/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"sets": [],
"fixStatus": "noFix",
"details": "This rule has been removed.\n",
"sinceDartSdk": "3.3.0-wip"
"sinceDartSdk": "3.3.0"
},
{
"name": "avoid_web_libraries_in_flutter",
Expand Down Expand Up @@ -328,6 +328,17 @@
"details": "**DON'T** test for conditions composed only by literals, since the value can be\ninferred at compile time.\n\nConditional statements using a condition which cannot be anything but FALSE have\nthe effect of making blocks of code non-functional. If the condition cannot\nevaluate to anything but `true`, the conditional statement is completely\nredundant, and makes the code less readable.\nIt is quite likely that the code does not match the programmer's intent.\nEither the condition should be removed or it should be updated so that it does\nnot always evaluate to `true` or `false`.\n\n**BAD:**\n```dart\nvoid bad() {\n if (true) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (true && 1 != 0) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (1 != 0 && true) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (1 < 0 && true) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (true && false) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (1 != 0) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (true && 1 != 0 || 3 < 4) {} // LINT\n}\n```\n\n**BAD:**\n```dart\nvoid bad() {\n if (1 != 0 || 3 < 4 && true) {} // LINT\n}\n```\n\n**NOTE:** that an exception is made for the common `while (true) { }` idiom,\nwhich is often reasonably preferred to the equivalent `for (;;)`.\n\n**GOOD:**\n```dart\nvoid good() {\n while (true) {\n // Do stuff.\n }\n}\n```\n",
"sinceDartSdk": "2.0.0"
},
{
"name": "missing_code_block_language_in_doc_comment",
"description": "A code block is missing a specified language.",
"group": "errors",
"state": "stable",
"incompatible": [],
"sets": [],
"fixStatus": "needsEvaluation",
"details": "**DO** specify the language used in the code block of a doc comment.\n\nTo enable proper syntax highlighting of Markdown code blocks,\n[`dart doc`](https://dart.dev/tools/dart-doc) strongly recommends code blocks to\nspecify the language used after the initial code fence.\n\nSee [highlight.js](https://github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md)\nfor the list of languages supported by `dart doc`.\n\n**BAD:**\n```dart\n/// ```\n/// void main() {}\n/// ```\nclass A {}\n```\n\n**GOOD:**\n```dart\n/// ```dart\n/// void main() {}\n/// ```\nclass A {}\n```\n\n",
"sinceDartSdk": "3.4.0-wip"
},
{
"name": "no_adjacent_strings_in_list",
"description": "Don't use adjacent strings in list.",
Expand Down Expand Up @@ -627,7 +638,7 @@
],
"sets": [],
"fixStatus": "hasFix",
"details": "From the [style guide for the flutter repo](https://flutter.dev/style-guide/):\n\n**DO** specify type annotations.\n\nAvoid `var` when specifying that a type is unknown and short-hands that elide\ntype annotations. Use `dynamic` if you are being explicit that the type is\nunknown. Use `Object` if you are being explicit that you want an object that\nimplements `==` and `hashCode`.\n\n**BAD:**\n```dart\nvar foo = 10;\nfinal bar = Bar();\nconst quux = 20;\n```\n\n**GOOD:**\n```dart\nint foo = 10;\nfinal Bar bar = Bar();\nString baz = 'hello';\nconst int quux = 20;\n```\n\nNOTE: Using the the `@optionalTypeArgs` annotation in the `meta` package, API\nauthors can special-case type variables whose type needs to by dynamic but whose\ndeclaration should be treated as optional. For example, suppose you have a\n`Key` object whose type parameter you'd like to treat as optional. Using the\n`@optionalTypeArgs` would look like this:\n\n```dart\nimport 'package:meta/meta.dart';\n\n@optionalTypeArgs\nclass Key<T> {\n ...\n}\n\nmain() {\n Key s = Key(); // OK!\n}\n```\n\n",
"details": "From the [style guide for the flutter repo](https://flutter.dev/style-guide/):\n\n**DO** specify type annotations.\n\nAvoid `var` when specifying that a type is unknown and short-hands that elide\ntype annotations. Use `dynamic` if you are being explicit that the type is\nunknown. Use `Object` if you are being explicit that you want an object that\nimplements `==` and `hashCode`.\n\n**BAD:**\n```dart\nvar foo = 10;\nfinal bar = Bar();\nconst quux = 20;\n```\n\n**GOOD:**\n```dart\nint foo = 10;\nfinal Bar bar = Bar();\nString baz = 'hello';\nconst int quux = 20;\n```\n\nNOTE: Using the the `@optionalTypeArgs` annotation in the `meta` package, API\nauthors can special-case type variables whose type needs to be dynamic but whose\ndeclaration should be treated as optional. For example, suppose you have a\n`Key` object whose type parameter you'd like to treat as optional. Using the\n`@optionalTypeArgs` would look like this:\n\n```dart\nimport 'package:meta/meta.dart';\n\n@optionalTypeArgs\nclass Key<T> {\n ...\n}\n\nmain() {\n Key s = Key(); // OK!\n}\n```\n\n",
"sinceDartSdk": "2.0.0"
},
{
Expand Down Expand Up @@ -1352,7 +1363,11 @@
"group": "style",
"state": "stable",
"incompatible": [],
"sets": [],
"sets": [
"core",
"recommended",
"flutter"
],
"fixStatus": "hasFix",
"details": "Attach library annotations to library directives, rather than\nsome other library-level element.\n\n**BAD:**\n```dart\n@TestOn('browser')\n\nimport 'package:test/test.dart';\n\nvoid main() {}\n```\n\n**GOOD:**\n```dart\n@TestOn('browser')\nlibrary;\n\nimport 'package:test/test.dart';\n\nvoid main() {}\n```\n\n**NOTE:** An unnamed library, like `library;` above, is only supported in Dart\n2.19 and later. Code which might run in earlier versions of Dart will need to\nprovide a name in the `library` directive.\n",
"sinceDartSdk": "2.19.0"
Expand Down Expand Up @@ -1614,11 +1629,7 @@
"group": "style",
"state": "stable",
"incompatible": [],
"sets": [
"core",
"recommended",
"flutter"
],
"sets": [],
"fixStatus": "noFix",
"details": "**DO** prefix library names with the package name and a dot-separated path.\n\nThis guideline helps avoid the warnings you get when two libraries have the same\nname. Here are the rules we recommend:\n\n* Prefix all library names with the package name.\n* Make the entry library have the same name as the package.\n* For all other libraries in a package, after the package name add the\ndot-separated path to the library's Dart file.\n* For libraries under `lib`, omit the top directory name.\n\nFor example, say the package name is `my_package`. Here are the library names\nfor various files in the package:\n\n**GOOD:**\n```dart\n// In lib/my_package.dart\nlibrary my_package;\n\n// In lib/other.dart\nlibrary my_package.other;\n\n// In lib/foo/bar.dart\nlibrary my_package.foo.bar;\n\n// In example/foo/bar.dart\nlibrary my_package.example.foo.bar;\n\n// In lib/src/private.dart\nlibrary my_package.src.private;\n```\n\n",
"sinceDartSdk": "2.0.0"
Expand Down
3 changes: 2 additions & 1 deletion pkg/linter/tool/since/sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ avoid_type_to_string: 2.12.0
avoid_types_as_parameter_names: 2.0.0
avoid_types_on_closure_parameters: 2.0.0
avoid_unnecessary_containers: 2.7.0
avoid_unstable_final_fields: 3.3.0-wip
avoid_unstable_final_fields: 3.3.0
avoid_unused_constructor_parameters: 2.0.0
avoid_void_async: 2.1.0
avoid_web_libraries_in_flutter: 2.6.0
Expand Down Expand Up @@ -95,6 +95,7 @@ lines_longer_than_80_chars: 2.0.0
list_remove_unrelated_type: 2.0.0
literal_only_boolean_expressions: 2.0.0
matching_super_parameters: 3.0.0
missing_code_block_language_in_doc_comment: 3.4.0-wip
missing_whitespace_between_adjacent_strings: 2.8.1
no_adjacent_strings_in_list: 2.0.0
no_default_cases: 2.9.0
Expand Down

0 comments on commit 3cf6ac9

Please sign in to comment.