Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: simplify diagnostic reporting logic by using a nullable arg…
…ument instead of a list
  • Loading branch information
Illia Aihistov
Illia Aihistov committed Aug 27, 2026
commit 57865ff88f2843890f671462adf7388530662c7f
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,19 @@ class AvoidDuplicateCodeReporter {
.map((p) => p.exactHash)
.contains(currentExactHash);

final (diagnosticCode, arguments) = switch (hasExactPartner) {
true => (_rule.exactCode, const <String>[]),
false => (
_rule.differentLiteralsCode,
[
_computeLiteralsSummary(
currentLiterals: target.collectLiterals(_literalsAnalyzer),
partnerLiterals: [
for (final p in internalPartners)
p.collectLiterals(_literalsAnalyzer),
..._loadExternalLiterals(externalPartners),
],
),
],
),
};
final (diagnosticCode, argument) = hasExactPartner
? (_rule.exactCode, null)
: (
_rule.differentLiteralsCode,
_computeLiteralsSummary(
currentLiterals: target.collectLiterals(_literalsAnalyzer),
partnerLiterals: [
for (final p in internalPartners)
p.collectLiterals(_literalsAnalyzer),
..._loadExternalLiterals(externalPartners),
],
),
);

final contextMessages = _buildContextMessages(
currentFilePath: filePath,
Expand All @@ -108,7 +105,7 @@ class AvoidDuplicateCodeReporter {
target.report(
_rule,
diagnosticCode: diagnosticCode,
arguments: arguments,
arguments: [?argument],
contextMessages: contextMessages,
);
}
Expand Down