pedantic 1.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 68

pedantic

This package serves three purposes:

  • It documents how Dart static analysis is used internally at Google, including best practices for the code we write. The documentation is this README.md.
  • It contains a corresponding sample analysis_options.yaml.
  • It contains occasional small snippets of Dart code that are used in implementing those best practices.

Note that everything here fits within the guidelines set out in Effective Dart. You could think of that document as the design and this package as one possible partial implementation.

Using Static Analysis

Here is how static analysis is used internally at Google:

  • By default we disallow checking in code with any errors, warnings, or hints.
    • The TODO hint is a permanent exception.
    • Deprecation hints are a permanent exception. Deprecations are handled separately on a case by case basis.
    • unnecessary_no_such_method, unused_element, unused_field and unused_local_variable are allowed.
    • When a new SDK version adds new errors, warnings or hints, we either clean up everything before switching SDK version or maintain a whitelist of allowed violations so it can be gradually cleaned up.
  • Lints are considered and enabled on a case by case basis. When enabling a lint we first clean up all pre-existing violations. After it's enabled, any attempt to check in a further violation will be blocked.

Enabled Lints

The currently enabled lints can be found in the sample analysis_options.yaml.

To use those lints you can add a dev dependency in your pubspec.yaml:

dev_dependencies:
  pedantic: '1.1.0'

and add an include in your analysis_options.yaml:

include: package:pedantic/analysis_options.yaml

Unused Lints

The following lints have been considered and will not be enforced:

always_put_control_body_on_new_line violates Effective Dart "DO format your code using dartfmt". See note about Flutter SDK style below.

always_specify_types violates Effective Dart "AVOID type annotating initialized local variables" and others. See note about Flutter SDK style below.

avoid_as does not reflect standard usage. See note about Flutter SDK style below.

empty_statements is superfluous, enforcing use of dartfmt is sufficient to make empty statements obvious.

prefer_bool_in_asserts is obsolete in Dart 2; bool is required in asserts.

prefer_final_locals does not reflect standard usage.

Note on Flutter SDK Style: some lints were created specifically to support Flutter SDK development. Flutter app developers should instead use standard Dart style as described in Effective Dart, and should not use these lints.

Features and bugs

Please file feature requests and bugs at the issue tracker.

1.1.0

  • Moved analsys_options.yaml under lib so you can import it directly from your own analysis_options.yaml. See README.md for example.

1.0.0

  • Describe Dart static analysis use at Google in README.md.
  • Add sample analysis_options.yaml.
  • Add unawaited method for silencing the unawaited_futures lint.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pedantic: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pedantic/pedantic.dart';
  
Version Uploaded Documentation Archive
1.1.0 Sep 5, 2018 Go to the documentation of pedantic 1.1.0 Download pedantic 1.1.0 archive
1.0.0 Aug 23, 2018 Go to the documentation of pedantic 1.0.0 Download pedantic 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:pedantic/pedantic.dart.

Suggestions

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use pedantic.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0