Skip to content

Commit

Permalink
Switch to package:dart_flutter_team_lints (#1387)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem authored Jul 18, 2024
1 parent f9bcafe commit 3314a87
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 25 deletions.
4 changes: 3 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml
analyzer:
language:
strict-casts: true
Expand All @@ -8,6 +8,8 @@ analyzer:
unused_local_variable: error
dead_code: error
deprecated_member_use_from_same_package: ignore
lines_longer_than_80_chars: ignore
avoid_dynamic_calls: ignore

linter:
rules:
Expand Down
3 changes: 1 addition & 2 deletions lib/src/batch/batch_compare_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:pana/src/package_analyzer.dart';
import 'package:yaml/yaml.dart' as yaml;

import '../package_analyzer.dart';
import '../sdk_env.dart' show SdkConfig, ToolEnvironment;
import '../utils.dart' show withTempDir;

import 'batch_model.dart';

/// Compares pana outcomes on the selected packages.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/batch/batch_query_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class BatchQueryCommand extends Command<void> {

Future<int> _ageInDays(String package) async {
final rs = await _client
.get((Uri.parse('https://pub.dartlang.org/api/packages/$package')));
.get(Uri.parse('https://pub.dartlang.org/api/packages/$package'));
if (rs.statusCode != 200) {
throw AssertionError('Unexpected status code: ${rs.statusCode}');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/batch/batch_run_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import 'dart:convert';
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:pana/src/package_analyzer.dart';
import 'package:yaml/yaml.dart' as yaml;

import '../package_analyzer.dart';
import '../sdk_env.dart' show SdkConfig, ToolEnvironment;
import '../utils.dart' show withTempDir;

import 'batch_model.dart';

/// Runs pana on the selected packages.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import 'dart:convert';
import 'dart:io';

import 'package:meta/meta.dart';
import 'package:pana/src/license_detection/license_detector.dart' hide License;
import 'package:path/path.dart' as p;

import 'license_detection/license_detector.dart' hide License;
import 'model.dart';

const _licenseFileNames = ['LICENSE'];
Expand Down
3 changes: 2 additions & 1 deletion lib/src/license_detection/license_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import 'dart:isolate';
import 'dart:math';

import 'package:meta/meta.dart';
import 'package:pana/src/third_party/diff_match_patch/diff.dart';
import 'package:source_span/source_span.dart';
import 'package:string_scanner/string_scanner.dart';

import '../third_party/diff_match_patch/diff.dart';

part 'confidence.dart';
part 'crc32.dart';
part 'license.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/package_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'dart:io';
import 'dart:typed_data';

import 'package:logging/logging.dart';
import 'package:pana/src/tool/git_tool.dart';
import 'package:path/path.dart' as path;

import 'download_utils.dart';
Expand All @@ -22,6 +21,7 @@ import 'report/create_report.dart';
import 'sdk_env.dart';
import 'tag/pana_tags.dart';
import 'tag/tagger.dart';
import 'tool/git_tool.dart';
import 'tool/run_constrained.dart';
import 'utils.dart';

Expand Down
1 change: 1 addition & 0 deletions lib/src/report/static_analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ FileSpan? sourceSpanFromFile({
return null;
}
return sourceFile.span(startOffset, startOffset + newLength);
// ignore: avoid_catching_errors
} on RangeError {
// Note: This happens if the file contains CR as line terminators.
// If the range is invalid, then we just return null.
Expand Down
3 changes: 1 addition & 2 deletions lib/src/report/template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import 'dart:io';

import 'package:pana/src/tag/license_tags.dart';
import 'package:path/path.dart' as p;
import 'package:pubspec_parse/pubspec_parse.dart' show GitDependency;

import '../markdown_content.dart';
import '../model.dart';
import '../package_context.dart';
import '../tag/license_tags.dart';
import '../utils.dart';

import '_common.dart';

const _pluginDocsUrl =
Expand Down
2 changes: 2 additions & 0 deletions lib/src/repository/check_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Future<VerifiedRepository?> checkRepository({
yamlDoc = yaml.loadYaml(content);
} on FormatException catch (e, st) {
log.info('Invalid yaml file: $path', e, st);
// ignore: avoid_catching_errors
} on ArgumentError catch (e, st) {
log.info('Invalid yaml file: $path', e, st);
}
Expand Down Expand Up @@ -234,6 +235,7 @@ Future<VerifiedRepository?> checkRepository({
} on FormatException catch (e, st) {
failVerification(
'Unable to parse `pubspec.yaml` from git repository. $e', e, st);
// ignore: avoid_catching_errors
} on ArgumentError catch (e, st) {
failVerification(
'Unable to parse `pubspec.yaml` from git repository. $e', e, st);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/screenshots.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'dart:async';
import 'dart:io';
import 'dart:typed_data';

import 'package:pana/pana.dart';
import 'package:path/path.dart' as path;
import 'package:pubspec_parse/pubspec_parse.dart' as p;

import '../pana.dart';
import 'logging.dart';

final maxFileSizeInBytes = 4194304; // 4MB
Expand Down
2 changes: 1 addition & 1 deletion lib/src/third_party/diff_match_patch/diff.dart
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ List<Diff> diffBisect(String text1, String text2, DateTime deadline) {

for (var d = 0; d < maxD; d++) {
// Bail out if deadline is reached.
if ((DateTime.now()).compareTo(deadline) == 1) {
if (DateTime.now().compareTo(deadline) == 1) {
break;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/third_party/diff_match_patch/test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// ignore_for_file: invalid_use_of_visible_for_testing_member

import 'package:pana/src/third_party/diff_match_patch/diff.dart';
// ignore: depend_on_referenced_packages
import 'package:test/test.dart';

import 'diff.dart';

void testDiffMain() {
var expected = <Diff>[];
_testDiffMain(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tool/git_tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:pana/src/utils.dart';
import 'package:path/path.dart' as p;

import '../utils.dart';
import 'run_constrained.dart';

/// Runs `git` in an isolated environment using the [homePath] to access its
Expand Down
3 changes: 2 additions & 1 deletion lib/src/tool/run_constrained.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import 'dart:convert';
import 'dart:io' hide BytesBuilder;
import 'dart:typed_data';

import 'package:pana/src/logging.dart';
import 'package:retry/retry.dart';

import '../logging.dart';

final _timeout = const Duration(minutes: 2);
const _maxOutputBytes = 10 * 1024 * 1024; // 10 MiB
const _maxOutputLinesWhenKilled = 1000;
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ dependencies:
source_span: ^1.7.0
string_scanner: ^1.1.0
tar: ^2.0.0
yaml: ^3.0.0
test: ^1.5.2 # needed for lib/src/third_party/diff_match_patch/test.dart
yaml: ^3.0.0

dev_dependencies:
build: ^2.0.1
build_config: ^1.0.0
build_runner: ^2.0.4
build_verify: ^3.0.0
build_version: ^2.0.0
dart_flutter_team_lints: ^3.1.0
json_serializable: ^6.0.0
shelf: ^1.0.0
source_gen: ^1.0.0
Expand Down
2 changes: 1 addition & 1 deletion test/license_detector_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void main() {
]);
});

group(('longestUnclaimedPercentage tests:'), () {
group('longestUnclaimedPercentage tests:', () {
_testUnclaimedPercentage(
'Expect 1.0 for no matches found',
[],
Expand Down
7 changes: 0 additions & 7 deletions test/pubspec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ final Pubspec flutterPluginPubspec = Pubspec({
},
});

final Pubspec flutterDependencyPubspec = Pubspec({
'name': 'sample',
'dependencies': {
'flutter': 'any',
},
});

final Pubspec flutterSdkPubspec = Pubspec({
'name': 'sample',
'dependencies': {
Expand Down

0 comments on commit 3314a87

Please sign in to comment.