Skip to content

Commit

Permalink
Allow skipping checks for dscanner.suspicious.unmodified with nolint
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo39 committed May 5, 2024
1 parent 433d1eb commit 26f8141
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/dscanner/analysis/unmodified.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -189,6 +194,8 @@ final class UnmodifiedFinder : BaseAnalyzer

private:

enum string key = "dscanner.suspicious.unmodified";

template PartsMightModify(T)
{
override void visit(const T t)
Expand Down Expand Up @@ -379,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);
}

0 comments on commit 26f8141

Please sign in to comment.