How to get the most value from Dart static analysis

Related tags

Templates pedantic
Overview

Pub

This package is deprecated.

Before it was deprecated, it was the way to get analysis options matching those used internally at Google. This was useful because it was a good starting point for which lints to enable.

Instead, please see package:lints which is the lint recommendation from the Dart team, or package:flutter_lints which extends that for Flutter. These are better than the Google lint set because they take into account the needs of all Dart users, not just Google engineers.

To migrate away from package:pedantic please see the instructions here.

Comments
  • Omit type annotations for local variables make code harder to understand.

    Omit type annotations for local variables make code harder to understand.

    The latest version of the 'default' google analyser settings emit the warning:

    Omit type annotations for local variables (omit_local_variables_types).

    In many cases this improves the readability of code by removing redundant information.

    e.g.

    var  i = 1;
    

    The removal of the type (int) here doesn't affect the codes readability as the type of i is obvious.

    There are however many cases where removing the type actually makes the code harder to read and for a human to do static analysis.

    e.g.

        var code = _extractCode(monetaryAmount, codeLength);
    

    There is no information on this line that tells a reader what type 'code' is. The lack of type information forces the reader to stop and check what type _extractCode returns.

    If you are analysing a class of some complexity, having to stop and check the type of numerous variables significantly slows down the process.

    In a world of auto completion the reduction of a type to 'var' provides little reduction in typing.

    The only other argument for reducing a type to 'var' is visual clutter. Reduction in visual clutter should focus on removing redundant information, in the examples given the information being removed is not redundant.

    I would suggest that the Omit type annotations warning should only be emitted when it is obvious what the type is.

    opened by bsutton 49
  • Provide an options file which includes `package:lints/recommended.yaml`

    Provide an options file which includes `package:lints/recommended.yaml`

    Now that a Dart team-recommended set of lint rules has been published, I think it makes sense to think of pedantic as the layer on top of those rules which we value highly internally.

    (I know that that is not the actual situation; the pedantic rules are just completely separate, but in terms of analysis options files for users, I think it would be pragmatic to think of pedantic this way.)

    Only one analysis options file can be included into another; you cannot include a list of analysis options files. Perhaps you can some day, but there is some hashing out w.r.t. merging that needs doing, and it might not be a high priority item. In the meantime, the only way to include multiple analysis options files into your own is by daisy chaining them. package:lints/recommended.yaml includes package:lints/core.yaml, so you get the lint rules from each.

    It would be great for pedantic to provide a new analysis options file which includes package:lints/recommended.yaml. Something like package:pedantic/recommended.yaml. WDYT?

    opened by srawlins 13
  • Allow future.unawaited aside unawaited(future)

    Allow future.unawaited aside unawaited(future)

    future.unawaited vs. unawaited(future) is a matter of taste :) . Both could silent unawaited_futures. What do you think of adding the following extension?

    extension FutureExt<T> on Future<T> {
      void get unawaited {}
    }
    
    opened by a14n 12
  • migrate to null safety

    migrate to null safety

    ~I am not sure what the unawaited_futures lint would do with a Future? type. If it triggers we may want to allow Future<void>? as the argument here.~

    I went ahead and made the api nullable, at least with the current lint implementation it does trigger and I think it makes sense to.

    I also added an example since I needed to do that to test the lint behavior anyways.

    opened by jakemac53 8
  • consider bumping pedantic by major versions when adding a lint

    consider bumping pedantic by major versions when adding a lint

    I've seen CIs for several projects break after the release of the latest package:pedantic - v1.6.0.

    In the readme for this project, I see:

    This example uses a pinned version because every added lint rule could break a build for projects using it.

    You might consider either

    • making this more explicit - only recommend that consumers use specific versions, or pin to narrow ranges (>=1.5.0 <1.6.0).
    • or, only make pedantic more restrictive - adding more rules - on upgrades to major versions. That would allow projects to use deps like ^1.0.0 and adjust to new versions of pedantic at a more leisurely pace. That would probably also follow the guidance of semver more closely.
    opened by devoncarew 8
  • Unable to use 1.9.0 on Flutter stable 1.12.13+hotfix.5

    Unable to use 1.9.0 on Flutter stable 1.12.13+hotfix.5

    Because every version of flutter_test from sdk depends on pedantic 1.8.0+1 and beyond depends on pedantic ^1.9.0, flutter_test from sdk is forbidden.
    
    So, because beyond depends on flutter_test any from sdk, version solving failed.
    pub get failed (1; So, because beyond depends on flutter_test any from sdk, version solving failed.
    

    Is this intentional? We need to wait until the Flutter test SDK uses 1.9.0 before we can use it in our projects?

    opened by MisterJimson 7
  • Bump SDK constraints for pub

    Bump SDK constraints for pub

    Use a 2.12.0 lower bound since pub does not understand allowed experiments for earlier versions.

    Use a 3.0.0 upper bound to avoid a warning in pub and to give some flexibility in publishing for stable.

    opened by natebosch 6
  • make unawaited a generic function

    make unawaited a generic function

    I just recently hit a snag using unawaited that I believe could have been avoided were it generic.

    Thoughts? Reservations?

    /cc @davidmorgan @bwilkerson

    opened by pq 6
  • unawaited with void return

    unawaited with void return

    The unawaited check doesn't flag calls to async methods which return plain void rather than Future<void>, ie:

    void main() async {
      try {
        doThing(); // No unawaited error here
      } catch (e) {
        print("caught $e");
      }
    }
    
    // Returns void instead of Future<void>
    void doThing() async {
      await Future.delayed(Duration(seconds: 1));
      throw Exception("oops");
    }
    

    I'm not really clear on the semantics of returning void instead of Future from doThing(). IIRC the compiler used to always require returning a Future from async methods and at some point changed to allow just void, but that still seems to function as an awaitable future.

    In the example above, awaiting doThing() results in the exception being caught while not awaiting does not.

    Seems like this should be flagged?

    opened by jklint-g 6
  • sort_constructors_first shows improper suggestions in Flutter

    sort_constructors_first shows improper suggestions in Flutter

    const ValueSlider(
          {Key key,
          @required this.onChanged,
          @required this.labels,
          @required this.values,
          @required this.type,
          this.status = AttendanceStatus.none})
          : super(key: key);
    

    this is caught by the linter even though Flutter puts Key first by default.

    opened by ThinkDigitalSoftware 6
  • Who lints the lints?

    Who lints the lints?

    Vague title, but I couldn't resist it sorry.

    Here's my situation: I want to use pedantic but I've also got quite a few extra lints that I want enabled. Some of those will almost certainly be included in pedantic itself at some point. Since the point of pedantic is to adhere to Google's standard, the lints I add are useful as a point of difference. However, nothing guarantees that they are a point of difference.

    What's the guidance in this situation? It would be nice to know that if my lint configuration becomes redundant at some point (due to a newer pedantic release) that I would be notified, but it seems that this is not the case (I just tried adding a lint that pedantic has already enabled). Is my only recourse to manually pick through the lints I have enabled and see whether they're redundant? Seems finicky.

    opened by kentcb 6
Releases(v1.11.1)
Owner
Google
Google ❤️ Open Source
Google
A fast, extra light and synchronous key-value storage to Get framework

get_storage A fast, extra light and synchronous key-value in memory, which backs up data to disk at each operation. It is written entirely in Dart and

Jonny Borges 257 Dec 21, 2022
Get or set persistent storage value based on MMKV framework.

mmkv_flutter Plugin that allow Flutter to read value from persistent storage or save value to persistent storage based on MMKV framework Getting Start

OpenFlutter 101 Jan 17, 2022
An intuitive Token Parser that includes grammar definition, tokenization, parsing, syntax error and debugging. Implementation based on Lexical Analysis for Dart.

Token Parser An intuitive Token Parser that includes syntax/grammar definition, tokenization and parsing. Implementation based on Lexical Analysis. Re

JUST A SNIPER ツ 2 Dec 15, 2022
Dart library for creating static trees of execution.

Processing tree Dart library for building and executing static trees of execution created in runtime. When to use it The main idea behind usage of thi

The Tosters 1 Dec 20, 2021
Superpowers for Dart. Collection of useful static extension methods.

If you miss an extension, please open an issue or pull request Resources: Documentation Pub Package GitHub Repository On this page you can find some o

Simon Leier 955 Jan 8, 2023
Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation with a minimum password strength required.

password_strength_checker Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation wit

Dario Varriale 6 Aug 8, 2023
Codeflow 19 Sep 29, 2022
soTired is an application for cognitive fatigue assessment. It includes a stand-alone Android app for fatigue detection and an additional part for data management and further analysis.

Motivation soTired is an application for cognitive fatigue assessment. It includes a stand-alone Android app for fatigue detection and an additional p

Team Ulster 2.0 5 Oct 22, 2021
Customizable heat map interface analysis library

Round Spot Customizable heat map interface analysis library Round Spot simplifies the UI accessibility and behaviour analysis for Flutter applications

Stanisław Góra 31 Dec 12, 2022
A SECURE personal data Analysis and Storage system.

Magic Data Bottle Our goal is to design and implement a secure personal data analysis and storage system. Repo Structure app An android app written in

Xinpeng Wei 3 Sep 27, 2022
A most easily usable Duolingo API wrapper in Dart. Duolingo4D is an open-sourced Dart library.

A most easily usable Duolingo API wrapper in Dart! 1. About Duolingo4D Duolingo4D is an open-sourced Dart library. With Duolingo4D, you can easily int

Kato Shinya 18 Oct 17, 2022
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

HiveDB 3.4k Dec 30, 2022
Lightweight and blazing fast key-value database written in pure Dart.

Fast, Enjoyable & Secure NoSQL Database Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. Documenta

HiveDB 3.4k Dec 30, 2022
A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

Simplify Equality Comparisons Overview Being able to compare objects in Dart often involves having to override the == operator as well as hashCode. No

Felix Angelov 747 Jan 8, 2023
A Flutter widget to create an iOS settings-table (static TableView).

flutter_cupertino_settings A Flutter widget to create an iOS settings-table (static TableView). import 'package:flutter_cupertino_settings/flutter_cup

Matthias Rupp 234 Dec 28, 2022
Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? Flutter Shortcuts Plugin is known for : Flutter Shortcuts Fast, performant &

Divyanshu Shekhar 39 Sep 26, 2022
Flutter plugin for creating static & dynamic app shortcuts on the home screen.

Flutter Shortcuts Compatibility ✅ Android ❌ iOS (active issue: iOS support for quick actions) Show some ❤️ and ⭐ the repo Why use Flutter Shortcuts? F

Devs On Flutter 39 Sep 26, 2022
The read-a-book app is using static data. the application I developed has a homepage and detail page

book_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Adil Ahmet Sargın 1 Nov 12, 2021