Skip to content

Commit 0eea52b

Browse files
committed
Add dscanner.ini, tweak documentation
1 parent 840563e commit 0eea52b

File tree

2 files changed

+114
-7
lines changed

2 files changed

+114
-7
lines changed

dscanner.ini

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
; Configure which static analysis checks are enabled
2+
[analysis.config.StaticAnalysisConfig]
3+
; Check variable, class, struct, interface, union, and function names against the Phobos style guide
4+
style_check="enabled"
5+
; Check for array literals that cause unnecessary allocation
6+
enum_array_literal_check="enabled"
7+
; Check for poor exception handling practices
8+
exception_check="enabled"
9+
; Check for use of the deprecated 'delete' keyword
10+
delete_check="enabled"
11+
; Check for use of the deprecated floating point operators
12+
float_operator_check="enabled"
13+
; Check number literals for readability
14+
number_style_check="enabled"
15+
; Checks that opEquals, opCmp, toHash, and toString are either const, immutable, or inout.
16+
object_const_check="enabled"
17+
; Checks for .. expressions where the left side is larger than the right.
18+
backwards_range_check="enabled"
19+
; Checks for if statements whose 'then' block is the same as the 'else' block
20+
if_else_same_check="enabled"
21+
; Checks for some problems with constructors
22+
constructor_check="enabled"
23+
; Checks for unused variables
24+
unused_variable_check="enabled"
25+
; Checks for unused labels
26+
unused_label_check="enabled"
27+
; Checks for unused function parameters
28+
unused_parameter_check="enabled"
29+
; Checks for duplicate attributes
30+
duplicate_attribute="enabled"
31+
; Checks that opEquals and toHash are both defined or neither are defined
32+
opequals_tohash_check="enabled"
33+
; Checks for subtraction from .length properties
34+
length_subtraction_check="enabled"
35+
; Checks for methods or properties whose names conflict with built-in properties
36+
builtin_property_names_check="enabled"
37+
; Checks for confusing code in inline asm statements
38+
asm_style_check="enabled"
39+
; Checks for confusing logical operator precedence
40+
logical_precedence_check="enabled"
41+
; Checks for undocumented public declarations
42+
undocumented_declaration_check="enabled"
43+
; Checks for poor placement of function attributes
44+
function_attribute_check="enabled"
45+
; Checks for use of the comma operator
46+
comma_expression_check="enabled"
47+
; Checks for local imports that are too broad. Only accurate when checking code used with D versions older than 2.071.0
48+
local_import_check="disabled"
49+
; Checks for variables that could be declared immutable
50+
could_be_immutable_check="enabled"
51+
; Checks for redundant expressions in if statements
52+
redundant_if_check="enabled"
53+
; Checks for redundant parenthesis
54+
redundant_parens_check="enabled"
55+
; Checks for mismatched argument and parameter names
56+
mismatched_args_check="enabled"
57+
; Checks for labels with the same name as variables
58+
label_var_same_name_check="enabled"
59+
; Checks for lines longer than `max_line_length` characters
60+
long_line_check="enabled"
61+
; Checks for assignment to auto-ref function parameters
62+
auto_ref_assignment_check="enabled"
63+
; Checks for incorrect infinite range definitions
64+
incorrect_infinite_range_check="enabled"
65+
; Checks for asserts that are always true
66+
useless_assert_check="enabled"
67+
; Check for uses of the old-style alias syntax
68+
alias_syntax_check="enabled"
69+
; Checks for else if that should be else static if
70+
static_if_else_check="enabled"
71+
; Check for unclear lambda syntax
72+
lambda_return_check="enabled"
73+
; Check for auto function without return statement
74+
auto_function_check="enabled"
75+
; Check for sortedness of imports
76+
imports_sortedness="disabled"
77+
; Check for explicitly annotated unittests
78+
explicitly_annotated_unittests="disabled"
79+
; Check for properly documented public functions (Returns, Params)
80+
properly_documented_public_functions="disabled"
81+
; Check for useless usage of the final attribute
82+
final_attribute_check="enabled"
83+
; Check for virtual calls in the class constructors
84+
vcall_in_ctor="enabled"
85+
; Check for useless user defined initializers
86+
useless_initializer="disabled"
87+
; Check allman brace style
88+
allman_braces_check="disabled"
89+
; Check for redundant attributes
90+
redundant_attributes_check="enabled"
91+
; Check public declarations without a documented unittest
92+
has_public_example="disabled"
93+
; Check for asserts without an explanatory message
94+
assert_without_msg="disabled"
95+
; Check indent of if constraints
96+
if_constraints_indent="disabled"
97+
; Check for @trusted applied to a bigger scope than a single function
98+
trust_too_much="enabled"
99+
; Check for redundant storage classes on variable declarations
100+
redundant_storage_classes="enabled"
101+
; Check for unused function return values
102+
unused_result="enabled"
103+
; Enable cyclomatic complexity check
104+
cyclomatic_complexity="disabled"
105+

source/sha3d.d

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module sha3d;
66

77
/// Version string of sha3-d that can be used for printing purposes.
8-
public enum SHA3D_VERSION_STRING = "1.3.0-dev";
8+
public enum SHA3D_VERSION_STRING = "1.3.0";
99

1010
private import std.digest;
1111
private import core.bitop : rol, bswap;
@@ -222,8 +222,8 @@ public struct KECCAK(uint digestSize,
222222

223223
version (SHA3D_Trace) // For tests anyway
224224
{
225-
uint round_counter;
226-
bool verbose;
225+
uint round_counter; // @suppress(dscanner.style.undocumented_declaration)
226+
bool verbose; // @suppress(dscanner.style.undocumented_declaration)
227227
}
228228

229229
/// Initiate or reset the state of the instance.
@@ -233,13 +233,14 @@ public struct KECCAK(uint digestSize,
233233
}
234234

235235
version (SHA3D_Trace)
236-
void enable_verbose()
236+
void enable_verbose() // @suppress(dscanner.style.undocumented_declaration)
237237
{
238238
verbose = true;
239239
writeln("keccak.init capacity=", capacity, " rate=", rate, " statesz=", state8Size);
240240
}
241241

242242
/// Feed the algorithm with data.
243+
///
243244
/// Also implements the $(REF isOutputRange, std,range,primitives)
244245
/// interface for `ubyte` and `const(ubyte)[]`.
245246
/// Params: input = Input data to digest
@@ -283,8 +284,9 @@ public struct KECCAK(uint digestSize,
283284
}
284285

285286
/// Returns the finished hash.
287+
///
286288
/// This also clears part of the state, leaving just the final digest.
287-
/// Returns: Raw digest data.
289+
/// Returns: Digest.
288290
ubyte[digestSizeBytes] finish()
289291
{
290292
// Mark delimiter at end of message and padding at the end of sponge.
@@ -785,7 +787,7 @@ version (SHA3D_Trace) {} else
785787
auto shake128_256Of(T...)(T data) { return digest!(SHAKE128_256, T)(data); }
786788

787789
// SHAKE128("", 256) =
788-
auto shake128_256empty = hexString!(
790+
const auto shake128_256empty = hexString!(
789791
"7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26");
790792

791793
// Using convenience alias
@@ -801,7 +803,7 @@ version (SHA3D_Trace) {} else
801803
auto shake256_512Of(T...)(T data) { return digest!(SHAKE256_512, T)(data); }
802804

803805
// SHAKE256("", 512) =
804-
auto shake256_512empty = hexString!(
806+
const auto shake256_512empty = hexString!(
805807
"46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762f"~
806808
"d75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be");
807809

0 commit comments

Comments
 (0)