Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dscanner.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ allman_braces_check="enabled"
redundant_attributes_check="enabled"
; Check for public declarations without a documented unittest
has_public_example="enabled"
; Check for asserts without an explanatory message
assert_without_msg="skip-unittest"

; Configure which modules are checked with a specific checker
; Please help to extend these checks onto more Phobos modules
Expand All @@ -111,6 +113,8 @@ alias_syntax_check="-std.traits,-std.typecons"
allman_braces_check="+disabled"
; Checks for confusing code in inline asm statements
asm_style_check="-std.math"
; Check for asserts without an explanatory message
assert_without_msg="-etc.c.SQL_,-std.algorithm.comparison,-std.algorithm.iteration,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.concurrency,-std.container,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.systime,-std.datetime.timezone,-std.digest.digest,-std.digest.murmurhash,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.null_allocator,-std.experimental.allocator.building_blocks.quantizer,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.building_blocks.scoped_allocator,-std.experimental.allocator.common,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.mmap_allocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.gammafunction,-std.internal.scopebuffer,-std.math,-std.mathspecial,-std.mmfile,-std.net.curl,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.xml"
; Checks for assignment to auto-ref function parameters
auto_ref_assignment_check="-std.algorithm.mutation,-std.format,-std.typecons"
; Checks for variables that could be declared immutable
Expand Down
4 changes: 2 additions & 2 deletions std/algorithm/comparison.d
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ auto clamp(T1, T2, T3)(T1 val, T2 lower, T3 upper)
in
{
import std.functional : greaterThan;
assert(!lower.greaterThan(upper));
assert(!lower.greaterThan(upper), "Lower can't be greater than upper.");
}
do
{
Expand Down Expand Up @@ -732,7 +732,7 @@ Compares two ranges for equality, as defined by predicate $(D pred)
template equal(alias pred = "a == b")
{
enum isEmptyRange(R) =
isInputRange!R && __traits(compiles, {static assert(R.empty);});
isInputRange!R && __traits(compiles, {static assert(R.empty, "");});

enum hasFixedLength(T) = hasLength!T || isNarrowString!T;

Expand Down
8 changes: 4 additions & 4 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ if (isInputRange!InputRange && isForwardRange!ForwardRange)
}
else
{
assert(front.empty);
assert(front.empty, "Expected front to be empty");
// Left side was shorter. Let's step into the back.
static if (is(InputRange == Take!ForwardRange))
{
Expand Down Expand Up @@ -1528,7 +1528,7 @@ private InputRange2 moveAllImpl(alias moveOp, InputRange1, InputRange2)(
&& hasSlicing!InputRange2 && isRandomAccessRange!InputRange2)
{
auto toMove = src.length;
assert(toMove <= tgt.length);
assert(toMove <= tgt.length, "Source buffer needs to be smaller or equal to the target buffer.");
foreach (idx; 0 .. toMove)
moveOp(src[idx], tgt[idx]);
return tgt[toMove .. tgt.length];
Expand All @@ -1537,7 +1537,7 @@ private InputRange2 moveAllImpl(alias moveOp, InputRange1, InputRange2)(
{
for (; !src.empty; src.popFront(), tgt.popFront())
{
assert(!tgt.empty);
assert(!tgt.empty, "Source buffer needs to be smaller or equal to the target buffer.");
moveOp(src.front, tgt.front);
}
return tgt;
Expand Down Expand Up @@ -1849,7 +1849,7 @@ if (s != SwapStrategy.stable
break;
}
// Advance to next blackout on the left
assert(blackouts[left].pos >= tgtPos);
assert(blackouts[left].pos >= tgtPos, "Next blackout on the left shouldn't appear before the target.");
tgt.popFrontExactly(blackouts[left].pos - tgtPos);
tgtPos = blackouts[left].pos;

Expand Down
4 changes: 2 additions & 2 deletions std/digest/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ if (isDigest!T) : Digest
nothrow ubyte[] finish(ubyte[] buf)
in
{
assert(buf.length >= this.length);
assert(buf.length >= this.length, "Given buffer is smaller than the local buffer.");
}
do
{
Expand Down Expand Up @@ -967,7 +967,7 @@ if (isDigest!T) : Digest
@trusted ubyte[] peek(ubyte[] buf) const
in
{
assert(buf.length >= this.length);
assert(buf.length >= this.length, "Given buffer is smaller than the local buffer.");
}
do
{
Expand Down
2 changes: 1 addition & 1 deletion std/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ string toJSON(const ref JSONValue root, in bool pretty = false, in JSONOptions o
// Make sure we do UTF decoding iff we want to
// escape Unicode characters.
assert(((options & JSONOptions.escapeNonAsciiChars) != 0)
== is(Char == dchar));
== is(Char == dchar), "JSONOptions.escapeNonAsciiChars needs dchar strings");

with (JSONOptions) if (isControl(c) ||
((options & escapeNonAsciiChars) >= escapeNonAsciiChars && c >= 0x80))
Expand Down
4 changes: 2 additions & 2 deletions std/zip.d
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ final class ZipArchive
import std.zlib : crc32;
() @trusted { de._crc32 = crc32(0, cast(void[]) de._expandedData); }();
}
assert(de._compressedData.length == de._compressedSize);
assert(de._compressedData.length == de._compressedSize, "Archive member compressed failed.");
}

/** Delete de from the archive.
Expand Down Expand Up @@ -543,7 +543,7 @@ final class ZipArchive
i += 22;

// Write archive comment
assert(i + comment.length == data.length);
assert(i + comment.length == data.length, "Writing the archive comment failed.");
_data[i .. data.length] = (cast(ubyte[]) comment)[];

return cast(void[]) data;
Expand Down
15 changes: 8 additions & 7 deletions std/zlib.d
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ uint crc32(uint crc, const(void)[] buf)
ubyte[] compress(const(void)[] srcbuf, int level)
in
{
assert(-1 <= level && level <= 9);
assert(-1 <= level && level <= 9, "Compression level needs to be within [-1, 9].");
}
do
{
Expand Down Expand Up @@ -276,7 +276,7 @@ void[] uncompress(const(void)[] srcbuf, size_t destlen = 0u, int winbits = 15)
throw new ZlibException(err);
}
}
assert(0);
assert(0, "Unreachable code");
}

@system unittest
Expand Down Expand Up @@ -370,7 +370,7 @@ class Compress
this(int level, HeaderFormat header = HeaderFormat.deflate)
in
{
assert(1 <= level && level <= 9);
assert(1 <= level && level <= 9, "Legal compression level are in [1, 9].");
}
do
{
Expand Down Expand Up @@ -461,7 +461,8 @@ class Compress
void[] flush(int mode = Z_FINISH)
in
{
assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH);
assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH,
"Mode must be either Z_FINISH, Z_SYNC_FLUSH or Z_FULL_FLUSH.");
}
do
{
Expand Down Expand Up @@ -572,7 +573,7 @@ class UnCompress
const(void)[] uncompress(const(void)[] buf)
in
{
assert(!done);
assert(!done, "Buffer has been flushed.");
}
do
{
Expand Down Expand Up @@ -752,11 +753,11 @@ class UnCompress
void[] flush()
in
{
assert(!done);
assert(!done, "Buffer has been flushed before.");
}
out
{
assert(done);
assert(done, "Flushing failed.");
}
do
{
Expand Down