@@ -5,14 +5,15 @@ import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
5
5
import 'package:analyzer/dart/analysis/results.dart' ;
6
6
import 'package:analyzer/dart/ast/ast.dart' ;
7
7
import 'package:analyzer/file_system/physical_file_system.dart' ;
8
- import 'package:file/local.dart' ;
9
- import 'package:glob/glob.dart' ;
10
8
import 'package:path/path.dart' ;
11
9
12
- import '../../config_builder/models/config.dart' ;
10
+ import '../../config_builder/config_builder.dart' ;
11
+ import '../../config_builder/models/analysis_options.dart' ;
13
12
import '../../reporters/models/reporter.dart' ;
14
13
import '../../utils/exclude_utils.dart' ;
14
+ import '../../utils/file_utils.dart' ;
15
15
import '../../utils/node_utils.dart' ;
16
+ import 'lint_analysis_config.dart' ;
16
17
import 'lint_config.dart' ;
17
18
import 'metrics/halstead_volume_ast_visitor.dart' ;
18
19
import 'metrics/metric_utils.dart' ;
@@ -38,7 +39,7 @@ class LintAnalyzer {
38
39
const LintAnalyzer ();
39
40
40
41
Reporter ? getReporter ({
41
- required Config config,
42
+ required LintConfig config,
42
43
required String name,
43
44
required IOSink output,
44
45
required String reportFolder,
@@ -52,7 +53,7 @@ class LintAnalyzer {
52
53
53
54
LintFileReport ? runPluginAnalysis (
54
55
ResolvedUnitResult result,
55
- LintConfig config,
56
+ LintAnalysisConfig config,
56
57
String rootFolder,
57
58
) {
58
59
if (! isExcluded (result.path, config.globalExcludes)) {
@@ -78,24 +79,23 @@ class LintAnalyzer {
78
79
resourceProvider: PhysicalResourceProvider .INSTANCE ,
79
80
);
80
81
81
- final filePaths = folders
82
- .expand ((directory) => Glob ('$directory /**.dart' )
83
- .listFileSystemSync (
84
- const LocalFileSystem (),
85
- root: rootFolder,
86
- followLinks: false ,
87
- )
88
- .whereType <File >()
89
- .where ((entity) => ! isExcluded (
90
- relative (entity.path, from: rootFolder),
91
- config.globalExcludes,
92
- ))
93
- .map ((entity) => entity.path))
94
- .toSet ();
95
-
96
82
final analyzerResult = < LintFileReport > [];
97
83
98
84
for (final context in collection.contexts) {
85
+ final analysisOptions = await analysisOptionsFromContext (context) ??
86
+ await analysisOptionsFromFilePath (rootFolder);
87
+
88
+ final contextConfig =
89
+ ConfigBuilder .getLintConfigFromOptions (analysisOptions).merge (config);
90
+ final lintAnalysisConfig =
91
+ ConfigBuilder .getLintAnalysisConfig (contextConfig, rootFolder);
92
+
93
+ final filePaths = extractDartFilesFromFolders (
94
+ folders,
95
+ rootFolder,
96
+ lintAnalysisConfig.globalExcludes,
97
+ );
98
+
99
99
final analyzedFiles =
100
100
filePaths.intersection (context.contextRoot.analyzedFiles ().toSet ());
101
101
@@ -104,7 +104,7 @@ class LintAnalyzer {
104
104
if (unit is ResolvedUnitResult ) {
105
105
final result = _runAnalysisForFile (
106
106
unit,
107
- config ,
107
+ lintAnalysisConfig ,
108
108
rootFolder,
109
109
filePath: filePath,
110
110
);
@@ -121,7 +121,7 @@ class LintAnalyzer {
121
121
122
122
LintFileReport ? _runAnalysisForFile (
123
123
ResolvedUnitResult result,
124
- LintConfig config,
124
+ LintAnalysisConfig config,
125
125
String rootFolder, {
126
126
String ? filePath,
127
127
}) {
@@ -215,7 +215,7 @@ class LintAnalyzer {
215
215
Iterable <Issue > _checkOnCodeIssues (
216
216
Suppression ignores,
217
217
InternalResolvedUnitResult source,
218
- LintConfig config,
218
+ LintAnalysisConfig config,
219
219
String filePath,
220
220
String ? rootFolder,
221
221
) =>
@@ -240,7 +240,7 @@ class LintAnalyzer {
240
240
Suppression ignores,
241
241
InternalResolvedUnitResult source,
242
242
Iterable <ScopedFunctionDeclaration > functions,
243
- LintConfig config,
243
+ LintAnalysisConfig config,
244
244
) =>
245
245
config.antiPatterns
246
246
.where ((pattern) => ! ignores.isSuppressed (pattern.id))
@@ -255,7 +255,7 @@ class LintAnalyzer {
255
255
Map <ScopedClassDeclaration , Report > _checkClassMetrics (
256
256
ScopeVisitor visitor,
257
257
InternalResolvedUnitResult source,
258
- LintConfig config,
258
+ LintAnalysisConfig config,
259
259
) {
260
260
final classRecords = < ScopedClassDeclaration , Report > {};
261
261
@@ -292,7 +292,7 @@ class LintAnalyzer {
292
292
Map <ScopedFunctionDeclaration , Report > _checkFunctionMetrics (
293
293
ScopeVisitor visitor,
294
294
InternalResolvedUnitResult source,
295
- LintConfig config,
295
+ LintAnalysisConfig config,
296
296
) {
297
297
final functionRecords = < ScopedFunctionDeclaration , Report > {};
298
298
0 commit comments