Skip to content

Commit f756a84

Browse files
committed
UDA to disable linting: can now disable at module level
1 parent 677a401 commit f756a84

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/dscanner/analysis/base.d

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,17 @@ public:
411411
*
412412
* When overriden, make sure to keep this structure
413413
*/
414-
override void visit(const(ModuleDeclaration) moduleDeclaration)
414+
override void visit(const(Module) mod)
415415
{
416-
auto currNoLint = NoLintFactory.fromModuleDeclaration(moduleDeclaration);
417-
noLint.push(currNoLint);
418-
scope(exit) noLint.pop(currNoLint);
419-
420-
moduleDeclaration.accept(this);
416+
if(mod.moduleDeclaration !is null)
417+
{
418+
auto currNoLint = NoLintFactory.fromModuleDeclaration(mod.moduleDeclaration);
419+
noLint.push(currNoLint);
420+
scope(exit) noLint.pop(currNoLint);
421+
mod.accept(this);
422+
}
423+
else
424+
mod.accept(this);
421425
}
422426

423427
/**

src/dscanner/analysis/style.d

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,5 @@ unittest
237237
^^^^^^^^^^^^^^ [warn]: Function name 'WinButWithBody' does not match style guidelines. +/
238238
}c, sac);
239239

240-
assertAnalyzerWarnings(q{
241-
@("nolint(dscanner.style.phobos_naming_convention)")
242-
module AMODULE;
243-
}c, sac);
244-
245240
stderr.writeln("Unittest for StyleChecker passed.");
246241
}

src/dscanner/analysis/useless_initializer.d

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@ public:
395395

396396
}, sac);
397397

398+
// passes (disable check at module level)
399+
assertAnalyzerWarnings(q{
400+
@("nolint(dscanner.useless-initializer)")
401+
module my_module;
402+
403+
int a = 0;
404+
405+
int f() {
406+
int a = 0;
407+
}
408+
}, sac);
409+
398410
stderr.writeln("Unittest for UselessInitializerChecker passed.");
399411
}
400412

0 commit comments

Comments
 (0)