UDA to disable linting: can now disable at module level

This commit is contained in:
Axel Ricard 2023-10-12 21:49:13 +02:00
parent 333bd45a35
commit ebed325964
3 changed files with 22 additions and 11 deletions

View file

@ -411,13 +411,17 @@ public:
*
* When overriden, make sure to keep this structure
*/
override void visit(const(ModuleDeclaration) moduleDeclaration)
override void visit(const(Module) mod)
{
auto currNoLint = NoLintFactory.fromModuleDeclaration(moduleDeclaration);
noLint.push(currNoLint);
scope(exit) noLint.pop(currNoLint);
moduleDeclaration.accept(this);
if(mod.moduleDeclaration !is null)
{
auto currNoLint = NoLintFactory.fromModuleDeclaration(mod.moduleDeclaration);
noLint.push(currNoLint);
scope(exit) noLint.pop(currNoLint);
mod.accept(this);
}
else
mod.accept(this);
}
/**

View file

@ -237,10 +237,5 @@ unittest
^^^^^^^^^^^^^^ [warn]: Function name 'WinButWithBody' does not match style guidelines. +/
}c, sac);
assertAnalyzerWarnings(q{
@("nolint(dscanner.style.phobos_naming_convention)")
module AMODULE;
}c, sac);
stderr.writeln("Unittest for StyleChecker passed.");
}

View file

@ -395,6 +395,18 @@ public:
}, sac);
// passes (disable check at module level)
assertAnalyzerWarnings(q{
@("nolint(dscanner.useless-initializer)")
module my_module;
int a = 0;
int f() {
int a = 0;
}
}, sac);
stderr.writeln("Unittest for UselessInitializerChecker passed.");
}