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

Commit 592cd3d

Browse files
authored
feat: exclude .freezed.dart files by default (#1139)
* feat: exclude `.freezed.dart` files by default * docs: update site
1 parent 09b6479 commit 592cd3d

13 files changed

+178
-175
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
* feat: exclude `.freezed.dart` files by default.
56
* fix: handle try and switch statements for [`use-setstate-synchronously`](https://dartcodemetrics.dev/docs/rules/flutter/use-setstate-synchronously)
67
* chore: restrict `analyzer` version to `>=5.1.0 <5.4.0`.
78

lib/src/analyzers/lint_analyzer/lint_analyzer.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,7 @@ class LintAnalyzer {
418418
}
419419

420420
bool _isSupported(FileResult result) =>
421-
result.path.endsWith('.dart') && !result.path.endsWith('.g.dart');
421+
result.path.endsWith('.dart') &&
422+
!result.path.endsWith('.g.dart') &&
423+
!result.path.endsWith('.freezed.dart');
422424
}

lib/src/cli/commands/base_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ abstract class BaseCommand extends Command<void> {
124124
argParser.addOption(
125125
FlagNames.exclude,
126126
help: 'File paths in Glob syntax to be exclude.',
127-
valueHelp: '{/**.g.dart,/**.template.dart}',
128-
defaultsTo: '{/**.g.dart,/**.template.dart}',
127+
valueHelp: '{/**.g.dart,/**.freezed.dart}',
128+
defaultsTo: '{/**.g.dart,/**.freezed.dart}',
129129
);
130130
}
131131

test/src/cli/commands/analyze_command_test.dart

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,50 @@ import 'package:test/test.dart';
55
const _usage = 'Collect code metrics, rules and anti-patterns violations.\n'
66
'\n'
77
'Usage: metrics analyze [arguments] <directories>\n'
8-
'-h, --help Print this usage information.\n'
8+
'-h, --help Print this usage information.\n'
99
'\n'
1010
'\n'
11-
'-r, --reporter=<console> The format of the output of the analysis.\n'
12-
' [console (default), console-verbose, checkstyle, codeclimate, github, gitlab, html, json]\n'
13-
'-o, --output-directory=<OUTPUT> Write HTML output to OUTPUT.\n'
14-
' (defaults to "metrics")\n'
15-
' --json-path=<path/to/file.json> Path to the JSON file with the output of the analysis.\n'
11+
'-r, --reporter=<console> The format of the output of the analysis.\n'
12+
' [console (default), console-verbose, checkstyle, codeclimate, github, gitlab, html, json]\n'
13+
'-o, --output-directory=<OUTPUT> Write HTML output to OUTPUT.\n'
14+
' (defaults to "metrics")\n'
15+
' --json-path=<path/to/file.json> Path to the JSON file with the output of the analysis.\n'
1616
'\n'
1717
'\n'
18-
' --cyclomatic-complexity=<20> Cyclomatic Complexity threshold.\n'
19-
' --halstead-volume=<150> Halstead Volume threshold.\n'
20-
' --lines-of-code=<100> Lines of Code threshold.\n'
21-
' --maximum-nesting-level=<5> Maximum Nesting Level threshold.\n'
22-
' --number-of-methods=<10> Number of Methods threshold.\n'
23-
' --number-of-parameters=<4> Number of Parameters threshold.\n'
24-
' --source-lines-of-code=<50> Source lines of Code threshold.\n'
25-
' --weight-of-class=<0.33> Weight Of a Class threshold.\n'
26-
' --maintainability-index=<50> Maintainability Index threshold.\n'
27-
' --technical-debt=<0> Technical Debt threshold.\n'
18+
' --cyclomatic-complexity=<20> Cyclomatic Complexity threshold.\n'
19+
' --halstead-volume=<150> Halstead Volume threshold.\n'
20+
' --lines-of-code=<100> Lines of Code threshold.\n'
21+
' --maximum-nesting-level=<5> Maximum Nesting Level threshold.\n'
22+
' --number-of-methods=<10> Number of Methods threshold.\n'
23+
' --number-of-parameters=<4> Number of Parameters threshold.\n'
24+
' --source-lines-of-code=<50> Source lines of Code threshold.\n'
25+
' --weight-of-class=<0.33> Weight Of a Class threshold.\n'
26+
' --maintainability-index=<50> Maintainability Index threshold.\n'
27+
' --technical-debt=<0> Technical Debt threshold.\n'
2828
'\n'
2929
'\n'
30-
'-c, --print-config Print resolved config.\n'
30+
'-c, --print-config Print resolved config.\n'
3131
'\n'
3232
'\n'
33-
' --root-folder=<./> Root folder.\n'
34-
' (defaults to current directory)\n'
35-
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
36-
' --exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.\n'
37-
' (defaults to "{/**.g.dart,/**.template.dart}")\n'
33+
' --root-folder=<./> Root folder.\n'
34+
' (defaults to current directory)\n'
35+
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
36+
' --exclude=<{/**.g.dart,/**.freezed.dart}> File paths in Glob syntax to be exclude.\n'
37+
' (defaults to "{/**.g.dart,/**.freezed.dart}")\n'
3838
'\n'
3939
'\n'
40-
" --no-congratulate Don't show output even when there are no issues.\n"
40+
" --no-congratulate Don't show output even when there are no issues.\n"
4141
'\n'
4242
'\n'
43-
' --[no-]verbose Show verbose logs.\n'
43+
' --[no-]verbose Show verbose logs.\n'
4444
'\n'
4545
'\n'
46-
' --set-exit-on-violation-level=<warning> Set exit code 2 if code violations same or higher level than selected are detected.\n'
47-
' [noted, warning, alarm]\n'
48-
' --[no-]fatal-style Treat style level issues as fatal.\n'
49-
' --[no-]fatal-performance Treat performance level issues as fatal.\n'
50-
' --[no-]fatal-warnings Treat warning level issues as fatal.\n'
51-
' (defaults to on)\n'
46+
' --set-exit-on-violation-level=<warning> Set exit code 2 if code violations same or higher level than selected are detected.\n'
47+
' [noted, warning, alarm]\n'
48+
' --[no-]fatal-style Treat style level issues as fatal.\n'
49+
' --[no-]fatal-performance Treat performance level issues as fatal.\n'
50+
' --[no-]fatal-warnings Treat warning level issues as fatal.\n'
51+
' (defaults to on)\n'
5252
'\n'
5353
'Run "metrics help" to see global options.';
5454

test/src/cli/commands/check_unnecessary_nullable_command_test.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ const _usage =
66
'Check unnecessary nullable parameters in functions, methods, constructors.\n'
77
'\n'
88
'Usage: metrics check-unnecessary-nullable [arguments] <directories>\n'
9-
'-h, --help Print this usage information.\n'
9+
'-h, --help Print this usage information.\n'
1010
'\n'
1111
'\n'
12-
'-r, --reporter=<console> The format of the output of the analysis.\n'
13-
' [console (default), json]\n'
12+
'-r, --reporter=<console> The format of the output of the analysis.\n'
13+
' [console (default), json]\n'
1414
'\n'
1515
'\n'
16-
'-c, --print-config Print resolved config.\n'
16+
'-c, --print-config Print resolved config.\n'
1717
'\n'
1818
'\n'
19-
' --root-folder=<./> Root folder.\n'
20-
' (defaults to current directory)\n'
21-
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
22-
' --exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.\n'
23-
' (defaults to "{/**.g.dart,/**.template.dart}")\n'
19+
' --root-folder=<./> Root folder.\n'
20+
' (defaults to current directory)\n'
21+
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
22+
' --exclude=<{/**.g.dart,/**.freezed.dart}> File paths in Glob syntax to be exclude.\n'
23+
' (defaults to "{/**.g.dart,/**.freezed.dart}")\n'
2424
'\n'
2525
'\n'
26-
" --no-congratulate Don't show output even when there are no issues.\n"
26+
" --no-congratulate Don't show output even when there are no issues.\n"
2727
'\n'
2828
'\n'
29-
' --[no-]verbose Show verbose logs.\n'
29+
' --[no-]verbose Show verbose logs.\n'
3030
'\n'
3131
'\n'
32-
' --[no-]monorepo Treat all exported code with parameters as non-nullable by default.\n'
32+
' --[no-]monorepo Treat all exported code with parameters as non-nullable by default.\n'
3333
'\n'
3434
'\n'
35-
' --[no-]fatal-found Treat found unnecessary nullable parameters as fatal.\n'
36-
' (defaults to on)\n'
35+
' --[no-]fatal-found Treat found unnecessary nullable parameters as fatal.\n'
36+
' (defaults to on)\n'
3737
'\n'
3838
'Run "metrics help" to see global options.';
3939

test/src/cli/commands/check_unused_code_command_test.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@ import 'package:test/test.dart';
55
const _usage = 'Check unused code in *.dart files.\n'
66
'\n'
77
'Usage: metrics check-unused-code [arguments] <directories>\n'
8-
'-h, --help Print this usage information.\n'
8+
'-h, --help Print this usage information.\n'
99
'\n'
1010
'\n'
11-
'-r, --reporter=<console> The format of the output of the analysis.\n'
12-
' [console (default), json]\n'
11+
'-r, --reporter=<console> The format of the output of the analysis.\n'
12+
' [console (default), json]\n'
1313
'\n'
1414
'\n'
15-
'-c, --print-config Print resolved config.\n'
15+
'-c, --print-config Print resolved config.\n'
1616
'\n'
1717
'\n'
18-
' --root-folder=<./> Root folder.\n'
19-
' (defaults to current directory)\n'
20-
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
21-
' --exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.\n'
22-
' (defaults to "{/**.g.dart,/**.template.dart}")\n'
18+
' --root-folder=<./> Root folder.\n'
19+
' (defaults to current directory)\n'
20+
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
21+
' --exclude=<{/**.g.dart,/**.freezed.dart}> File paths in Glob syntax to be exclude.\n'
22+
' (defaults to "{/**.g.dart,/**.freezed.dart}")\n'
2323
'\n'
2424
'\n'
25-
" --no-congratulate Don't show output even when there are no issues.\n"
25+
" --no-congratulate Don't show output even when there are no issues.\n"
2626
'\n'
2727
'\n'
28-
' --[no-]verbose Show verbose logs.\n'
28+
' --[no-]verbose Show verbose logs.\n'
2929
'\n'
3030
'\n'
31-
' --[no-]monorepo Treat all exported code as unused by default.\n'
31+
' --[no-]monorepo Treat all exported code as unused by default.\n'
3232
'\n'
3333
'\n'
34-
' --[no-]fatal-unused Treat find unused code as fatal.\n'
35-
' (defaults to on)\n'
34+
' --[no-]fatal-unused Treat find unused code as fatal.\n'
35+
' (defaults to on)\n'
3636
'\n'
3737
'Run "metrics help" to see global options.';
3838

test/src/cli/commands/check_unused_files_command_test.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ import 'package:test/test.dart';
55
const _usage = 'Check unused *.dart files.\n'
66
'\n'
77
'Usage: metrics check-unused-files [arguments] <directories>\n'
8-
'-h, --help Print this usage information.\n'
8+
'-h, --help Print this usage information.\n'
99
'\n'
1010
'\n'
11-
'-r, --reporter=<console> The format of the output of the analysis.\n'
12-
' [console (default), json]\n'
11+
'-r, --reporter=<console> The format of the output of the analysis.\n'
12+
' [console (default), json]\n'
1313
'\n'
1414
'\n'
15-
'-c, --print-config Print resolved config.\n'
15+
'-c, --print-config Print resolved config.\n'
1616
'\n'
1717
'\n'
18-
' --root-folder=<./> Root folder.\n'
19-
' (defaults to current directory)\n'
20-
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
21-
' --exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.\n'
22-
' (defaults to "{/**.g.dart,/**.template.dart}")\n'
18+
' --root-folder=<./> Root folder.\n'
19+
' (defaults to current directory)\n'
20+
' --sdk-path=<directory-path> Dart SDK directory path. Should be provided only when you run the application as compiled executable(https://dart.dev/tools/dart-compile#exe) and automatic Dart SDK path detection fails.\n'
21+
' --exclude=<{/**.g.dart,/**.freezed.dart}> File paths in Glob syntax to be exclude.\n'
22+
' (defaults to "{/**.g.dart,/**.freezed.dart}")\n'
2323
'\n'
2424
'\n'
25-
" --no-congratulate Don't show output even when there are no issues.\n"
25+
" --no-congratulate Don't show output even when there are no issues.\n"
2626
'\n'
2727
'\n'
28-
' --[no-]verbose Show verbose logs.\n'
28+
' --[no-]verbose Show verbose logs.\n'
2929
'\n'
3030
'\n'
31-
' --[no-]monorepo Treat all exported files as unused by default.\n'
31+
' --[no-]monorepo Treat all exported files as unused by default.\n'
3232
'\n'
3333
'\n'
34-
' --[no-]fatal-unused Treat find unused file as fatal.\n'
35-
' (defaults to on)\n'
34+
' --[no-]fatal-unused Treat find unused file as fatal.\n'
35+
' (defaults to on)\n'
3636
'\n'
3737
'\n'
38-
'-d, --[no-]delete-files Delete all unused files.\n'
38+
'-d, --[no-]delete-files Delete all unused files.\n'
3939
'\n'
4040
'Run "metrics help" to see global options.';
4141

0 commit comments

Comments
 (0)