add BaseAnalyzerArguments to keep ctor changes sane

also immediately makes tokens a part of it

This struct can for example precompute token indices for line endings
This commit is contained in:
WebFreak001 2023-10-25 07:30:11 +02:00 committed by Jan Jurzitza
parent 1e8f1ec9e6
commit 42033dcc55
57 changed files with 268 additions and 240 deletions

View File

@ -18,9 +18,9 @@ final class AliasSyntaxCheck : BaseAnalyzer
mixin AnalyzerInfo!"alias_syntax_check"; mixin AnalyzerInfo!"alias_syntax_check";
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const AliasDeclaration ad) override void visit(const AliasDeclaration ad)

View File

@ -30,9 +30,9 @@ final class AllManCheck : BaseAnalyzer
mixin AnalyzerInfo!"allman_braces_check"; mixin AnalyzerInfo!"allman_braces_check";
/// ///
this(string fileName, const(Token)[] tokens, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
foreach (i; 1 .. tokens.length - 1) foreach (i; 1 .. tokens.length - 1)
{ {
const curLine = tokens[i].line; const curLine = tokens[i].line;

View File

@ -21,9 +21,9 @@ final class AlwaysCurlyCheck : BaseAnalyzer
alias visit = BaseAnalyzer.visit; alias visit = BaseAnalyzer.visit;
/// ///
this(string fileName, const(Token)[] tokens, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
void test(L, B)(L loc, B s, string stmtKind) void test(L, B)(L loc, B s, string stmtKind)

View File

@ -22,9 +22,9 @@ final class AsmStyleCheck : BaseAnalyzer
mixin AnalyzerInfo!"asm_style_check"; mixin AnalyzerInfo!"asm_style_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const AsmBrExp brExp) override void visit(const AsmBrExp brExp)

View File

@ -23,9 +23,9 @@ final class AssertWithoutMessageCheck : BaseAnalyzer
mixin AnalyzerInfo!"assert_without_msg"; mixin AnalyzerInfo!"assert_without_msg";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const AssertExpression expr) override void visit(const AssertExpression expr)

View File

@ -40,9 +40,9 @@ public:
mixin AnalyzerInfo!"auto_function_check"; mixin AnalyzerInfo!"auto_function_check";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
package static const(Token)[] findAutoReturnType(const(FunctionDeclaration) decl) package static const(Token)[] findAutoReturnType(const(FunctionDeclaration) decl)

View File

@ -17,9 +17,9 @@ final class AutoRefAssignmentCheck : BaseAnalyzer
mixin AnalyzerInfo!"auto_ref_assignment_check"; mixin AnalyzerInfo!"auto_ref_assignment_check";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const Module m) override void visit(const Module m)

View File

@ -371,14 +371,41 @@ mixin template AnalyzerInfo(string checkName)
} }
} }
struct BaseAnalyzerArguments
{
string fileName;
const(Token)[] tokens;
const Scope* sc;
bool skipTests = false;
BaseAnalyzerArguments setSkipTests(bool v)
{
auto ret = this;
ret.skipTests = v;
return ret;
}
}
abstract class BaseAnalyzer : ASTVisitor abstract class BaseAnalyzer : ASTVisitor
{ {
public: public:
deprecated("Don't use this constructor, use the one taking BaseAnalyzerArguments")
this(string fileName, const Scope* sc, bool skipTests = false) this(string fileName, const Scope* sc, bool skipTests = false)
{ {
this.sc = sc; BaseAnalyzerArguments args = {
this.fileName = fileName; fileName: fileName,
this.skipTests = skipTests; sc: sc,
skipTests: skipTests
};
this(args);
}
this(BaseAnalyzerArguments args)
{
this.sc = args.sc;
this.tokens = args.tokens;
this.fileName = args.fileName;
this.skipTests = args.skipTests;
_messages = new MessageSet; _messages = new MessageSet;
} }
@ -453,6 +480,7 @@ protected:
bool inAggregate; bool inAggregate;
bool skipTests; bool skipTests;
const(Token)[] tokens;
NoLint noLint; NoLint noLint;
template visitTemplate(T) template visitTemplate(T)
@ -550,9 +578,9 @@ const(Token)[] findTokenForDisplay(const Token[] tokens, IdType type, const(Toke
abstract class ScopedBaseAnalyzer : BaseAnalyzer abstract class ScopedBaseAnalyzer : BaseAnalyzer
{ {
public: public:
this(string fileName, const Scope* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
@ -698,7 +726,7 @@ unittest
{ {
this(size_t codeLine) this(size_t codeLine)
{ {
super("stdin", null, false); super(BaseAnalyzerArguments("stdin"));
this.codeLine = codeLine; this.codeLine = codeLine;
} }

View File

@ -12,9 +12,9 @@ final class BodyOnDisabledFuncsCheck : BaseAnalyzer
mixin AnalyzerInfo!"body_on_disabled_func_check"; mixin AnalyzerInfo!"body_on_disabled_func_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
static foreach (AggregateType; AliasSeq!(InterfaceDeclaration, ClassDeclaration, static foreach (AggregateType; AliasSeq!(InterfaceDeclaration, ClassDeclaration,

View File

@ -33,9 +33,9 @@ final class BuiltinPropertyNameCheck : BaseAnalyzer
mixin AnalyzerInfo!"builtin_property_names_check"; mixin AnalyzerInfo!"builtin_property_names_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const FunctionDeclaration fd) override void visit(const FunctionDeclaration fd)

View File

@ -19,9 +19,9 @@ final class CommaExpressionCheck : BaseAnalyzer
mixin AnalyzerInfo!"comma_expression_check"; mixin AnalyzerInfo!"comma_expression_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Expression ex) override void visit(const Expression ex)

View File

@ -14,9 +14,9 @@ final class ConstructorCheck : BaseAnalyzer
mixin AnalyzerInfo!"constructor_check"; mixin AnalyzerInfo!"constructor_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const ClassDeclaration classDeclaration) override void visit(const ClassDeclaration classDeclaration)

View File

@ -53,10 +53,9 @@ final class CyclomaticComplexityCheck : BaseAnalyzer
int maxCyclomaticComplexity; int maxCyclomaticComplexity;
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false, this(BaseAnalyzerArguments args, int maxCyclomaticComplexity = 50)
int maxCyclomaticComplexity = 50)
{ {
super(fileName, sc, skipTests); super(args);
this.maxCyclomaticComplexity = maxCyclomaticComplexity; this.maxCyclomaticComplexity = maxCyclomaticComplexity;
} }

View File

@ -20,9 +20,9 @@ final class DeleteCheck : BaseAnalyzer
mixin AnalyzerInfo!"delete_check"; mixin AnalyzerInfo!"delete_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const DeleteExpression d) override void visit(const DeleteExpression d)

View File

@ -23,9 +23,9 @@ final class DuplicateAttributeCheck : BaseAnalyzer
mixin AnalyzerInfo!"duplicate_attribute"; mixin AnalyzerInfo!"duplicate_attribute";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Declaration node) override void visit(const Declaration node)

View File

@ -21,9 +21,9 @@ final class EnumArrayLiteralCheck : BaseAnalyzer
mixin AnalyzerInfo!"enum_array_literal_check"; mixin AnalyzerInfo!"enum_array_literal_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
bool looking; bool looking;

View File

@ -20,9 +20,9 @@ final class ExplicitlyAnnotatedUnittestCheck : BaseAnalyzer
mixin AnalyzerInfo!"explicitly_annotated_unittests"; mixin AnalyzerInfo!"explicitly_annotated_unittests";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const Declaration decl) override void visit(const Declaration decl)

View File

@ -74,9 +74,9 @@ public:
}; };
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const(StructDeclaration) sd) override void visit(const(StructDeclaration) sd)

View File

@ -22,9 +22,9 @@ final class FloatOperatorCheck : BaseAnalyzer
enum string KEY = "dscanner.deprecated.floating_point_operators"; enum string KEY = "dscanner.deprecated.floating_point_operators";
mixin AnalyzerInfo!"float_operator_check"; mixin AnalyzerInfo!"float_operator_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const RelExpression r) override void visit(const RelExpression r)

View File

@ -28,9 +28,9 @@ final class FunctionAttributeCheck : BaseAnalyzer
mixin AnalyzerInfo!"function_attribute_check"; mixin AnalyzerInfo!"function_attribute_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const InterfaceDeclaration dec) override void visit(const InterfaceDeclaration dec)

View File

@ -22,9 +22,9 @@ final class HasPublicExampleCheck : BaseAnalyzer
mixin AnalyzerInfo!"has_public_example"; mixin AnalyzerInfo!"has_public_example";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Module mod) override void visit(const Module mod)

View File

@ -20,9 +20,9 @@ final class IfConstraintsIndentCheck : BaseAnalyzer
mixin AnalyzerInfo!"if_constraints_indent"; mixin AnalyzerInfo!"if_constraints_indent";
/// ///
this(string fileName, const(Token)[] tokens, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
// convert tokens to a list of token starting positions per line // convert tokens to a list of token starting positions per line

View File

@ -16,9 +16,9 @@ final class IfStatementCheck : BaseAnalyzer
alias visit = BaseAnalyzer.visit; alias visit = BaseAnalyzer.visit;
mixin AnalyzerInfo!"redundant_if_check"; mixin AnalyzerInfo!"redundant_if_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const IfStatement ifStatement) override void visit(const IfStatement ifStatement)

View File

@ -26,9 +26,9 @@ final class IfElseSameCheck : BaseAnalyzer
mixin AnalyzerInfo!"if_else_same_check"; mixin AnalyzerInfo!"if_else_same_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const IfStatement ifStatement) override void visit(const IfStatement ifStatement)

View File

@ -20,9 +20,9 @@ final class ImportSortednessCheck : BaseAnalyzer
mixin AnalyzerInfo!"imports_sortedness"; mixin AnalyzerInfo!"imports_sortedness";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
mixin ScopedVisit!Module; mixin ScopedVisit!Module;

View File

@ -22,9 +22,9 @@ final class IncorrectInfiniteRangeCheck : BaseAnalyzer
mixin AnalyzerInfo!"incorrect_infinite_range_check"; mixin AnalyzerInfo!"incorrect_infinite_range_check";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const StructBody structBody) override void visit(const StructBody structBody)

View File

@ -17,9 +17,9 @@ final class LabelVarNameCheck : ScopedBaseAnalyzer
{ {
mixin AnalyzerInfo!"label_var_same_name_check"; mixin AnalyzerInfo!"label_var_same_name_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
mixin AggregateVisit!ClassDeclaration; mixin AggregateVisit!ClassDeclaration;

View File

@ -16,9 +16,9 @@ final class LambdaReturnCheck : BaseAnalyzer
mixin AnalyzerInfo!"lambda_return_check"; mixin AnalyzerInfo!"lambda_return_check";
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const FunctionLiteralExpression fLit) override void visit(const FunctionLiteralExpression fLit)

View File

@ -22,9 +22,9 @@ final class LengthSubtractionCheck : BaseAnalyzer
mixin AnalyzerInfo!"length_subtraction_check"; mixin AnalyzerInfo!"length_subtraction_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const AddExpression addExpression) override void visit(const AddExpression addExpression)

View File

@ -20,10 +20,9 @@ final class LineLengthCheck : BaseAnalyzer
mixin AnalyzerInfo!"long_line_check"; mixin AnalyzerInfo!"long_line_check";
/// ///
this(string fileName, const(Token)[] tokens, int maxLineLength, bool skipTests = false) this(BaseAnalyzerArguments args, int maxLineLength)
{ {
super(fileName, null, skipTests); super(args);
this.tokens = tokens;
this.maxLineLength = maxLineLength; this.maxLineLength = maxLineLength;
} }
@ -94,9 +93,9 @@ private:
unittest unittest
{ {
assert(new LineLengthCheck(null, null, 120).checkMultiLineToken(Token(tok!"stringLiteral", " ", 0, 0, 0)) == 8); assert(new LineLengthCheck(BaseAnalyzerArguments.init, 120).checkMultiLineToken(Token(tok!"stringLiteral", " ", 0, 0, 0)) == 8);
assert(new LineLengthCheck(null, null, 120).checkMultiLineToken(Token(tok!"stringLiteral", " \na", 0, 0, 0)) == 2); assert(new LineLengthCheck(BaseAnalyzerArguments.init, 120).checkMultiLineToken(Token(tok!"stringLiteral", " \na", 0, 0, 0)) == 2);
assert(new LineLengthCheck(null, null, 120).checkMultiLineToken(Token(tok!"stringLiteral", " \n ", 0, 0, 0)) == 5); assert(new LineLengthCheck(BaseAnalyzerArguments.init, 120).checkMultiLineToken(Token(tok!"stringLiteral", " \n ", 0, 0, 0)) == 5);
} }
static size_t tokenByteLength()(auto ref const Token tok) static size_t tokenByteLength()(auto ref const Token tok)
@ -165,7 +164,6 @@ private:
enum string KEY = "dscanner.style.long_line"; enum string KEY = "dscanner.style.long_line";
const int maxLineLength; const int maxLineLength;
const(Token)[] tokens;
} }
@system unittest @system unittest

View File

@ -25,9 +25,9 @@ final class LocalImportCheck : BaseAnalyzer
/** /**
* Construct with the given file name. * Construct with the given file name.
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
mixin visitThing!StructBody; mixin visitThing!StructBody;

View File

@ -26,9 +26,9 @@ final class LogicPrecedenceCheck : BaseAnalyzer
enum string KEY = "dscanner.confusing.logical_precedence"; enum string KEY = "dscanner.confusing.logical_precedence";
mixin AnalyzerInfo!"logical_precedence_check"; mixin AnalyzerInfo!"logical_precedence_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const OrOrExpression orOr) override void visit(const OrOrExpression orOr)

View File

@ -14,9 +14,9 @@ final class MismatchedArgumentCheck : BaseAnalyzer
mixin AnalyzerInfo!"mismatched_args_check"; mixin AnalyzerInfo!"mismatched_args_check";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const FunctionCallExpression fce) override void visit(const FunctionCallExpression fce)

View File

@ -26,9 +26,9 @@ public:
/** /**
* Constructs the style checker with the given file name. * Constructs the style checker with the given file name.
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Token t) override void visit(const Token t)

View File

@ -24,9 +24,9 @@ final class ObjectConstCheck : BaseAnalyzer
mixin AnalyzerInfo!"object_const_check"; mixin AnalyzerInfo!"object_const_check";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
mixin visitTemplate!ClassDeclaration; mixin visitTemplate!ClassDeclaration;

View File

@ -23,9 +23,9 @@ final class OpEqualsWithoutToHashCheck : BaseAnalyzer
mixin AnalyzerInfo!"opequals_tohash_check"; mixin AnalyzerInfo!"opequals_tohash_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const ClassDeclaration node) override void visit(const ClassDeclaration node)

View File

@ -31,9 +31,9 @@ final class PokemonExceptionCheck : BaseAnalyzer
alias visit = BaseAnalyzer.visit; alias visit = BaseAnalyzer.visit;
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const LastCatch lc) override void visit(const LastCatch lc)

View File

@ -41,9 +41,9 @@ final class ProperlyDocumentedPublicFunctions : BaseAnalyzer
mixin AnalyzerInfo!"properly_documented_public_functions"; mixin AnalyzerInfo!"properly_documented_public_functions";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const Module mod) override void visit(const Module mod)

View File

@ -29,9 +29,9 @@ final class BackwardsRangeCheck : BaseAnalyzer
* Params: * Params:
* fileName = the name of the file being analyzed * fileName = the name of the file being analyzed
*/ */
this(string fileName, const Scope* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const ForeachStatement foreachStatement) override void visit(const ForeachStatement foreachStatement)

View File

@ -21,9 +21,9 @@ final class RedundantAttributesCheck : ScopedBaseAnalyzer
{ {
mixin AnalyzerInfo!"redundant_attributes_check"; mixin AnalyzerInfo!"redundant_attributes_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
stack.length = 0; stack.length = 0;
} }

View File

@ -20,9 +20,9 @@ final class RedundantParenCheck : BaseAnalyzer
mixin AnalyzerInfo!"redundant_parens_check"; mixin AnalyzerInfo!"redundant_parens_check";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const IfStatement statement) override void visit(const IfStatement statement)

View File

@ -22,9 +22,9 @@ final class RedundantStorageClassCheck : BaseAnalyzer
enum string REDUNDANT_VARIABLE_ATTRIBUTES = "Variable declaration for `%s` has redundant attributes (%-(`%s`%|, %))."; enum string REDUNDANT_VARIABLE_ATTRIBUTES = "Variable declaration for `%s` has redundant attributes (%-(`%s`%|, %)).";
mixin AnalyzerInfo!"redundant_storage_classes"; mixin AnalyzerInfo!"redundant_storage_classes";
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const Declaration node) override void visit(const Declaration node)

View File

@ -307,7 +307,7 @@ void generateReport(string[] fileNames, const StaticAnalysisConfig config,
}; };
first = true; first = true;
StatsCollector stats = new StatsCollector(""); StatsCollector stats = new StatsCollector(BaseAnalyzerArguments.init);
ulong lineOfCodeCount; ulong lineOfCodeCount;
foreach (fileName; fileNames) foreach (fileName; fileNames)
{ {
@ -749,220 +749,226 @@ private BaseAnalyzer[] getAnalyzersForModuleAndConfig(string fileName,
m.moduleDeclaration.moduleName.identifiers !is null) m.moduleDeclaration.moduleName.identifiers !is null)
moduleName = m.moduleDeclaration.moduleName.identifiers.map!(e => e.text).join("."); moduleName = m.moduleDeclaration.moduleName.identifiers.map!(e => e.text).join(".");
BaseAnalyzerArguments args = BaseAnalyzerArguments(
fileName: fileName,
tokens: tokens,
sc: moduleScope
);
if (moduleName.shouldRun!AsmStyleCheck(analysisConfig)) if (moduleName.shouldRun!AsmStyleCheck(analysisConfig))
checks ~= new AsmStyleCheck(fileName, moduleScope, checks ~= new AsmStyleCheck(args.setSkipTests(
analysisConfig.asm_style_check == Check.skipTests && !ut); analysisConfig.asm_style_check == Check.skipTests && !ut));
if (moduleName.shouldRun!BackwardsRangeCheck(analysisConfig)) if (moduleName.shouldRun!BackwardsRangeCheck(analysisConfig))
checks ~= new BackwardsRangeCheck(fileName, moduleScope, checks ~= new BackwardsRangeCheck(args.setSkipTests(
analysisConfig.backwards_range_check == Check.skipTests && !ut); analysisConfig.backwards_range_check == Check.skipTests && !ut));
if (moduleName.shouldRun!BuiltinPropertyNameCheck(analysisConfig)) if (moduleName.shouldRun!BuiltinPropertyNameCheck(analysisConfig))
checks ~= new BuiltinPropertyNameCheck(fileName, moduleScope, checks ~= new BuiltinPropertyNameCheck(args.setSkipTests(
analysisConfig.builtin_property_names_check == Check.skipTests && !ut); analysisConfig.builtin_property_names_check == Check.skipTests && !ut));
if (moduleName.shouldRun!CommaExpressionCheck(analysisConfig)) if (moduleName.shouldRun!CommaExpressionCheck(analysisConfig))
checks ~= new CommaExpressionCheck(fileName, moduleScope, checks ~= new CommaExpressionCheck(args.setSkipTests(
analysisConfig.comma_expression_check == Check.skipTests && !ut); analysisConfig.comma_expression_check == Check.skipTests && !ut));
if (moduleName.shouldRun!ConstructorCheck(analysisConfig)) if (moduleName.shouldRun!ConstructorCheck(analysisConfig))
checks ~= new ConstructorCheck(fileName, moduleScope, checks ~= new ConstructorCheck(args.setSkipTests(
analysisConfig.constructor_check == Check.skipTests && !ut); analysisConfig.constructor_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UnmodifiedFinder(analysisConfig)) if (moduleName.shouldRun!UnmodifiedFinder(analysisConfig))
checks ~= new UnmodifiedFinder(fileName, moduleScope, checks ~= new UnmodifiedFinder(args.setSkipTests(
analysisConfig.could_be_immutable_check == Check.skipTests && !ut); analysisConfig.could_be_immutable_check == Check.skipTests && !ut));
if (moduleName.shouldRun!DeleteCheck(analysisConfig)) if (moduleName.shouldRun!DeleteCheck(analysisConfig))
checks ~= new DeleteCheck(fileName, moduleScope, checks ~= new DeleteCheck(args.setSkipTests(
analysisConfig.delete_check == Check.skipTests && !ut); analysisConfig.delete_check == Check.skipTests && !ut));
if (moduleName.shouldRun!DuplicateAttributeCheck(analysisConfig)) if (moduleName.shouldRun!DuplicateAttributeCheck(analysisConfig))
checks ~= new DuplicateAttributeCheck(fileName, moduleScope, checks ~= new DuplicateAttributeCheck(args.setSkipTests(
analysisConfig.duplicate_attribute == Check.skipTests && !ut); analysisConfig.duplicate_attribute == Check.skipTests && !ut));
if (moduleName.shouldRun!EnumArrayLiteralCheck(analysisConfig)) if (moduleName.shouldRun!EnumArrayLiteralCheck(analysisConfig))
checks ~= new EnumArrayLiteralCheck(fileName, moduleScope, checks ~= new EnumArrayLiteralCheck(args.setSkipTests(
analysisConfig.enum_array_literal_check == Check.skipTests && !ut); analysisConfig.enum_array_literal_check == Check.skipTests && !ut));
if (moduleName.shouldRun!PokemonExceptionCheck(analysisConfig)) if (moduleName.shouldRun!PokemonExceptionCheck(analysisConfig))
checks ~= new PokemonExceptionCheck(fileName, moduleScope, checks ~= new PokemonExceptionCheck(args.setSkipTests(
analysisConfig.exception_check == Check.skipTests && !ut); analysisConfig.exception_check == Check.skipTests && !ut));
if (moduleName.shouldRun!FloatOperatorCheck(analysisConfig)) if (moduleName.shouldRun!FloatOperatorCheck(analysisConfig))
checks ~= new FloatOperatorCheck(fileName, moduleScope, checks ~= new FloatOperatorCheck(args.setSkipTests(
analysisConfig.float_operator_check == Check.skipTests && !ut); analysisConfig.float_operator_check == Check.skipTests && !ut));
if (moduleName.shouldRun!FunctionAttributeCheck(analysisConfig)) if (moduleName.shouldRun!FunctionAttributeCheck(analysisConfig))
checks ~= new FunctionAttributeCheck(fileName, moduleScope, checks ~= new FunctionAttributeCheck(args.setSkipTests(
analysisConfig.function_attribute_check == Check.skipTests && !ut); analysisConfig.function_attribute_check == Check.skipTests && !ut));
if (moduleName.shouldRun!IfElseSameCheck(analysisConfig)) if (moduleName.shouldRun!IfElseSameCheck(analysisConfig))
checks ~= new IfElseSameCheck(fileName, moduleScope, checks ~= new IfElseSameCheck(args.setSkipTests(
analysisConfig.if_else_same_check == Check.skipTests&& !ut); analysisConfig.if_else_same_check == Check.skipTests&& !ut));
if (moduleName.shouldRun!LabelVarNameCheck(analysisConfig)) if (moduleName.shouldRun!LabelVarNameCheck(analysisConfig))
checks ~= new LabelVarNameCheck(fileName, moduleScope, checks ~= new LabelVarNameCheck(args.setSkipTests(
analysisConfig.label_var_same_name_check == Check.skipTests && !ut); analysisConfig.label_var_same_name_check == Check.skipTests && !ut));
if (moduleName.shouldRun!LengthSubtractionCheck(analysisConfig)) if (moduleName.shouldRun!LengthSubtractionCheck(analysisConfig))
checks ~= new LengthSubtractionCheck(fileName, moduleScope, checks ~= new LengthSubtractionCheck(args.setSkipTests(
analysisConfig.length_subtraction_check == Check.skipTests && !ut); analysisConfig.length_subtraction_check == Check.skipTests && !ut));
if (moduleName.shouldRun!LocalImportCheck(analysisConfig)) if (moduleName.shouldRun!LocalImportCheck(analysisConfig))
checks ~= new LocalImportCheck(fileName, moduleScope, checks ~= new LocalImportCheck(args.setSkipTests(
analysisConfig.local_import_check == Check.skipTests && !ut); analysisConfig.local_import_check == Check.skipTests && !ut));
if (moduleName.shouldRun!LogicPrecedenceCheck(analysisConfig)) if (moduleName.shouldRun!LogicPrecedenceCheck(analysisConfig))
checks ~= new LogicPrecedenceCheck(fileName, moduleScope, checks ~= new LogicPrecedenceCheck(args.setSkipTests(
analysisConfig.logical_precedence_check == Check.skipTests && !ut); analysisConfig.logical_precedence_check == Check.skipTests && !ut));
if (moduleName.shouldRun!MismatchedArgumentCheck(analysisConfig)) if (moduleName.shouldRun!MismatchedArgumentCheck(analysisConfig))
checks ~= new MismatchedArgumentCheck(fileName, moduleScope, checks ~= new MismatchedArgumentCheck(args.setSkipTests(
analysisConfig.mismatched_args_check == Check.skipTests && !ut); analysisConfig.mismatched_args_check == Check.skipTests && !ut));
if (moduleName.shouldRun!NumberStyleCheck(analysisConfig)) if (moduleName.shouldRun!NumberStyleCheck(analysisConfig))
checks ~= new NumberStyleCheck(fileName, moduleScope, checks ~= new NumberStyleCheck(args.setSkipTests(
analysisConfig.number_style_check == Check.skipTests && !ut); analysisConfig.number_style_check == Check.skipTests && !ut));
if (moduleName.shouldRun!ObjectConstCheck(analysisConfig)) if (moduleName.shouldRun!ObjectConstCheck(analysisConfig))
checks ~= new ObjectConstCheck(fileName, moduleScope, checks ~= new ObjectConstCheck(args.setSkipTests(
analysisConfig.object_const_check == Check.skipTests && !ut); analysisConfig.object_const_check == Check.skipTests && !ut));
if (moduleName.shouldRun!OpEqualsWithoutToHashCheck(analysisConfig)) if (moduleName.shouldRun!OpEqualsWithoutToHashCheck(analysisConfig))
checks ~= new OpEqualsWithoutToHashCheck(fileName, moduleScope, checks ~= new OpEqualsWithoutToHashCheck(args.setSkipTests(
analysisConfig.opequals_tohash_check == Check.skipTests && !ut); analysisConfig.opequals_tohash_check == Check.skipTests && !ut));
if (moduleName.shouldRun!RedundantParenCheck(analysisConfig)) if (moduleName.shouldRun!RedundantParenCheck(analysisConfig))
checks ~= new RedundantParenCheck(fileName, moduleScope, checks ~= new RedundantParenCheck(args.setSkipTests(
analysisConfig.redundant_parens_check == Check.skipTests && !ut); analysisConfig.redundant_parens_check == Check.skipTests && !ut));
if (moduleName.shouldRun!StyleChecker(analysisConfig)) if (moduleName.shouldRun!StyleChecker(analysisConfig))
checks ~= new StyleChecker(fileName, moduleScope, checks ~= new StyleChecker(args.setSkipTests(
analysisConfig.style_check == Check.skipTests && !ut); analysisConfig.style_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UndocumentedDeclarationCheck(analysisConfig)) if (moduleName.shouldRun!UndocumentedDeclarationCheck(analysisConfig))
checks ~= new UndocumentedDeclarationCheck(fileName, moduleScope, checks ~= new UndocumentedDeclarationCheck(args.setSkipTests(
analysisConfig.undocumented_declaration_check == Check.skipTests && !ut); analysisConfig.undocumented_declaration_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UnusedLabelCheck(analysisConfig)) if (moduleName.shouldRun!UnusedLabelCheck(analysisConfig))
checks ~= new UnusedLabelCheck(fileName, moduleScope, checks ~= new UnusedLabelCheck(args.setSkipTests(
analysisConfig.unused_label_check == Check.skipTests && !ut); analysisConfig.unused_label_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UnusedVariableCheck(analysisConfig)) if (moduleName.shouldRun!UnusedVariableCheck(analysisConfig))
checks ~= new UnusedVariableCheck(fileName, moduleScope, checks ~= new UnusedVariableCheck(args.setSkipTests(
analysisConfig.unused_variable_check == Check.skipTests && !ut); analysisConfig.unused_variable_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UnusedParameterCheck(analysisConfig)) if (moduleName.shouldRun!UnusedParameterCheck(analysisConfig))
checks ~= new UnusedParameterCheck(fileName, moduleScope, checks ~= new UnusedParameterCheck(args.setSkipTests(
analysisConfig.unused_parameter_check == Check.skipTests && !ut); analysisConfig.unused_parameter_check == Check.skipTests && !ut));
if (moduleName.shouldRun!LineLengthCheck(analysisConfig)) if (moduleName.shouldRun!LineLengthCheck(analysisConfig))
checks ~= new LineLengthCheck(fileName, tokens, checks ~= new LineLengthCheck(args.setSkipTests(
analysisConfig.max_line_length, analysisConfig.long_line_check == Check.skipTests && !ut),
analysisConfig.long_line_check == Check.skipTests && !ut); analysisConfig.max_line_length);
if (moduleName.shouldRun!AutoRefAssignmentCheck(analysisConfig)) if (moduleName.shouldRun!AutoRefAssignmentCheck(analysisConfig))
checks ~= new AutoRefAssignmentCheck(fileName, checks ~= new AutoRefAssignmentCheck(args.setSkipTests(
analysisConfig.auto_ref_assignment_check == Check.skipTests && !ut); analysisConfig.auto_ref_assignment_check == Check.skipTests && !ut));
if (moduleName.shouldRun!IncorrectInfiniteRangeCheck(analysisConfig)) if (moduleName.shouldRun!IncorrectInfiniteRangeCheck(analysisConfig))
checks ~= new IncorrectInfiniteRangeCheck(fileName, checks ~= new IncorrectInfiniteRangeCheck(args.setSkipTests(
analysisConfig.incorrect_infinite_range_check == Check.skipTests && !ut); analysisConfig.incorrect_infinite_range_check == Check.skipTests && !ut));
if (moduleName.shouldRun!UselessAssertCheck(analysisConfig)) if (moduleName.shouldRun!UselessAssertCheck(analysisConfig))
checks ~= new UselessAssertCheck(fileName, checks ~= new UselessAssertCheck(args.setSkipTests(
analysisConfig.useless_assert_check == Check.skipTests && !ut); analysisConfig.useless_assert_check == Check.skipTests && !ut));
if (moduleName.shouldRun!AliasSyntaxCheck(analysisConfig)) if (moduleName.shouldRun!AliasSyntaxCheck(analysisConfig))
checks ~= new AliasSyntaxCheck(fileName, checks ~= new AliasSyntaxCheck(args.setSkipTests(
analysisConfig.alias_syntax_check == Check.skipTests && !ut); analysisConfig.alias_syntax_check == Check.skipTests && !ut));
if (moduleName.shouldRun!StaticIfElse(analysisConfig)) if (moduleName.shouldRun!StaticIfElse(analysisConfig))
checks ~= new StaticIfElse(fileName, checks ~= new StaticIfElse(args.setSkipTests(
analysisConfig.static_if_else_check == Check.skipTests && !ut); analysisConfig.static_if_else_check == Check.skipTests && !ut));
if (moduleName.shouldRun!LambdaReturnCheck(analysisConfig)) if (moduleName.shouldRun!LambdaReturnCheck(analysisConfig))
checks ~= new LambdaReturnCheck(fileName, checks ~= new LambdaReturnCheck(args.setSkipTests(
analysisConfig.lambda_return_check == Check.skipTests && !ut); analysisConfig.lambda_return_check == Check.skipTests && !ut));
if (moduleName.shouldRun!AutoFunctionChecker(analysisConfig)) if (moduleName.shouldRun!AutoFunctionChecker(analysisConfig))
checks ~= new AutoFunctionChecker(fileName, checks ~= new AutoFunctionChecker(args.setSkipTests(
analysisConfig.auto_function_check == Check.skipTests && !ut); analysisConfig.auto_function_check == Check.skipTests && !ut));
if (moduleName.shouldRun!ImportSortednessCheck(analysisConfig)) if (moduleName.shouldRun!ImportSortednessCheck(analysisConfig))
checks ~= new ImportSortednessCheck(fileName, checks ~= new ImportSortednessCheck(args.setSkipTests(
analysisConfig.imports_sortedness == Check.skipTests && !ut); analysisConfig.imports_sortedness == Check.skipTests && !ut));
if (moduleName.shouldRun!ExplicitlyAnnotatedUnittestCheck(analysisConfig)) if (moduleName.shouldRun!ExplicitlyAnnotatedUnittestCheck(analysisConfig))
checks ~= new ExplicitlyAnnotatedUnittestCheck(fileName, checks ~= new ExplicitlyAnnotatedUnittestCheck(args.setSkipTests(
analysisConfig.explicitly_annotated_unittests == Check.skipTests && !ut); analysisConfig.explicitly_annotated_unittests == Check.skipTests && !ut));
if (moduleName.shouldRun!ProperlyDocumentedPublicFunctions(analysisConfig)) if (moduleName.shouldRun!ProperlyDocumentedPublicFunctions(analysisConfig))
checks ~= new ProperlyDocumentedPublicFunctions(fileName, checks ~= new ProperlyDocumentedPublicFunctions(args.setSkipTests(
analysisConfig.properly_documented_public_functions == Check.skipTests && !ut); analysisConfig.properly_documented_public_functions == Check.skipTests && !ut));
if (moduleName.shouldRun!FinalAttributeChecker(analysisConfig)) if (moduleName.shouldRun!FinalAttributeChecker(analysisConfig))
checks ~= new FinalAttributeChecker(fileName, checks ~= new FinalAttributeChecker(args.setSkipTests(
analysisConfig.final_attribute_check == Check.skipTests && !ut); analysisConfig.final_attribute_check == Check.skipTests && !ut));
if (moduleName.shouldRun!VcallCtorChecker(analysisConfig)) if (moduleName.shouldRun!VcallCtorChecker(analysisConfig))
checks ~= new VcallCtorChecker(fileName, checks ~= new VcallCtorChecker(args.setSkipTests(
analysisConfig.vcall_in_ctor == Check.skipTests && !ut); analysisConfig.vcall_in_ctor == Check.skipTests && !ut));
if (moduleName.shouldRun!UselessInitializerChecker(analysisConfig)) if (moduleName.shouldRun!UselessInitializerChecker(analysisConfig))
checks ~= new UselessInitializerChecker(fileName, checks ~= new UselessInitializerChecker(args.setSkipTests(
analysisConfig.useless_initializer == Check.skipTests && !ut); analysisConfig.useless_initializer == Check.skipTests && !ut));
if (moduleName.shouldRun!AllManCheck(analysisConfig)) if (moduleName.shouldRun!AllManCheck(analysisConfig))
checks ~= new AllManCheck(fileName, tokens, checks ~= new AllManCheck(args.setSkipTests(
analysisConfig.allman_braces_check == Check.skipTests && !ut); analysisConfig.allman_braces_check == Check.skipTests && !ut));
if (moduleName.shouldRun!AlwaysCurlyCheck(analysisConfig)) if (moduleName.shouldRun!AlwaysCurlyCheck(analysisConfig))
checks ~= new AlwaysCurlyCheck(fileName, tokens, checks ~= new AlwaysCurlyCheck(args.setSkipTests(
analysisConfig.always_curly_check == Check.skipTests && !ut); analysisConfig.always_curly_check == Check.skipTests && !ut));
if (moduleName.shouldRun!RedundantAttributesCheck(analysisConfig)) if (moduleName.shouldRun!RedundantAttributesCheck(analysisConfig))
checks ~= new RedundantAttributesCheck(fileName, moduleScope, checks ~= new RedundantAttributesCheck(args.setSkipTests(
analysisConfig.redundant_attributes_check == Check.skipTests && !ut); analysisConfig.redundant_attributes_check == Check.skipTests && !ut));
if (moduleName.shouldRun!HasPublicExampleCheck(analysisConfig)) if (moduleName.shouldRun!HasPublicExampleCheck(analysisConfig))
checks ~= new HasPublicExampleCheck(fileName, moduleScope, checks ~= new HasPublicExampleCheck(args.setSkipTests(
analysisConfig.has_public_example == Check.skipTests && !ut); analysisConfig.has_public_example == Check.skipTests && !ut));
if (moduleName.shouldRun!AssertWithoutMessageCheck(analysisConfig)) if (moduleName.shouldRun!AssertWithoutMessageCheck(analysisConfig))
checks ~= new AssertWithoutMessageCheck(fileName, moduleScope, checks ~= new AssertWithoutMessageCheck(args.setSkipTests(
analysisConfig.assert_without_msg == Check.skipTests && !ut); analysisConfig.assert_without_msg == Check.skipTests && !ut));
if (moduleName.shouldRun!IfConstraintsIndentCheck(analysisConfig)) if (moduleName.shouldRun!IfConstraintsIndentCheck(analysisConfig))
checks ~= new IfConstraintsIndentCheck(fileName, tokens, checks ~= new IfConstraintsIndentCheck(args.setSkipTests(
analysisConfig.if_constraints_indent == Check.skipTests && !ut); analysisConfig.if_constraints_indent == Check.skipTests && !ut));
if (moduleName.shouldRun!TrustTooMuchCheck(analysisConfig)) if (moduleName.shouldRun!TrustTooMuchCheck(analysisConfig))
checks ~= new TrustTooMuchCheck(fileName, checks ~= new TrustTooMuchCheck(args.setSkipTests(
analysisConfig.trust_too_much == Check.skipTests && !ut); analysisConfig.trust_too_much == Check.skipTests && !ut));
if (moduleName.shouldRun!RedundantStorageClassCheck(analysisConfig)) if (moduleName.shouldRun!RedundantStorageClassCheck(analysisConfig))
checks ~= new RedundantStorageClassCheck(fileName, checks ~= new RedundantStorageClassCheck(args.setSkipTests(
analysisConfig.redundant_storage_classes == Check.skipTests && !ut); analysisConfig.redundant_storage_classes == Check.skipTests && !ut));
if (moduleName.shouldRun!UnusedResultChecker(analysisConfig)) if (moduleName.shouldRun!UnusedResultChecker(analysisConfig))
checks ~= new UnusedResultChecker(fileName, moduleScope, checks ~= new UnusedResultChecker(args.setSkipTests(
analysisConfig.unused_result == Check.skipTests && !ut); analysisConfig.unused_result == Check.skipTests && !ut));
if (moduleName.shouldRun!CyclomaticComplexityCheck(analysisConfig)) if (moduleName.shouldRun!CyclomaticComplexityCheck(analysisConfig))
checks ~= new CyclomaticComplexityCheck(fileName, moduleScope, checks ~= new CyclomaticComplexityCheck(args.setSkipTests(
analysisConfig.cyclomatic_complexity == Check.skipTests && !ut, analysisConfig.cyclomatic_complexity == Check.skipTests && !ut),
analysisConfig.max_cyclomatic_complexity.to!int); analysisConfig.max_cyclomatic_complexity.to!int);
if (moduleName.shouldRun!BodyOnDisabledFuncsCheck(analysisConfig)) if (moduleName.shouldRun!BodyOnDisabledFuncsCheck(analysisConfig))
checks ~= new BodyOnDisabledFuncsCheck(fileName, moduleScope, checks ~= new BodyOnDisabledFuncsCheck(args.setSkipTests(
analysisConfig.body_on_disabled_func_check == Check.skipTests && !ut); analysisConfig.body_on_disabled_func_check == Check.skipTests && !ut));
version (none) version (none)
if (moduleName.shouldRun!IfStatementCheck(analysisConfig)) if (moduleName.shouldRun!IfStatementCheck(analysisConfig))
checks ~= new IfStatementCheck(fileName, moduleScope, checks ~= new IfStatementCheck(args.setSkipTests(
analysisConfig.redundant_if_check == Check.skipTests && !ut); analysisConfig.redundant_if_check == Check.skipTests && !ut));
return checks; return checks;
} }

View File

@ -28,9 +28,9 @@ final class StaticIfElse : BaseAnalyzer
mixin AnalyzerInfo!"static_if_else_check"; mixin AnalyzerInfo!"static_if_else_check";
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const ConditionalStatement cc) override void visit(const ConditionalStatement cc)

View File

@ -13,9 +13,10 @@ final class StatsCollector : BaseAnalyzer
{ {
alias visit = ASTVisitor.visit; alias visit = ASTVisitor.visit;
this(string fileName) this(BaseAnalyzerArguments args)
{ {
super(fileName, null); args.skipTests = false; // old behavior compatibility
super(args);
} }
override void visit(const Statement statement) override void visit(const Statement statement)

View File

@ -27,9 +27,9 @@ final class StyleChecker : BaseAnalyzer
enum string KEY = "dscanner.style.phobos_naming_convention"; enum string KEY = "dscanner.style.phobos_naming_convention";
mixin AnalyzerInfo!"style_check"; mixin AnalyzerInfo!"style_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const ModuleDeclaration dec) override void visit(const ModuleDeclaration dec)

View File

@ -31,9 +31,9 @@ public:
mixin AnalyzerInfo!"trust_too_much"; mixin AnalyzerInfo!"trust_too_much";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const AtAttribute d) override void visit(const AtAttribute d)

View File

@ -23,9 +23,9 @@ final class UndocumentedDeclarationCheck : BaseAnalyzer
mixin AnalyzerInfo!"undocumented_declaration_check"; mixin AnalyzerInfo!"undocumented_declaration_check";
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Module mod) override void visit(const Module mod)

View File

@ -21,9 +21,9 @@ final class UnmodifiedFinder : BaseAnalyzer
mixin AnalyzerInfo!"could_be_immutable_check"; mixin AnalyzerInfo!"could_be_immutable_check";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Module mod) override void visit(const Module mod)

View File

@ -20,12 +20,10 @@ abstract class UnusedIdentifierCheck : BaseAnalyzer
alias visit = BaseAnalyzer.visit; alias visit = BaseAnalyzer.visit;
/** /**
* Params:
* fileName = the name of the file being analyzed
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
re = regex("[\\p{Alphabetic}_][\\w_]*"); re = regex("[\\p{Alphabetic}_][\\w_]*");
} }
@ -421,15 +419,13 @@ abstract class UnusedStorageCheck : UnusedIdentifierCheck
/** /**
* Params: * Params:
* fileName = the name of the file being analyzed * args = commonly shared analyzer arguments
* sc = the scope
* skipTest = whether tests should be analyzed
* publicType = declaration kind used in error messages, e.g. "Variable"s * publicType = declaration kind used in error messages, e.g. "Variable"s
* reportType = declaration kind used in error reports, e.g. "unused_variable" * reportType = declaration kind used in error reports, e.g. "unused_variable"
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false, string publicType = null, string reportType = null) this(BaseAnalyzerArguments args, string publicType = null, string reportType = null)
{ {
super(fileName, sc, skipTests); super(args);
this.publicType = publicType; this.publicType = publicType;
this.reportType = reportType; this.reportType = reportType;
} }

View File

@ -21,9 +21,9 @@ final class UnusedLabelCheck : BaseAnalyzer
mixin AnalyzerInfo!"unused_label_check"; mixin AnalyzerInfo!"unused_label_check";
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
} }
override void visit(const Module mod) override void visit(const Module mod)

View File

@ -23,9 +23,9 @@ final class UnusedParameterCheck : UnusedStorageCheck
* Params: * Params:
* fileName = the name of the file being analyzed * fileName = the name of the file being analyzed
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests, "Parameter", "unused_parameter"); super(args, "Parameter", "unused_parameter");
} }
override void visit(const Parameter parameter) override void visit(const Parameter parameter)

View File

@ -41,9 +41,9 @@ public:
const(DSymbol)* noreturn_; const(DSymbol)* noreturn_;
/// ///
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests); super(args);
void_ = sc.getSymbolsByName(internString("void"))[0]; void_ = sc.getSymbolsByName(internString("void"))[0];
auto symbols = sc.getSymbolsByName(internString("noreturn")); auto symbols = sc.getSymbolsByName(internString("noreturn"));
if (symbols.length > 0) if (symbols.length > 0)

View File

@ -23,9 +23,9 @@ final class UnusedVariableCheck : UnusedStorageCheck
* Params: * Params:
* fileName = the name of the file being analyzed * fileName = the name of the file being analyzed
*/ */
this(string fileName, const(Scope)* sc, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, sc, skipTests, "Variable", "unused_variable"); super(args, "Variable", "unused_variable");
} }
override void visit(const VariableDeclaration variableDeclaration) override void visit(const VariableDeclaration variableDeclaration)

View File

@ -30,9 +30,9 @@ final class UselessAssertCheck : BaseAnalyzer
mixin AnalyzerInfo!"useless_assert_check"; mixin AnalyzerInfo!"useless_assert_check";
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const AssertExpression ae) override void visit(const AssertExpression ae)

View File

@ -56,9 +56,9 @@ private:
public: public:
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
_inStruct.insert(false); _inStruct.insert(false);
} }

View File

@ -145,9 +145,9 @@ private:
public: public:
/// ///
this(string fileName, bool skipTests = false) this(BaseAnalyzerArguments args)
{ {
super(fileName, null, skipTests); super(args);
} }
override void visit(const(ClassDeclaration) decl) override void visit(const(ClassDeclaration) decl)