Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit f71a860

Browse files
authored
fix: stabilized command usage tests (#626)
* fix: stabilized command usage tests * docs: add missing documentation
1 parent 448b1f6 commit f71a860

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* feat: add static code diagnostics `avoid-global-state`.
66
* chore: migrate from deprecated api
77
* fix: fixed issue with type check in prefer-match-file-name
8+
* fix: stabilized command usage tests
89
* doc: add flutter favorite badge
910
* chore: disable github_checks annotations from codecov
1011
* chore: activate language strict rules

test/src/cli/commands/analyze_command_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@TestOn('vm')
22
import 'package:dart_code_metrics/src/cli/cli_runner.dart';
33
import 'package:dart_code_metrics/src/cli/commands/analyze_command.dart';
4+
import 'package:path/path.dart' as p;
45
import 'package:test/test.dart';
56

67
const _usage = 'Collect code metrics, rules and anti-patterns violations.\n'
@@ -67,10 +68,7 @@ void main() {
6768

6869
test('should have correct usage', () {
6970
expect(
70-
command.usage.replaceAll(
71-
RegExp('defaults to "(.*?)dart-code-metrics"'),
72-
'defaults to current directory',
73-
),
71+
command.usage.replaceAll('"${p.current}"', 'current directory'),
7472
_usage,
7573
);
7674
});

test/src/cli/commands/check_unused_files_command_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@TestOn('vm')
22
import 'package:dart_code_metrics/src/cli/cli_runner.dart';
33
import 'package:dart_code_metrics/src/cli/commands/check_unused_files_command.dart';
4+
import 'package:path/path.dart' as p;
45
import 'package:test/test.dart';
56

67
const _usage = 'Check unused *.dart files.\n'
@@ -50,10 +51,7 @@ void main() {
5051

5152
test('should have correct usage', () {
5253
expect(
53-
command.usage.replaceAll(
54-
RegExp('defaults to "(.*?)dart-code-metrics"'),
55-
'defaults to current directory',
56-
),
54+
command.usage.replaceAll('"${p.current}"', 'current directory'),
5755
_usage,
5856
);
5957
});

test/src/cli/commands/check_unused_l10n_command_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@TestOn('vm')
22
import 'package:dart_code_metrics/src/cli/cli_runner.dart';
33
import 'package:dart_code_metrics/src/cli/commands/check_unused_l10n_command.dart';
4+
import 'package:path/path.dart' as p;
45
import 'package:test/test.dart';
56

67
const _usage = 'Check unused localization in *.dart files.\n'
@@ -54,10 +55,7 @@ void main() {
5455

5556
test('should have correct usage', () {
5657
expect(
57-
command.usage.replaceAll(
58-
RegExp('defaults to "(.*?)dart-code-metrics"'),
59-
'defaults to current directory',
60-
),
58+
command.usage.replaceAll('"${p.current}"', 'current directory'),
6159
_usage,
6260
);
6361
});

website/docs/rules/common/avoid-global-state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Warning
1313
The rule should violate on not final and non-const top-level variables.
1414

1515
Having many mutable global variables inside application is a pretty bad practice:
16+
1617
- application state becomes distributed between multiple files
1718
- application state is not protected: it can be modified in almost any place
1819
- it might be hard to debug such applications

website/docs/rules/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Rules configuration is [described here](../getting-started/configuration#configu
1111

1212
## Common {#common}
1313

14+
- [avoid-global-state](./common/avoid-global-state.md)
15+
16+
Warns about usage mutable global variables.
17+
1418
- [avoid-ignoring-return-values](./common/avoid-ignoring-return-values.md)
1519

1620
Warns when a return value of a method or function invocation or a class instance property access is not used.

0 commit comments

Comments
 (0)