-
-
Notifications
You must be signed in to change notification settings - Fork 763
Fix all DScanner warnings + use -return-exit-code re-enable it #6151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4689,6 +4689,47 @@ if (isSomeChar!C) | |
| } | ||
| } | ||
|
|
||
| // In same combinations substitute needs to calculate the auto-decoded length | ||
| // of its needles | ||
| private template hasDifferentAutodecoding(Range, Needles...) | ||
| { | ||
| import std.meta : anySatisfy; | ||
| /* iff | ||
| - the needles needs auto-decoding, but the incoming range doesn't (or vice versa) | ||
| - both (range, needle) need auto-decoding and don't share the same common type | ||
| */ | ||
| enum needlesAreNarrow = anySatisfy!(isNarrowString, Needles); | ||
| enum sourceIsNarrow = isNarrowString!Range; | ||
| enum hasDifferentAutodecoding = sourceIsNarrow != needlesAreNarrow || | ||
| (sourceIsNarrow && needlesAreNarrow && | ||
| is(CommonType!(Range, Needles) == void)); | ||
| } | ||
|
|
||
| @safe nothrow @nogc pure unittest | ||
| { | ||
| import std.meta : AliasSeq; // used for better clarity | ||
|
|
||
| static assert(!hasDifferentAutodecoding!(string, AliasSeq!(string, string))); | ||
| static assert(!hasDifferentAutodecoding!(wstring, AliasSeq!(wstring, wstring))); | ||
| static assert(!hasDifferentAutodecoding!(dstring, AliasSeq!(dstring, dstring))); | ||
|
|
||
| // the needles needs auto-decoding, but the incoming range doesn't (or vice versa) | ||
| static assert(hasDifferentAutodecoding!(string, AliasSeq!(wstring, wstring))); | ||
| static assert(hasDifferentAutodecoding!(string, AliasSeq!(dstring, dstring))); | ||
| static assert(hasDifferentAutodecoding!(wstring, AliasSeq!(string, string))); | ||
| static assert(hasDifferentAutodecoding!(wstring, AliasSeq!(dstring, dstring))); | ||
| static assert(hasDifferentAutodecoding!(dstring, AliasSeq!(string, string))); | ||
| static assert(hasDifferentAutodecoding!(dstring, AliasSeq!(wstring, wstring))); | ||
|
|
||
| // both (range, needle) need auto-decoding and don't share the same common type | ||
| static foreach (T; AliasSeq!(string, wstring, dstring)) | ||
| { | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(wstring, string))); | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(dstring, string))); | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(wstring, dstring))); | ||
| } | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was needed to for the "public symbol without undocumented example" check.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand. This symbol is not documented and the unit test is not an example.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning was for |
||
|
|
||
| // substitute | ||
| /** | ||
| Returns a range with all occurrences of `substs` in `r`. | ||
|
|
@@ -4731,14 +4772,16 @@ if (substs.length >= 2 && isExpressions!substs) | |
| // Substitute single range elements with compile-time substitution mappings | ||
| return value.map!(a => substitute(a)); | ||
| } | ||
| else static if (isInputRange!Value && !is(CommonType!(ElementType!Value, ElementType!(typeof(substs[0]))) == void)) | ||
| else static if (isInputRange!Value && | ||
| !is(CommonType!(ElementType!Value, ElementType!(typeof(substs[0]))) == void)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line > 120 |
||
| { | ||
| // not implemented yet, fallback to runtime variant for now | ||
| return .substitute(value, substs); | ||
| } | ||
| else | ||
| { | ||
| static assert(0, "Compile-time substitutions must be elements or ranges of the same type of ` ~ Value.stringof ~ `."); | ||
| static assert(0, `Compile-time substitutions must be elements or ranges of the same type of ` ~ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line > 120 |
||
| Value.stringof ~ `.`); | ||
| } | ||
| } | ||
| // Substitute single values with compile-time substitution mappings. | ||
|
|
@@ -4756,47 +4799,6 @@ if (substs.length >= 2 && isExpressions!substs) | |
| } | ||
| } | ||
|
|
||
| // In same combinations substitute needs to calculate the auto-decoded length | ||
| // of its needles | ||
| private template hasDifferentAutodecoding(Range, Needles...) | ||
| { | ||
| import std.meta : anySatisfy; | ||
| /* iff | ||
| - the needles needs auto-decoding, but the incoming range doesn't (or vice versa) | ||
| - both (range, needle) need auto-decoding and don't share the same common type | ||
| */ | ||
| enum needlesAreNarrow = anySatisfy!(isNarrowString, Needles); | ||
| enum sourceIsNarrow = isNarrowString!Range; | ||
| enum hasDifferentAutodecoding = sourceIsNarrow != needlesAreNarrow || | ||
| (sourceIsNarrow && needlesAreNarrow && | ||
| is(CommonType!(Range, Needles) == void)); | ||
| } | ||
|
|
||
| @safe nothrow @nogc pure unittest | ||
| { | ||
| import std.meta : AliasSeq; // used for better clarity | ||
|
|
||
| static assert(!hasDifferentAutodecoding!(string, AliasSeq!(string, string))); | ||
| static assert(!hasDifferentAutodecoding!(wstring, AliasSeq!(wstring, wstring))); | ||
| static assert(!hasDifferentAutodecoding!(dstring, AliasSeq!(dstring, dstring))); | ||
|
|
||
| // the needles needs auto-decoding, but the incoming range doesn't (or vice versa) | ||
| static assert(hasDifferentAutodecoding!(string, AliasSeq!(wstring, wstring))); | ||
| static assert(hasDifferentAutodecoding!(string, AliasSeq!(dstring, dstring))); | ||
| static assert(hasDifferentAutodecoding!(wstring, AliasSeq!(string, string))); | ||
| static assert(hasDifferentAutodecoding!(wstring, AliasSeq!(dstring, dstring))); | ||
| static assert(hasDifferentAutodecoding!(dstring, AliasSeq!(string, string))); | ||
| static assert(hasDifferentAutodecoding!(dstring, AliasSeq!(wstring, wstring))); | ||
|
|
||
| // both (range, needle) need auto-decoding and don't share the same common type | ||
| static foreach (T; AliasSeq!(string, wstring, dstring)) | ||
| { | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(wstring, string))); | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(dstring, string))); | ||
| static assert(hasDifferentAutodecoding!(T, AliasSeq!(wstring, dstring))); | ||
| } | ||
| } | ||
|
|
||
| /// ditto | ||
| auto substitute(alias pred = (a, b) => a == b, R, Substs...)(R r, Substs substs) | ||
| if (isInputRange!R && Substs.length >= 2 && !is(CommonType!(Substs) == void)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1835,6 +1835,7 @@ unittest | |
|
|
||
| enum BigInt test1 = BigInt(123); | ||
| enum BigInt test2 = plusTwo(test1); | ||
| assert(test2 == 125); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10322,7 +10322,6 @@ if (isSomeString!S) | |
| import std.ascii : isDigit; | ||
| import std.conv : to; | ||
| import std.string : representation; | ||
| import core.time; | ||
|
|
||
| if (isoString.empty) | ||
| return Duration.zero; | ||
|
|
@@ -10963,7 +10962,6 @@ version(StdUnittest) | |
|
|
||
| void initializeTests() @safe | ||
| { | ||
| import core.time; | ||
| import std.algorithm.sorting : sort; | ||
| import std.typecons : Rebindable; | ||
| immutable lt = LocalTime().utcToTZ(0); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused imports |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -909,7 +909,8 @@ alias SHA512_256 = SHA!(1024, 256); /// SHA alias for SHA-512/256, hash is ubyte | |
| sha256.put(cast(ubyte[])"abcdef"); | ||
| sha256.start(); | ||
| sha256.put(cast(ubyte[])""); | ||
| assert(sha256.finish() == cast(ubyte[]) hexString!"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); | ||
| assert(sha256.finish() == cast(ubyte[]) | ||
| hexString!"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); | ||
|
|
||
| SHA384 sha384; | ||
| sha384.put(cast(ubyte[])"abcdef"); | ||
|
|
@@ -922,7 +923,8 @@ alias SHA512_256 = SHA!(1024, 256); /// SHA alias for SHA-512/256, hash is ubyte | |
| sha512.put(cast(ubyte[])"abcdef"); | ||
| sha512.start(); | ||
| sha512.put(cast(ubyte[])""); | ||
| assert(sha512.finish() == cast(ubyte[]) hexString!("cf83e1357eefb8bdf1542850d66d8007d620e4050b571" | ||
| assert(sha512.finish() == cast(ubyte[]) | ||
| hexString!("cf83e1357eefb8bdf1542850d66d8007d620e4050b571" | ||
| ~"5dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e")); | ||
|
|
||
| SHA512_224 sha512_224; | ||
|
|
@@ -935,7 +937,8 @@ alias SHA512_256 = SHA!(1024, 256); /// SHA alias for SHA-512/256, hash is ubyte | |
| sha512_256.put(cast(ubyte[])"abcdef"); | ||
| sha512_256.start(); | ||
| sha512_256.put(cast(ubyte[])""); | ||
| assert(sha512_256.finish() == cast(ubyte[]) hexString!"c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a"); | ||
| assert(sha512_256.finish() == cast(ubyte[]) | ||
| hexString!"c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long lines |
||
|
|
||
| digest = sha1Of (""); | ||
| digest224 = sha224Of (""); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: DScanner doesn't seem to be super stable, so imho it's better to keep running it within GDB for a while. The overhead isn't too big and we have done so for the last two months.