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

Commit 6ed4a6d

Browse files
committed
fix: disable type=lint check for other commands
1 parent 4ef9548 commit 6ed4a6d

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

lib/src/analyzers/lint_analyzer/lint_analyzer.dart

+12-6
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class LintAnalyzer {
196196
);
197197
}
198198

199+
// ignore: long-method
199200
LintFileReport? _analyzeFile(
200201
ResolvedUnitResult result,
201202
LintAnalysisConfig config,
@@ -206,7 +207,11 @@ class LintAnalyzer {
206207
return null;
207208
}
208209

209-
final ignores = Suppression(result.content, result.lineInfo);
210+
final ignores = Suppression(
211+
result.content,
212+
result.lineInfo,
213+
supportsTypeLintIgnore: true,
214+
);
210215
final internalResult = InternalResolvedUnitResult(
211216
filePath,
212217
result.content,
@@ -240,11 +245,12 @@ class LintAnalyzer {
240245
path: filePath,
241246
relativePath: relativePath,
242247
file: fileMetrics,
243-
classes: Map.unmodifiable(classMetrics
244-
.map<String, Report>((key, value) => MapEntry(key.name, value))),
245-
functions: Map.unmodifiable(functionMetrics.map<String, Report>(
246-
(key, value) => MapEntry(key.fullName, value),
247-
)),
248+
classes: Map.unmodifiable(
249+
classMetrics.map((key, value) => MapEntry(key.name, value)),
250+
),
251+
functions: Map.unmodifiable(
252+
functionMetrics.map((key, value) => MapEntry(key.fullName, value)),
253+
),
248254
issues: issues,
249255
antiPatternCases: antiPatterns,
250256
);

lib/src/utils/suppression.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ class Suppression {
2626
(_ignoreMap[lineIndex]?.contains(_canonicalize(id)) ?? false);
2727

2828
/// Initialize a newly created [Suppression] with the given [content] and [lineInfo].
29-
Suppression(String content, this.lineInfo) {
29+
Suppression(
30+
String content,
31+
this.lineInfo, {
32+
bool supportsTypeLintIgnore = false,
33+
}) {
3034
for (final match in _ignoreMatchers.allMatches(content)) {
3135
final ids = match.group(1)!.split(',').map(_canonicalize);
3236
final location = lineInfo.getLocation(match.start);
@@ -47,7 +51,7 @@ class Suppression {
4751

4852
for (final match in _ignoreForFileMatcher.allMatches(content)) {
4953
final suppressed = match.group(1)!.split(',').map(_canonicalize);
50-
if (suppressed.contains(_typeLint)) {
54+
if (supportsTypeLintIgnore && suppressed.contains(_typeLint)) {
5155
_hasAllLintsSuppressed = true;
5256
} else {
5357
_ignoreForFileSet.addAll(suppressed);

test/src/analyzers/lint_analyzer/models/suppression_test.dart

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ void main() {
1010
test('suppression in content', () async {
1111
final parseResult = await FileResolver.resolve(_examplePath);
1212

13-
final suppression = Suppression(parseResult.content, parseResult.lineInfo);
13+
final suppression = Suppression(
14+
parseResult.content,
15+
parseResult.lineInfo,
16+
supportsTypeLintIgnore: true,
17+
);
1418

1519
expect(suppression.isSuppressed('rule_id1'), isTrue);
1620
expect(suppression.isSuppressed('rule_id2'), isTrue);
@@ -28,7 +32,11 @@ void main() {
2832
test('suppression with type=lint', () async {
2933
final parseResult = await FileResolver.resolve(_exampleAllPath);
3034

31-
final suppression = Suppression(parseResult.content, parseResult.lineInfo);
35+
final suppression = Suppression(
36+
parseResult.content,
37+
parseResult.lineInfo,
38+
supportsTypeLintIgnore: true,
39+
);
3240

3341
expect(suppression.isSuppressed('rule_id1'), isTrue);
3442
expect(suppression.isSuppressed('rule_id2'), isTrue);

0 commit comments

Comments
 (0)