Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

simple machine readable rule listing #2358

Merged
merged 2 commits into from
Dec 3, 2020
Merged

simple machine readable rule listing #2358

merged 2 commits into from
Dec 3, 2020

Conversation

pq
Copy link
Contributor

@pq pq commented Dec 3, 2020

Sample (snipped) output:

[
  {
    "name": "always_use_package_imports",
    "description": "Avoid relative imports for files in `lib/`.",
    "group": "errors",
    "details": "*DO* avoid relative imports for files in `lib/`.\n\nWhen mixing relative and absolute imports it's possible to create confusion\nwhere the same member gets imported in two different ways. One way to avoid\nthat is to ensure you consistently use absolute imports for files withing the\n`lib/` directory.\n\nThis is the opposite of 'prefer_relative_imports'.\nMight be used with 'avoid_relative_lib_imports' to avoid relative imports of\nfiles within `lib/` directory outside of it. (for example `test/`)\n\n**GOOD:**\n\n```\nimport 'package:foo/bar.dart';\n\nimport 'package:foo/baz.dart';\n\nimport 'package:foo/src/baz.dart';\n...\n```\n\n**BAD:**\n\n```\nimport 'baz.dart';\n\nimport 'src/bag.dart'\n\nimport '../lib/baz.dart';\n\n...\n```\n\n"
  },
  {
    "name": "avoid_empty_else",
    "description": "Avoid empty else statements.",
    "group": "errors",
    "details": "\n**AVOID** empty else statements.\n\n**BAD:**\n```\nif (x > y)\n  print(\"1\");\nelse ;\n  print(\"2\");\n```\n\n"
  },
  {
    "name": "avoid_print",
    "description": "Avoid `print` calls in production code.",
    "group": "errors",
    "details": "**DO** avoid `print` calls in production code.\n\n**BAD:**\n```\nvoid f(int x) {\n  print('debug: $x');\n  ...\n}\n```\n"
  }
]

/cc @csells @devoncarew

@google-cla google-cla bot added the cla: yes label Dec 3, 2020
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.578% when pulling 874fa0f on machine into 332775d on master.

Copy link
Contributor

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Do we want this tool to be run by specific developers? To be committed to the repo periodically, like when we re-gen docs?

@pq
Copy link
Contributor Author

pq commented Dec 3, 2020

I'm not sure? Committing this data is an interesting idea and I hadn't considered it. We might also add other bits too (e.g., badging data or "is this in pedantic?")

I opened dart-lang/sdk#58280 to discuss.

@pq pq merged commit 7266426 into master Dec 3, 2020
@pq pq deleted the machine branch December 3, 2020 18:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

3 participants