Allow skipping checks for dscanner.suspicious.unmodified with nolint

This commit is contained in:
Hiroki Noda 2024-05-05 21:15:22 +09:00 committed by Jan Jurzitza
parent 17f3286fef
commit 22c9f980ae
1 changed files with 14 additions and 2 deletions

View File

@ -5,6 +5,7 @@
module dscanner.analysis.unmodified; module dscanner.analysis.unmodified;
import dscanner.analysis.base; import dscanner.analysis.base;
import dscanner.analysis.nolint;
import dscanner.utils : safeAccess; import dscanner.utils : safeAccess;
import dsymbol.scope_ : Scope; import dsymbol.scope_ : Scope;
import std.container; import std.container;
@ -114,12 +115,16 @@ final class UnmodifiedFinder : BaseAnalyzer
if (canFindImmutableOrConst(dec)) if (canFindImmutableOrConst(dec))
{ {
isImmutable++; isImmutable++;
with (noLint.push(NoLintFactory.fromDeclaration(dec)))
dec.accept(this); dec.accept(this);
isImmutable--; isImmutable--;
} }
else else
{
with (noLint.push(NoLintFactory.fromDeclaration(dec)))
dec.accept(this); dec.accept(this);
} }
}
override void visit(const IdentifierChain ic) override void visit(const IdentifierChain ic)
{ {
@ -381,5 +386,12 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc
foo(i2); foo(i2);
} }
}, sac); }, sac);
assertAnalyzerWarnings(q{
@("nolint(dscanner.suspicious.unmodified)")
void foo(){
int i = 1;
}
}, sac);
} }