mirror of
https://github.com/dlang-community/D-Scanner.git
synced 2025-04-27 05:40:01 +03:00
UDA to disable linting: can now disable at module level
This commit is contained in:
parent
333bd45a35
commit
ebed325964
3 changed files with 22 additions and 11 deletions
|
@ -411,13 +411,17 @@ public:
|
||||||
*
|
*
|
||||||
* When overriden, make sure to keep this structure
|
* 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);
|
if(mod.moduleDeclaration !is null)
|
||||||
noLint.push(currNoLint);
|
{
|
||||||
scope(exit) noLint.pop(currNoLint);
|
auto currNoLint = NoLintFactory.fromModuleDeclaration(mod.moduleDeclaration);
|
||||||
|
noLint.push(currNoLint);
|
||||||
moduleDeclaration.accept(this);
|
scope(exit) noLint.pop(currNoLint);
|
||||||
|
mod.accept(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mod.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -237,10 +237,5 @@ unittest
|
||||||
^^^^^^^^^^^^^^ [warn]: Function name 'WinButWithBody' does not match style guidelines. +/
|
^^^^^^^^^^^^^^ [warn]: Function name 'WinButWithBody' does not match style guidelines. +/
|
||||||
}c, sac);
|
}c, sac);
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
|
||||||
@("nolint(dscanner.style.phobos_naming_convention)")
|
|
||||||
module AMODULE;
|
|
||||||
}c, sac);
|
|
||||||
|
|
||||||
stderr.writeln("Unittest for StyleChecker passed.");
|
stderr.writeln("Unittest for StyleChecker passed.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,6 +395,18 @@ public:
|
||||||
|
|
||||||
}, sac);
|
}, 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.");
|
stderr.writeln("Unittest for UselessInitializerChecker passed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue