• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dart-lang / linter / 6444183028

01 Sep 2023 04:26PM CUT coverage: 96.562% (+0.01%) from 96.551%
6444183028

push

github

web-flow
update labels (#4740)

9127 of 9452 relevant lines covered (96.56%)

1.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/src/util/score_utils.dart
1
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4

5
import 'package:analyzer/src/lint/config.dart'; // ignore: implementation_imports
6
import 'package:http/http.dart' as http;
7

8
import '../utils.dart';
9

10
Future<List<String>> _readCoreLints() async => _fetchLints(
×
11
    'https://raw.githubusercontent.com/dart-lang/lints/main/lib/core.yaml');
12

13
/// todo(pq): de-duplicate these fetches / URIs
14
Future<List<String>> _readFlutterLints() async => _fetchLints(
×
15
    'https://raw.githubusercontent.com/flutter/packages/main/packages/flutter_lints/lib/flutter.yaml');
16

17
Future<List<String>> _readRecommendedLints() async => _fetchLints(
×
18
    'https://raw.githubusercontent.com/dart-lang/lints/main/lib/recommended.yaml');
19

20
/// todo(pq): update `scorecard.dart` to reuse these fetch functions.
21
Future<List<String>> _fetchLints(String url) async {
×
22
  var req = await http.get(Uri.parse(url));
×
23
  return _readLints(req.body);
×
24
}
25

26
List<String> _readLints(String contents) {
×
27
  var lintConfigs = processAnalysisOptionsFile(contents);
×
28
  if (lintConfigs == null) {
29
    return [];
×
30
  }
31
  return lintConfigs.ruleConfigs.map((c) => c.name ?? '<unknown>').toList();
×
32
}
33

34
List<String>? _coreRules;
35
List<String>? _recommendedRules;
36
List<String>? _flutterRules;
37

38
Future<List<String>> get coreRules async =>
×
39
    _coreRules ??= await _readCoreLints();
×
40

41
Future<List<String>> get recommendedRules async =>
×
42
    _recommendedRules ??= await _readRecommendedLints();
×
43

44
Future<List<String>> get flutterRules async =>
×
45
    _flutterRules ??= await _readFlutterLints();
×
46

47
Future<List<String>> fetchRules(Uri optionsUrl) async {
×
48
  var config = await _fetchConfig(optionsUrl);
×
49
  if (config == null) {
50
    printToConsole('no config found for: $optionsUrl (SKIPPED)');
×
51
    return <String>[];
×
52
  }
53
  var rules = <String>[];
×
54
  for (var ruleConfig in config.ruleConfigs) {
×
55
    var name = ruleConfig.name;
×
56
    if (name != null) {
57
      rules.add(name);
×
58
    }
59
  }
60
  return rules;
61
}
62

63
Future<LintConfig?> _fetchConfig(Uri url) async {
×
64
  printToConsole('loading $url...');
×
65
  var req = await http.get(url);
×
66
  return processAnalysisOptionsFile(req.body);
×
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc