Skip to content

Commit 82d947c

Browse files
authored
Merge pull request #5495 from wilzbach/selective-checks
Apply Dscanner checks only to specific modules merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
2 parents 5e0699a + 3a13b12 commit 82d947c

File tree

5 files changed

+68
-43
lines changed

5 files changed

+68
-43
lines changed

.dscanner.ini

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,65 @@
22
[analysis.config.StaticAnalysisConfig]
33
; Check variable, class, struct, interface, union, and function names against
44
; the Phobos style guide
5-
style_check="disabled"
5+
style_check="enabled"
66
; Check for array literals that cause unnecessary allocation
77
enum_array_literal_check="enabled"
88
; Check for poor exception handling practices
9-
exception_check="disabled" ; FIXME
9+
exception_check="enabled"
1010
; Check for use of the deprecated 'delete' keyword
1111
delete_check="enabled"
1212
; Check for use of the deprecated floating point operators
1313
float_operator_check="enabled"
1414
; Check number literals for readability
15-
number_style_check="skip-unittest";
15+
number_style_check="enabled"
1616
; Checks that opEquals, opCmp, toHash, and toString are either const, immutable
1717
; , or inout.
18-
object_const_check="disabled"
18+
object_const_check="enabled"
1919
; Checks for .. expressions where the left side is larger than the right.
2020
backwards_range_check="enabled"
2121
; Checks for if statements whose 'then' block is the same as the 'else' block
2222
if_else_same_check="enabled"
2323
; Checks for some problems with constructors
2424
constructor_check="enabled"
2525
; Checks for unused variables and function parameters
26-
unused_variable_check="disabled"
26+
unused_variable_check="enabled"
2727
; Checks for unused labels
28-
unused_label_check="disabled" ; FIXME
28+
unused_label_check="enabled"
2929
; Checks for duplicate attributes
3030
duplicate_attribute="enabled"
3131
; Checks that opEquals and toHash are both defined or neither are defined
32-
opequals_tohash_check="disabled"
32+
opequals_tohash_check="enabled"
3333
; Checks for subtraction from .length properties
34-
length_subtraction_check="disabled"
35-
; Checks for methods or properties whose names conflict with built-in properties
36-
builtin_property_names_check="enabled"; FIXME
34+
length_subtraction_check="enabled"
35+
; Checks for methods or properties whose names conflict with built-in propertie
36+
; s
37+
builtin_property_names_check="enabled"
3738
; Checks for confusing code in inline asm statements
38-
asm_style_check="disabled"; FIXME
39+
asm_style_check="enabled"
3940
; Checks for confusing logical operator precedence
40-
logical_precedence_check="disabled"
41+
logical_precedence_check="enabled"
4142
; Checks for undocumented public declarations
42-
undocumented_declaration_check="disabled"; FIXME
43+
undocumented_declaration_check="enabled"
4344
; Checks for poor placement of function attributes
44-
function_attribute_check="disabled"
45+
function_attribute_check="enabled"
4546
; Checks for use of the comma operator
4647
comma_expression_check="enabled"
4748
; Checks for local imports that are too broad
4849
local_import_check="skip-unittest"
4950
; Checks for variables that could be declared immutable
50-
could_be_immutable_check="disabled"
51+
could_be_immutable_check="enabled"
5152
; Checks for redundant expressions in if statements
5253
redundant_if_check="enabled"
5354
; Checks for redundant parenthesis
5455
redundant_parens_check="enabled"
5556
; Checks for mismatched argument and parameter names
56-
mismatched_args_check="disabled"
57+
mismatched_args_check="enabled"
5758
; Checks for labels with the same name as variables
58-
label_var_same_name_check="disabled"
59+
label_var_same_name_check="enabled"
5960
; Checks for lines longer than 120 characters
6061
long_line_check="enabled"
6162
; Checks for assignment to auto-ref function parameters
62-
auto_ref_assignment_check="disabled" ; FIXME
63+
auto_ref_assignment_check="enabled"
6364
; Checks for incorrect infinite range definitions
6465
incorrect_infinite_range_check="enabled"
6566
; Checks for asserts that are always true
@@ -71,10 +72,48 @@ static_if_else_check="enabled"
7172
; Check for unclear lambda syntax
7273
lambda_return_check="enabled"
7374
; Check for auto function without return statement
74-
auto_function_check = "enabled"
75-
; Check for explicitly annotated unittests
76-
explicitly_annotated_unittests = "enabled"
75+
auto_function_check="enabled"
7776
; Check for sortedness of imports
78-
imports_sortedness = "disabled"
77+
imports_sortedness="enabled"
78+
; Check for explicitly annotated unittests
79+
explicitly_annotated_unittests="enabled"
80+
; Check for properly documented public functions (Returns, Params)
81+
properly_documented_public_functions="enabled"
7982
; Check for useless usage of the final attribute
80-
final_attribute_check = "enabled"
83+
final_attribute_check="enabled"
84+
; Check for virtual calls in the class constructors
85+
vcall_in_ctor="enabled"
86+
; Check for useless user defined initializers
87+
useless_initializer="enabled"
88+
; Check allman brace style
89+
allman_braces_check="disabled"
90+
; Check for redundant attributes
91+
redundant_attributes_check="enabled"
92+
93+
; Configure which modules are checked with a specific checker
94+
; Please help to extend these checks onto more Phobos modules
95+
[analysis.config.ModuleFilters]
96+
asm_style_check="+std.algorithm"
97+
auto_ref_assignment_check="+std.algorithm.searching"
98+
could_be_immutable_check="+std.algorithm.internal"
99+
exception_check="+std.algorithm"
100+
function_attribute_check="+std.algorithm.searching"
101+
imports_sortedness = "+std.algorithm.disabled" ; currently disabled, see https://github.com/dlang/phobos/pull/5478
102+
label_var_same_name_check="+std.algorithm.searching"
103+
length_subtraction_check="+std.algorithm.comparison"
104+
logical_precedence_check="+std.algorithm.internal"
105+
long_line_check="-std.regex.internal.thompson"; Dscanner bug: https://github.com/dlang-community/D-Scanner/pull/465
106+
mismatched_args_check="+std.algorithm"
107+
mismatched_args_check="+std.algorithm"
108+
number_style_check="+std.algorithm.searching"
109+
object_const_check="+std.algorithm.internal"
110+
opequals_tohash_check="+std.algorithm.comparison"
111+
redundant_attributes_check = "+std.algorithm"
112+
style_check="+std.algorithm.searching"
113+
undocumented_declaration_check="+std.algorithm.searching"
114+
unused_label_check="+std.algorithm"
115+
unused_variable_check="+std.algorithm.internal"
116+
useless_initializer = "+std.algorithm.comparison"
117+
vcall_in_ctor="-std.socket,-std.xml"
118+
properly_documented_public_functions="+std.algorithm.internal"
119+
explicitly_annotated_unittests="-std.array,-std.allocator,-std.base64,-std.bitmanip,-std.concurrency,-std.conv,-std.csv,-std.datetime,-std.demangle,-std.digest.hmac,-std.digest.sha,-std.encoding,-std.exception,-std.file,-std.format,-std.getopt,-std.internal,-std.isemail,-std.json,-std.logger.core,-std.logger.nulllogger,-std.math,-std.mathspecial,-std.net.curl,-std.numeric,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.regex,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.xml,-std.zlib"

circle.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ test:
88
override:
99
- ./circleci.sh setup-repos
1010
- ./circleci.sh style_lint
11-
- ./circleci.sh has_public_example
1211
- ./circleci.sh publictests
1312
- ./circleci.sh coverage:
1413
parallel: true

circleci.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,11 @@ publictests()
133133
make -f posix.mak -j$N publictests DUB=$DUB
134134
}
135135
136-
# check modules for public unittests
137-
has_public_example()
138-
{
139-
make -f posix.mak -j$N has_public_example DUB=$DUB
140-
}
141-
142136
case $1 in
143137
install-deps) install_deps ;;
144138
setup-repos) setup_repos ;;
145139
coverage) coverage ;;
146140
publictests) publictests ;;
147-
has_public_example) has_public_example;;
148141
style_lint) style_lint ;;
149142
*) echo "Unknown command"; exit 1;;
150143
esac

posix.mak

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ ${TOOLS_DIR}:
506506
git clone --depth=1 ${GIT_HOME}/$(@F) $@
507507
$(TOOLS_DIR)/checkwhitespace.d: | $(TOOLS_DIR)
508508
$(TOOLS_DIR)/styles/tests_extractor.d: | $(TOOLS_DIR)
509-
$(TOOLS_DIR)/styles/has_public_example.d: | $(TOOLS_DIR)
510509

