1 //          Copyright Brian Schott (Hackerpilot) 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 module analysis.config;
7 
8 import inifiled;
9 
10 StaticAnalysisConfig defaultStaticAnalysisConfig()
11 {
12 	StaticAnalysisConfig config;
13 	foreach (mem; __traits(allMembers, StaticAnalysisConfig))
14 		mixin("config." ~ mem ~ " = true;");
15 	return config;
16 }
17 
18 @INI("Configure which static analysis checks are enabled")
19 struct StaticAnalysisConfig
20 {
21 	@INI("Check variable, class, struct, interface, union, and function names against the Phobos style guide")
22 	bool style_check;
23 
24 	@INI("Check for array literals that cause unnecessary allocation")
25 	bool enum_array_literal_check;
26 
27 	@INI("Check for poor exception handling practices")
28 	bool exception_check;
29 
30 	@INI("Check for use of the deprecated 'delete' keyword")
31 	bool delete_check;
32 
33 	@INI("Check for use of the deprecated floating point operators")
34 	bool float_operator_check;
35 
36 	@INI("Check number literals for readability")
37 	bool number_style_check;
38 
39 	@INI("Checks that opEquals, opCmp, toHash, and toString are either const, immutable, or inout.")
40 	bool object_const_check;
41 
42 	@INI("Checks for .. expressions where the left side is larger than the right.")
43 	bool backwards_range_check;
44 
45 	@INI("Checks for if statements whose 'then' block is the same as the 'else' block")
46 	bool if_else_same_check;
47 
48 	@INI("Checks for some problems with constructors")
49 	bool constructor_check;
50 
51 	@INI("Checks for unused variables and function parameters")
52 	bool unused_variable_check;
53 
54 	@INI("Checks for unused labels")
55 	bool unused_label_check;
56 
57 	@INI("Checks for duplicate attributes")
58 	bool duplicate_attribute;
59 
60 	@INI("Checks that opEquals and toHash are both defined or neither are defined")
61 	bool opequals_tohash_check;
62 
63 	@INI("Checks for subtraction from .length properties")
64 	bool length_subtraction_check;
65 
66 	@INI("Checks for methods or properties whose names conflict with built-in properties")
67 	bool builtin_property_names_check;
68 
69 	@INI("Checks for confusing code in inline asm statements")
70 	bool asm_style_check;
71 
72 	@INI("Checks for confusing logical operator precedence")
73 	bool logical_precedence_check;
74 
75 	@INI("Checks for undocumented public declarations")
76 	bool undocumented_declaration_check;
77 
78 	@INI("Checks for poor placement of function attributes")
79 	bool function_attribute_check;
80 
81 	@INI("Checks for use of the comma operator")
82 	bool comma_expression_check;
83 
84 	@INI("Checks for local imports that are too broad")
85 	bool local_import_check;
86 
87 	@INI("Checks for variables that could be declared immutable")
88 	bool could_be_immutable_check = false; // disabled by default for now
89 
90 	@INI("Checks for redundant expressions in if statements")
91 	bool redundant_if_check;
92 
93 	@INI("Checks for redundant parenthesis")
94 	bool redundant_parens_check;
95 
96 	@INI("Checks for mismatched argument and parameter names")
97 	bool mismatched_args_check;
98 
99 	@INI("Checks for labels with the same name as variables")
100 	bool label_var_same_name_check;
101 
102 	@INI("Checks for lines longer than 120 characters")
103 	bool long_line_check;
104 
105 	@INI("Checks for assignment to auto-ref function parameters")
106 	bool auto_ref_assignment_check;
107 
108 	@INI("Checks for incorrect infinite range definitions")
109 	bool incorrect_infinite_range_check;
110 
111 	@INI("Checks for asserts that are always true")
112 	bool useless_assert_check;
113 
114 	@INI("Check for uses of the old-style alias syntax")
115 	bool alias_syntax_check;
116 }