Skip to content

Commit

Permalink
UDA to disable linting: can now disable at module level
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardaxel committed Oct 12, 2023
1 parent 9ce1584 commit 7456fa0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/dscanner/analysis/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions src/dscanner/analysis/style.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
12 changes: 12 additions & 0 deletions src/dscanner/analysis/useless_initializer.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

0 comments on commit 7456fa0

Please sign in to comment.