disable Phobos-specific checks by default, close #406
This commit is contained in:
parent
b2d96ad777
commit
7a74a70e85
|
@ -118,6 +118,9 @@ Note that the "--skipTests" option is the equivalent of changing each
|
||||||
* Some assertions that check conditions that will always be true.
|
* Some assertions that check conditions that will always be true.
|
||||||
* Auto functions without return statement. The compiler doesn't see an omission and it infers 'void' as return type.
|
* Auto functions without return statement. The compiler doesn't see an omission and it infers 'void' as return type.
|
||||||
* `final` attribute is used but in this context it's a noop.
|
* `final` attribute is used but in this context it's a noop.
|
||||||
|
* Check for properly documented public functions ("Returns" and "Params" sections). Initially implemented to lint Phobos. By default disabled.
|
||||||
|
* Check for explicitly annotated unittests (_@system_ or _@safe_). Initially implemented to lint Phobos. By default disabled.
|
||||||
|
* Check for that imports are sorted. Initially implemented to lint Phobos. By default disabled.
|
||||||
* Virtual calls inside classes constructors.
|
* Virtual calls inside classes constructors.
|
||||||
|
|
||||||
#### Wishlist
|
#### Wishlist
|
||||||
|
|
|
@ -40,10 +40,10 @@ private:
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.alias_syntax_check = Check.enabled;
|
sac.alias_syntax_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
alias int abcde; // [warn]: Prefer the new "'alias' identifier '=' type ';'" syntax to the old "'alias' type identifier ';'" syntax.
|
alias int abcde; // [warn]: Prefer the new "'alias' identifier '=' type ';'" syntax to the old "'alias' type identifier ';'" syntax.
|
||||||
|
|
|
@ -39,9 +39,9 @@ class AsmStyleCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.asm_style_check = Check.enabled;
|
sac.asm_style_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testAsm()
|
void testAsm()
|
||||||
|
|
|
@ -157,10 +157,10 @@ unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.auto_function_check = Check.enabled;
|
sac.auto_function_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
auto ref doStuff(){} // [warn]: %s
|
auto ref doStuff(){} // [warn]: %s
|
||||||
|
|
|
@ -113,10 +113,10 @@ unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.auto_ref_assignment_check = Check.enabled;
|
sac.auto_ref_assignment_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
int doStuff(T)(auto ref int a)
|
int doStuff(T)(auto ref int a)
|
||||||
|
|
|
@ -102,9 +102,9 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.builtin_property_names_check = Check.enabled;
|
sac.builtin_property_names_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
class SomeClass
|
class SomeClass
|
||||||
|
|
|
@ -7,146 +7,160 @@ module analysis.config;
|
||||||
|
|
||||||
import inifiled;
|
import inifiled;
|
||||||
|
|
||||||
|
/// Returns: A default configuration.
|
||||||
StaticAnalysisConfig defaultStaticAnalysisConfig()
|
StaticAnalysisConfig defaultStaticAnalysisConfig()
|
||||||
{
|
{
|
||||||
StaticAnalysisConfig config;
|
StaticAnalysisConfig config;
|
||||||
config.fillConfig!(Check.enabled);
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Describes how a check is operated.
|
||||||
enum Check: string
|
enum Check: string
|
||||||
{
|
{
|
||||||
|
/// Check is disabled.
|
||||||
disabled = "disabled",
|
disabled = "disabled",
|
||||||
|
/// Check is enabled.
|
||||||
enabled = "enabled",
|
enabled = "enabled",
|
||||||
|
/// Check is enabled but not operated in the unittests.
|
||||||
skipTests = "skip-unittest"
|
skipTests = "skip-unittest"
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillConfig(string check)(ref StaticAnalysisConfig config)
|
/// Applies the --skipTests switch, allowing to call Dscanner without config
|
||||||
|
/// and less noise related to the unittests.
|
||||||
|
void enabled2SkipTests(ref StaticAnalysisConfig config)
|
||||||
{
|
{
|
||||||
foreach (mem; __traits(allMembers, StaticAnalysisConfig))
|
foreach (mem; __traits(allMembers, StaticAnalysisConfig))
|
||||||
{
|
{
|
||||||
static if (is(typeof(__traits(getMember, StaticAnalysisConfig, mem))))
|
static if (is(typeof(__traits(getMember, StaticAnalysisConfig, mem))))
|
||||||
static if (is(typeof(__traits(getMember, config, mem)) == string))
|
static if (is(typeof(__traits(getMember, config, mem)) == string))
|
||||||
__traits(getMember, config, mem) = check;
|
{
|
||||||
|
if (__traits(getMember, config, mem) == Check.enabled)
|
||||||
|
__traits(getMember, config, mem) = Check.skipTests;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
/// Returns a config with all the checks disabled.
|
||||||
|
StaticAnalysisConfig disabledConfig()
|
||||||
{
|
{
|
||||||
StaticAnalysisConfig c;
|
StaticAnalysisConfig config;
|
||||||
c.fillConfig!(Check.enabled);
|
foreach (mem; __traits(allMembers, StaticAnalysisConfig))
|
||||||
assert(c.enum_array_literal_check == Check.enabled);
|
{
|
||||||
fillConfig!(Check.skipTests)(c);
|
static if (is(typeof(__traits(getMember, StaticAnalysisConfig, mem))))
|
||||||
assert(c.alias_syntax_check == Check.skipTests);
|
static if (is(typeof(__traits(getMember, config, mem)) == string))
|
||||||
|
__traits(getMember, config, mem) = Check.disabled;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@INI("Configure which static analysis checks are enabled")
|
@INI("Configure which static analysis checks are enabled")
|
||||||
struct StaticAnalysisConfig
|
struct StaticAnalysisConfig
|
||||||
{
|
{
|
||||||
@INI("Check variable, class, struct, interface, union, and function names against the Phobos style guide")
|
@INI("Check variable, class, struct, interface, union, and function names against the Phobos style guide")
|
||||||
string style_check = Check.disabled;
|
string style_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for array literals that cause unnecessary allocation")
|
@INI("Check for array literals that cause unnecessary allocation")
|
||||||
string enum_array_literal_check = Check.disabled;
|
string enum_array_literal_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for poor exception handling practices")
|
@INI("Check for poor exception handling practices")
|
||||||
string exception_check = Check.disabled;
|
string exception_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for use of the deprecated 'delete' keyword")
|
@INI("Check for use of the deprecated 'delete' keyword")
|
||||||
string delete_check = Check.disabled;
|
string delete_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for use of the deprecated floating point operators")
|
@INI("Check for use of the deprecated floating point operators")
|
||||||
string float_operator_check = Check.disabled;
|
string float_operator_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check number literals for readability")
|
@INI("Check number literals for readability")
|
||||||
string number_style_check = Check.disabled;
|
string number_style_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks that opEquals, opCmp, toHash, and toString are either const, immutable, or inout.")
|
@INI("Checks that opEquals, opCmp, toHash, and toString are either const, immutable, or inout.")
|
||||||
string object_const_check = Check.disabled;
|
string object_const_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for .. expressions where the left side is larger than the right.")
|
@INI("Checks for .. expressions where the left side is larger than the right.")
|
||||||
string backwards_range_check = Check.disabled;
|
string backwards_range_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for if statements whose 'then' block is the same as the 'else' block")
|
@INI("Checks for if statements whose 'then' block is the same as the 'else' block")
|
||||||
string if_else_same_check = Check.disabled;
|
string if_else_same_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for some problems with constructors")
|
@INI("Checks for some problems with constructors")
|
||||||
string constructor_check = Check.disabled;
|
string constructor_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for unused variables and function parameters")
|
@INI("Checks for unused variables and function parameters")
|
||||||
string unused_variable_check = Check.disabled;
|
string unused_variable_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for unused labels")
|
@INI("Checks for unused labels")
|
||||||
string unused_label_check = Check.disabled;
|
string unused_label_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for duplicate attributes")
|
@INI("Checks for duplicate attributes")
|
||||||
string duplicate_attribute = Check.disabled;
|
string duplicate_attribute = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks that opEquals and toHash are both defined or neither are defined")
|
@INI("Checks that opEquals and toHash are both defined or neither are defined")
|
||||||
string opequals_tohash_check = Check.disabled;
|
string opequals_tohash_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for subtraction from .length properties")
|
@INI("Checks for subtraction from .length properties")
|
||||||
string length_subtraction_check = Check.disabled;
|
string length_subtraction_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for methods or properties whose names conflict with built-in properties")
|
@INI("Checks for methods or properties whose names conflict with built-in properties")
|
||||||
string builtin_property_names_check = Check.disabled;
|
string builtin_property_names_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for confusing code in inline asm statements")
|
@INI("Checks for confusing code in inline asm statements")
|
||||||
string asm_style_check = Check.disabled;
|
string asm_style_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for confusing logical operator precedence")
|
@INI("Checks for confusing logical operator precedence")
|
||||||
string logical_precedence_check = Check.disabled;
|
string logical_precedence_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for undocumented public declarations")
|
@INI("Checks for undocumented public declarations")
|
||||||
string undocumented_declaration_check = Check.disabled;
|
string undocumented_declaration_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for poor placement of function attributes")
|
@INI("Checks for poor placement of function attributes")
|
||||||
string function_attribute_check = Check.disabled;
|
string function_attribute_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for use of the comma operator")
|
@INI("Checks for use of the comma operator")
|
||||||
string comma_expression_check = Check.disabled;
|
string comma_expression_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for local imports that are too broad")
|
@INI("Checks for local imports that are too broad")
|
||||||
string local_import_check = Check.disabled;
|
string local_import_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for variables that could be declared immutable")
|
@INI("Checks for variables that could be declared immutable")
|
||||||
string could_be_immutable_check = Check.disabled; // disabled by default for now
|
string could_be_immutable_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for redundant expressions in if statements")
|
@INI("Checks for redundant expressions in if statements")
|
||||||
string redundant_if_check = Check.disabled;
|
string redundant_if_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for redundant parenthesis")
|
@INI("Checks for redundant parenthesis")
|
||||||
string redundant_parens_check = Check.disabled;
|
string redundant_parens_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for mismatched argument and parameter names")
|
@INI("Checks for mismatched argument and parameter names")
|
||||||
string mismatched_args_check = Check.disabled;
|
string mismatched_args_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for labels with the same name as variables")
|
@INI("Checks for labels with the same name as variables")
|
||||||
string label_var_same_name_check = Check.disabled;
|
string label_var_same_name_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for lines longer than 120 characters")
|
@INI("Checks for lines longer than 120 characters")
|
||||||
string long_line_check = Check.disabled;
|
string long_line_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for assignment to auto-ref function parameters")
|
@INI("Checks for assignment to auto-ref function parameters")
|
||||||
string auto_ref_assignment_check = Check.disabled;
|
string auto_ref_assignment_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for incorrect infinite range definitions")
|
@INI("Checks for incorrect infinite range definitions")
|
||||||
string incorrect_infinite_range_check = Check.disabled;
|
string incorrect_infinite_range_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for asserts that are always true")
|
@INI("Checks for asserts that are always true")
|
||||||
string useless_assert_check = Check.disabled;
|
string useless_assert_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for uses of the old-style alias syntax")
|
@INI("Check for uses of the old-style alias syntax")
|
||||||
string alias_syntax_check = Check.disabled;
|
string alias_syntax_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Checks for else if that should be else static if")
|
@INI("Checks for else if that should be else static if")
|
||||||
string static_if_else_check = Check.disabled;
|
string static_if_else_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for unclear lambda syntax")
|
@INI("Check for unclear lambda syntax")
|
||||||
string lambda_return_check = Check.disabled;
|
string lambda_return_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for auto function without return statement")
|
@INI("Check for auto function without return statement")
|
||||||
string auto_function_check = Check.disabled;
|
string auto_function_check = Check.enabled;
|
||||||
|
|
||||||
@INI("Check for sortedness of imports")
|
@INI("Check for sortedness of imports")
|
||||||
string imports_sortedness = Check.disabled;
|
string imports_sortedness = Check.disabled;
|
||||||
|
|
|
@ -90,9 +90,9 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.constructor_check = Check.enabled;
|
sac.constructor_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
class Cat // [warn]: This class has a zero-argument constructor as well as a constructor with one default argument. This can be confusing.
|
class Cat // [warn]: This class has a zero-argument constructor as well as a constructor with one default argument. This can be confusing.
|
||||||
|
|
|
@ -33,10 +33,10 @@ class DeleteCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.delete_check = Check.enabled;
|
sac.delete_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testDelete()
|
void testDelete()
|
||||||
|
|
|
@ -153,9 +153,9 @@ class DuplicateAttributeCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.duplicate_attribute = Check.enabled;
|
sac.duplicate_attribute = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
class ExampleAttributes
|
class ExampleAttributes
|
||||||
|
|
|
@ -56,10 +56,10 @@ unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.explicitly_annotated_unittests = Check.enabled;
|
sac.explicitly_annotated_unittests = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
|
|
|
@ -219,12 +219,12 @@ public:
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.final_attribute_check = Check.enabled;
|
sac.final_attribute_check = Check.enabled;
|
||||||
|
|
||||||
// pass
|
// pass
|
||||||
|
|
|
@ -42,9 +42,9 @@ class FloatOperatorCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.float_operator_check = Check.enabled;
|
sac.float_operator_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testFish()
|
void testFish()
|
||||||
|
|
|
@ -76,9 +76,9 @@ class IfElseSameCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.if_else_same_check = Check.enabled;
|
sac.if_else_same_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testSizeT()
|
void testSizeT()
|
||||||
|
|
|
@ -104,10 +104,10 @@ unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.imports_sortedness = Check.enabled;
|
sac.imports_sortedness = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
|
|
|
@ -88,10 +88,10 @@ private:
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.incorrect_infinite_range_check = Check.enabled;
|
sac.incorrect_infinite_range_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{struct InfiniteRange
|
assertAnalyzerWarnings(q{struct InfiniteRange
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,10 +125,10 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.label_var_same_name_check = Check.enabled;
|
sac.label_var_same_name_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
unittest
|
unittest
|
||||||
|
|
|
@ -47,10 +47,10 @@ private:
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.lambda_return_check = Check.enabled;
|
sac.lambda_return_check = Check.enabled;
|
||||||
|
|
||||||
auto code = `
|
auto code = `
|
||||||
|
|
|
@ -58,9 +58,9 @@ class LengthSubtractionCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.length_subtraction_check = Check.enabled;
|
sac.length_subtraction_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testSizeT()
|
void testSizeT()
|
||||||
|
|
|
@ -85,11 +85,11 @@ private:
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
import analysis.config : Check, StaticAnalysisConfig;
|
import analysis.config : Check, StaticAnalysisConfig, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.long_line_check = Check.enabled;
|
sac.long_line_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
Window window = Platform.instance.createWindow("Дистанционное управление сварочным оборудованием", null);
|
Window window = Platform.instance.createWindow("Дистанционное управление сварочным оборудованием", null);
|
||||||
|
|
|
@ -84,9 +84,9 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.local_import_check = Check.enabled;
|
sac.local_import_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testLocalImport()
|
void testLocalImport()
|
||||||
|
|
|
@ -48,9 +48,9 @@ class LogicPrecedenceCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.logical_precedence_check = Check.enabled;
|
sac.logical_precedence_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testFish()
|
void testFish()
|
||||||
|
|
|
@ -49,9 +49,9 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.number_style_check = Check.enabled;
|
sac.number_style_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testNumbers()
|
void testNumbers()
|
||||||
|
|
|
@ -71,9 +71,9 @@ class ObjectConstCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.object_const_check = Check.enabled;
|
sac.object_const_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testConsts()
|
void testConsts()
|
||||||
|
|
|
@ -89,9 +89,9 @@ class OpEqualsWithoutToHashCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.opequals_tohash_check = Check.enabled;
|
sac.opequals_tohash_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
// Success because it has opEquals and toHash
|
// Success because it has opEquals and toHash
|
||||||
|
|
|
@ -85,9 +85,9 @@ class PokemonExceptionCheck : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.exception_check = Check.enabled;
|
sac.exception_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testCatch()
|
void testCatch()
|
||||||
|
|
|
@ -286,15 +286,16 @@ version(unittest)
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac = {properly_documented_public_functions: Check.enabled};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// missing params
|
// missing params
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
Some text
|
Some text
|
||||||
|
@ -367,6 +368,9 @@ unittest
|
||||||
// missing returns (only functions)
|
// missing returns (only functions)
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
Some text
|
Some text
|
||||||
|
@ -389,6 +393,9 @@ unittest
|
||||||
// ignore private
|
// ignore private
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
Some text
|
Some text
|
||||||
|
@ -442,10 +449,12 @@ unittest
|
||||||
), sac);
|
), sac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// test parameter names
|
// test parameter names
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
|
@ -557,6 +566,9 @@ struct foo(int foo, int bar){}
|
||||||
// support ditto
|
// support ditto
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
|
@ -651,6 +663,9 @@ int bar(int bar){}
|
||||||
// check correct ddoc headers
|
// check correct ddoc headers
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/++
|
/++
|
||||||
Counts elements in the given
|
Counts elements in the given
|
||||||
|
@ -684,6 +699,9 @@ template bar(string val){}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
|
StaticAnalysisConfig sac = disabledConfig;
|
||||||
|
sac.properly_documented_public_functions = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
/**
|
/**
|
||||||
* Ddoc for the inner function appears here.
|
* Ddoc for the inner function appears here.
|
||||||
|
|
|
@ -157,9 +157,9 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.backwards_range_check = Check.enabled;
|
sac.backwards_range_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void testRange()
|
void testRange()
|
||||||
|
|
|
@ -66,10 +66,10 @@ class StaticIfElse : BaseAnalyzer
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.static_if_else_check = Check.enabled;
|
sac.static_if_else_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
void foo() {
|
void foo() {
|
||||||
|
|
|
@ -166,9 +166,9 @@ final class StyleChecker : BaseAnalyzer
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.style_check = Check.enabled;
|
sac.style_check = Check.enabled;
|
||||||
|
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
|
|
|
@ -316,12 +316,12 @@ bool isValueTypeSimple(const Type type) pure nothrow @nogc
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.could_be_immutable_check = Check.enabled;
|
sac.could_be_immutable_check = Check.enabled;
|
||||||
|
|
||||||
// pass
|
// pass
|
||||||
|
|
|
@ -435,10 +435,10 @@ private:
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.unused_variable_check = Check.enabled;
|
sac.unused_variable_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
|
|
||||||
|
|
|
@ -165,10 +165,10 @@ private:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : Check, StaticAnalysisConfig;
|
import analysis.config : Check, StaticAnalysisConfig, disabledConfig;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.unused_label_check = Check.enabled;
|
sac.unused_label_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
int testUnusedLabel()
|
int testUnusedLabel()
|
||||||
|
|
|
@ -96,10 +96,10 @@ private:
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.useless_assert_check = Check.enabled;
|
sac.useless_assert_check = Check.enabled;
|
||||||
assertAnalyzerWarnings(q{
|
assertAnalyzerWarnings(q{
|
||||||
unittest
|
unittest
|
||||||
|
|
|
@ -276,12 +276,12 @@ public:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import analysis.config : StaticAnalysisConfig, Check;
|
import analysis.config : StaticAnalysisConfig, Check, disabledConfig;
|
||||||
import analysis.helpers : assertAnalyzerWarnings;
|
import analysis.helpers : assertAnalyzerWarnings;
|
||||||
import std.stdio : stderr;
|
import std.stdio : stderr;
|
||||||
import std.format : format;
|
import std.format : format;
|
||||||
|
|
||||||
StaticAnalysisConfig sac;
|
StaticAnalysisConfig sac = disabledConfig();
|
||||||
sac.vcall_in_ctor = Check.enabled;
|
sac.vcall_in_ctor = Check.enabled;
|
||||||
|
|
||||||
// fails
|
// fails
|
||||||
|
|
|
@ -229,7 +229,7 @@ else
|
||||||
if (s.exists())
|
if (s.exists())
|
||||||
readINIFile(config, s);
|
readINIFile(config, s);
|
||||||
if (skipTests)
|
if (skipTests)
|
||||||
config.fillConfig!(Check.skipTests);
|
config.enabled2SkipTests;
|
||||||
if (report)
|
if (report)
|
||||||
generateReport(expandArgs(args), config, cache, moduleCache);
|
generateReport(expandArgs(args), config, cache, moduleCache);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue