From 22c9f980aecd84a98e4398139ca22ae220b641f1 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Sun, 5 May 2024 21:15:22 +0900 Subject: [PATCH] Allow skipping checks for dscanner.suspicious.unmodified with nolint --- src/dscanner/analysis/unmodified.d | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/dscanner/analysis/unmodified.d b/src/dscanner/analysis/unmodified.d index b6051cd..6dd3d8c 100644 --- a/src/dscanner/analysis/unmodified.d +++ b/src/dscanner/analysis/unmodified.d @@ -5,6 +5,7 @@ module dscanner.analysis.unmodified; import dscanner.analysis.base; +import dscanner.analysis.nolint; import dscanner.utils : safeAccess; import dsymbol.scope_ : Scope; import std.container; @@ -114,11 +115,15 @@ final class UnmodifiedFinder : BaseAnalyzer if (canFindImmutableOrConst(dec)) { isImmutable++; - dec.accept(this); + with (noLint.push(NoLintFactory.fromDeclaration(dec))) + dec.accept(this); isImmutable--; } else - dec.accept(this); + { + with (noLint.push(NoLintFactory.fromDeclaration(dec))) + dec.accept(this); + } } override void visit(const IdentifierChain ic) @@ -381,5 +386,12 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc foo(i2); } }, sac); + + assertAnalyzerWarnings(q{ + @("nolint(dscanner.suspicious.unmodified)") + void foo(){ + int i = 1; + } + }, sac); }