• 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

70.0
/lib/src/rules/use_string_in_part_of_directives.dart
1
// Copyright (c) 2022, 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/dart/ast/ast.dart';
6
import 'package:analyzer/dart/ast/visitor.dart';
7

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

10
const _desc = r'Use string in part of directives.';
11

12
const _details = r'''
13
From [Effective Dart](https://dart.dev/effective-dart/usage#do-use-strings-in-part-of-directives):
14

15
**DO** use strings in `part of` directives.
16

17
**BAD:**
18

19
```dart
20
part of my_library;
21
```
22

23
**GOOD:**
24

25
```dart
26
part of '../../my_library.dart';
27
```
28

29
''';
30

31
class UseStringInPartOfDirectives extends LintRule {
32
  static const LintCode code = LintCode('use_string_in_part_of_directives',
33
      'The part-of directive uses a library name.',
34
      correctionMessage:
35
          'Try converting the directive to use the URI of the library.');
36

37
  UseStringInPartOfDirectives()
1✔
38
      : super(
1✔
39
          name: 'use_string_in_part_of_directives',
40
          description: _desc,
41
          details: _details,
42
          group: Group.style,
43
        );
44

45
  @override
1✔
46
  LintCode get lintCode => code;
47

48
  @override
1✔
49
  void registerNodeProcessors(
50
    NodeLintRegistry registry,
51
    LinterContext context,
52
  ) {
53
    var visitor = _Visitor(this);
1✔
54
    registry.addPartOfDirective(this, visitor);
1✔
55
  }
56
}
57

58
class _Visitor extends SimpleAstVisitor<void> {
59
  final LintRule rule;
60

61
  _Visitor(this.rule);
1✔
62

63
  @override
×
64
  void visitPartOfDirective(PartOfDirective node) {
65
    if (node.libraryName != null) {
×
66
      rule.reportLint(node);
×
67
    }
68
  }
69
}
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