511510
#################### test for undesired white spaces ##########################
512511
CWS_TOCHECK = posix.mak win32.mak win64.mak osmodel.mak
@@ -522,17 +521,17 @@ checkwhitespace: $(LIB) $(TOOLS_DIR)/checkwhitespace.d
522521
#############################
523522

524523
../dscanner:
525-
git clone https://github.com/Hackerpilot/Dscanner ../dscanner
526-
git -C ../dscanner checkout tags/v0.4.0
524+
git clone https://github.com/dlang-community/Dscanner ../dscanner
525+
git -C ../dscanner checkout phobos
527526
git -C ../dscanner submodule update --init --recursive
528527

529-
../dscanner/dsc: ../dscanner
528+
../dscanner/dsc: ../dscanner $(DMD) $(LIB)
530529
# debug build is faster, but disable 'missing import' messages (missing core from druntime)
531530
sed 's/dparse_verbose/StdLoggerDisableWarning/' ../dscanner/makefile > dscanner_makefile_tmp
532531
mv dscanner_makefile_tmp ../dscanner/makefile
533-
make -C ../dscanner githash debug
532+
DC=$(DMD) DFLAGS="$(DFLAGS) -defaultlib=$(LIB)" make -C ../dscanner githash debug
534533

535-
style: has_public_example publictests style_lint
534+
style: publictests style_lint
536535

537536
style_lint: ../dscanner/dsc $(LIB)
538537
@echo "Check for trailing whitespace"
@@ -599,11 +598,6 @@ $(TEST_EXTRACTOR): $(TOOLS_DIR)/styles/tests_extractor.d $(LIB)
599598
@$(TEST_EXTRACTOR) --inputdir $< --outputdir $(PUBLICTESTS_DIR)
600599
@$(DMD) $(DFLAGS) -defaultlib= -debuglib= $(LIB) -main -unittest -run $(PUBLICTESTS_DIR)/$(subst /,_,$<)
601600

602-
has_public_example: $(LIB)
603-
# checks whether public function have public examples (for now some modules are excluded)
604-
rm -rf ./out
605-
DFLAGS="$(DFLAGS) $(LIB) $(LINKDL)" $(DUB) -v --compiler=$${PWD}/$(DMD) --root=../tools/styles -c has_public_example -- --inputdir std --ignore "array.d,allocator,base64.d,bitmanip.d,concurrency.d,conv.d,csv.d,datetime/date.d,datetime/interval.d,datetime/package.d,datetime/stopwatch.d,datetime/systime.d,datetime/timezone.d,demangle.d,digest/hmac.d,digest/sha.d,encoding.d,exception.d,file.d,format.d,getopt.d,index.d,internal,isemail.d,json.d,logger/core.d,logger/nulllogger.d,math.d,mathspecial.d,net/curl.d,numeric.d,parallelism.d,path.d,process.d,random.d,range,regex/package.d,socket.d,stdio.d,string.d,traits.d,typecons.d,uni.d,unittest.d,uri.d,utf.d,uuid.d,xml.d,zlib.d"
606-
607601
.PHONY : auto-tester-build
608602
auto-tester-build: all checkwhitespace
609603

std/algorithm/sorting.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,7 @@ body
34023402
r.swapAt(rite, pivot);
34033403
}
34043404
// Second loop: make left and pivot meet
3405-
outer: for (; rite > pivot; --rite)
3405+
for (; rite > pivot; --rite)
34063406
{
34073407
if (!lp(r[rite], r[oldPivot])) continue;
34083408
while (rite > pivot)

0 commit comments

Comments
 (0)