Skip to content

Commit

Permalink
add additional lints to dart_flutter_team_lints (#167)
Browse files Browse the repository at this point in the history
* add additional lints to dart_flutter_team_lints

* mono_reo generate

* dart fix

* dartfmt

* revert unintentional changes

* updates from review
  • Loading branch information
devoncarew authored Sep 13, 2023
1 parent 7740bef commit babf5d1
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 44 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/dart.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkgs/blast_repo/lib/src/top_level.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:blast_repo/src/tweaks/mono_repo_tweak.dart';
import 'package:git/git.dart';

import 'repo_tweak.dart';
import 'tweaks/auto_publish_tweak.dart';
import 'tweaks/dependabot_tweak.dart';
import 'tweaks/github_action_tweak.dart';
import 'tweaks/mono_repo_tweak.dart';
import 'tweaks/no_reponse_tweak.dart';
import 'utils.dart';

Expand Down
2 changes: 1 addition & 1 deletion pkgs/corpus/bin/deps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void main(List<String> args) async {

var targetPackage = await pub.getPackageInfo(packageName);

final dateOneYearAgo = DateTime.now().subtract(Duration(days: 365));
final dateOneYearAgo = DateTime.now().subtract(const Duration(days: 365));

var limit = packageLimit == null ? null : int.parse(packageLimit);

Expand Down
6 changes: 3 additions & 3 deletions pkgs/corpus/lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ApiUsage {
'packages': fromPackages.toJson(),
'libraries': fromLibraries.toJson(),
};
file.writeAsStringSync(JsonEncoder.withIndent(' ').convert(json));
file.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(json));
}

/// Returns whether we found any references to the target package.
Expand All @@ -70,8 +70,8 @@ class ApiUsage {
}

static ApiUsage fromFile(PackageInfo packageInfo, File file) {
var json =
JsonDecoder().convert(file.readAsStringSync()) as Map<String, dynamic>;
var json = const JsonDecoder().convert(file.readAsStringSync())
as Map<String, dynamic>;
return ApiUsage(
packageInfo,
References.fromJson(json['packages'] as Map<String, dynamic>),
Expand Down
3 changes: 1 addition & 2 deletions pkgs/corpus/lib/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import 'dart:io';

import 'package:corpus/pub.dart';

import 'api.dart';
import 'pub.dart';
import 'utils.dart';

abstract class ReportTarget {
Expand Down
10 changes: 5 additions & 5 deletions pkgs/corpus/test/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ void main() {

setUp(() {
var json =
JsonDecoder().convert(_sampleUsageJson) as Map<String, dynamic>;
const JsonDecoder().convert(_sampleUsageJson) as Map<String, dynamic>;
sampleUsage = ApiUsage(
PackageInfo.from(
JsonDecoder().convert(_packageInfoJson) as Map<String, dynamic>),
PackageInfo.from(const JsonDecoder().convert(_packageInfoJson)
as Map<String, dynamic>),
References.fromJson(json['packages'] as Map<String, dynamic>),
References.fromJson(json['libraries'] as Map<String, dynamic>),
);
Expand All @@ -42,8 +42,8 @@ void main() {
sampleUsage.toFile(tempFile);

var result = ApiUsage.fromFile(
PackageInfo.from(
JsonDecoder().convert(_packageInfoJson) as Map<String, dynamic>),
PackageInfo.from(const JsonDecoder().convert(_packageInfoJson)
as Map<String, dynamic>),
tempFile,
);

Expand Down
4 changes: 2 additions & 2 deletions pkgs/corpus/test/data/dart_library_references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ void main() {
map['three'] = 3;
print(map);

var local = Queue();
Queue.castFrom(local);
var local = Queue<Object>();
Queue.castFrom<Object, String>(local);
}
10 changes: 10 additions & 0 deletions pkgs/dart_flutter_team_lints/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2.0.0

- Enable `strict-inference`.
- Added `comment_references`.
- Added `conditional_uri_does_not_exist`.
- Added `prefer_const_constructors`.
- Added `prefer_relative_imports`.
- Added `test_types_in_equals`.
- Added `use_super_parameters`.

## 1.0.0

- Added `collection_methods_unrelated_type`.
Expand Down
7 changes: 7 additions & 0 deletions pkgs/dart_flutter_team_lints/lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include: package:lints/recommended.yaml
analyzer:
language:
strict-casts: true
strict-inference: true

linter:
rules:
Expand All @@ -35,8 +36,10 @@ linter:
- lines_longer_than_80_chars
- omit_local_variable_types
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_generic_function_type_aliases
- prefer_is_empty
- prefer_relative_imports
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- sort_pub_dependencies
Expand All @@ -47,18 +50,22 @@ linter:
- unnecessary_statements
- use_is_even_rather_than_modulo
- use_string_in_part_of_directives
- use_super_parameters

# correctness
- always_declare_return_types
- avoid_catching_errors
- avoid_dynamic_calls
- await_only_futures
- collection_methods_unrelated_type
- comment_references
- conditional_uri_does_not_exist
- dangling_library_doc_comments
- hash_and_equals
- implicit_call_tearoffs
- no_duplicate_case_values
- only_throw_errors
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
Expand Down
4 changes: 2 additions & 2 deletions pkgs/dart_flutter_team_lints/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: dart_flutter_team_lints
description: An analysis rule set used by the Dart and Flutter teams.
version: 1.0.0
version: 2.0.0
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/dart_flutter_team_lints

environment:
sdk: '>=2.19.0 <3.0.0'
sdk: ^3.0.0

dependencies:
lints: ^2.0.0
Expand Down
3 changes: 1 addition & 2 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import 'dart:io';
import 'dart:math';

import 'package:firehose/src/repo.dart';

import 'src/github.dart';
import 'src/pub.dart';
import 'src/repo.dart';
import 'src/utils.dart';

const String _botSuffix = '[bot]';
Expand Down
3 changes: 2 additions & 1 deletion pkgs/firehose/lib/src/github.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import 'dart:convert';
import 'dart:io';

import 'package:firehose/src/repo.dart';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as path;

import 'repo.dart';

// TODO:(devoncarew): Consider replacing some of this class with package:github.

class Github {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/lib/src/health/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'dart:io';
import 'dart:math';

import 'package:collection/collection.dart';
import 'package:firehose/firehose.dart';

import '../../firehose.dart';
import '../github.dart';
import '../utils.dart';
import 'changelog.dart';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/lib/src/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import 'dart:io';

import 'package:firehose/src/changelog.dart';
import 'package:path/path.dart' as path;
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:yaml/yaml.dart' as yaml;

import 'changelog.dart';
import 'github.dart';

class Repository {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/repo_manage/lib/issue_transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class TransferIssuesCommand extends ReportCommand {
}

print('Waiting a bit to allow Github to catch up...');
await Future<void>.delayed(Duration(seconds: 5));
await Future<void>.delayed(const Duration(seconds: 5));
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkgs/repo_manage/lib/weekly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class WeeklyCommand extends ReportCommand {
final now = DateTime.now();
final currentDay = now.weekday;
final thisWeek = now.subtract(Duration(days: currentDay - 1));
firstReportingDay = thisWeek.subtract(Duration(days: 7));
firstReportingDay = thisWeek.subtract(const Duration(days: 7));
}

lastReportingDay = firstReportingDay.add(Duration(days: 6));
lastReportingDay = firstReportingDay.add(const Duration(days: 6));
}

var repos = noteableRepos.map(RepositorySlug.full).toList();
Expand Down

0 comments on commit babf5d1

Please sign in to comment.