Skip to content
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

Fix D-Scanner linting issues #9070

Merged
merged 5 commits into from
Oct 27, 2024
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
2 changes: 1 addition & 1 deletion std/algorithm/comparison.d
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ template among(values...)
if (isExpressionTuple!values)
{
uint among(Value)(Value value)
if (!is(CommonType!(Value, values) == void))
if (!is(CommonType!(Value, values) == void))
{
switch (value)
{
Expand Down
9 changes: 6 additions & 3 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ if (fun.length >= 1)
A range with each fun applied to all the elements. If there is more than one
fun, the element type will be `Tuple` containing one element for each fun.
*/
auto map(Range)(Range r) if (isInputRange!(Unqual!Range))
auto map(Range)(Range r)
if (isInputRange!(Unqual!Range))
{
import std.meta : AliasSeq, staticMap;

Expand Down Expand Up @@ -1308,7 +1309,8 @@ if (is(typeof(unaryFun!predicate)))
A range containing only elements `x` in `range` for
which `predicate(x)` returns `true`.
*/
auto filter(Range)(Range range) if (isInputRange!(Unqual!Range))
auto filter(Range)(Range range)
if (isInputRange!(Unqual!Range))
{
return FilterResult!(unaryFun!predicate, Range)(range);
}
Expand Down Expand Up @@ -1545,7 +1547,8 @@ template filterBidirectional(alias pred)
Returns:
A range containing only the elements in `r` for which `pred` returns `true`.
*/
auto filterBidirectional(Range)(Range r) if (isBidirectionalRange!(Unqual!Range))
auto filterBidirectional(Range)(Range r)
if (isBidirectionalRange!(Unqual!Range))
{
return FilterBidiResult!(unaryFun!pred, Range)(r);
}
Expand Down
9 changes: 6 additions & 3 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -3701,7 +3701,8 @@ if (isDynamicArray!A)
* Params:
* item = the single item to append
*/
void put(U)(U item) if (canPutItem!U)
void put(U)(U item)
if (canPutItem!U)
{
static if (isSomeChar!T && isSomeChar!U && T.sizeof < U.sizeof)
{
Expand Down Expand Up @@ -3730,7 +3731,8 @@ if (isDynamicArray!A)
}

// Const fixing hack.
void put(Range)(Range items) if (canPutConstRange!Range)
void put(Range)(Range items)
if (canPutConstRange!Range)
{
alias p = put!(Unqual!Range);
p(items);
Expand All @@ -3743,7 +3745,8 @@ if (isDynamicArray!A)
* Params:
* items = the range of items to append
*/
void put(Range)(Range items) if (canPutRange!Range)
void put(Range)(Range items)
if (canPutRange!Range)
{
// note, we disable this branch for appending one type of char to
// another because we can't trust the length portion.
Expand Down
69 changes: 41 additions & 28 deletions std/base64.d
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
/**
* ditto
*/
char[] encode(R1, R2)(R1 source, R2 buffer) if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : ubyte) && hasLength!R1 &&
is(R2 == char[]))
char[] encode(R1, R2)(R1 source, R2 buffer)
if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : ubyte) && hasLength!R1 &&
is(R2 == char[]))
in
{
assert(buffer.length >= encodeLength(source.length), "Insufficient buffer for encoding");
Expand Down Expand Up @@ -474,8 +475,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
size_t encode(R1, R2)(R1 source, auto ref R2 range)
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : ubyte) &&
hasLength!R1 && !is(R2 == char[]) && isOutputRange!(R2, char))
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : ubyte) &&
hasLength!R1 && !is(R2 == char[]) && isOutputRange!(R2, char))
{
immutable srcLen = source.length;
if (srcLen == 0)
Expand Down Expand Up @@ -559,7 +560,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* A newly-allocated `char[]` buffer containing the encoded string.
*/
@safe
pure char[] encode(Range)(Range source) if (isArray!Range && is(ElementType!Range : ubyte))
pure char[] encode(Range)(Range source)
if (isArray!Range && is(ElementType!Range : ubyte))
{
return encode(source, new char[encodeLength(source.length)]);
}
Expand All @@ -575,8 +577,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
/**
* ditto
*/
char[] encode(Range)(Range source) if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : ubyte) && hasLength!Range)
char[] encode(Range)(Range source)
if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : ubyte) && hasLength!Range)
{
return encode(source, new char[encodeLength(source.length)]);
}
Expand All @@ -592,8 +595,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Note: This struct is not intended to be created in user code directly;
* use the $(LREF encoder) function instead.
*/
struct Encoder(Range) if (isInputRange!Range && (is(ElementType!Range : const(ubyte)[]) ||
is(ElementType!Range : const(char)[])))
struct Encoder(Range)
if (isInputRange!Range && (is(ElementType!Range : const(ubyte)[]) ||
is(ElementType!Range : const(char)[])))
{
private:
Range range_;
Expand Down Expand Up @@ -702,7 +706,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Note: This struct is not intended to be created in user code directly;
* use the $(LREF encoder) function instead.
*/
struct Encoder(Range) if (isInputRange!Range && is(ElementType!Range : ubyte))
struct Encoder(Range)
if (isInputRange!Range && is(ElementType!Range : ubyte))
{
private:
Range range_;
Expand Down Expand Up @@ -884,7 +889,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* }
* -----
*/
Encoder!(Range) encoder(Range)(Range range) if (isInputRange!Range)
Encoder!(Range) encoder(Range)(Range range)
if (isInputRange!Range)
{
return typeof(return)(range);
}
Expand Down Expand Up @@ -981,8 +987,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* base alphabet of the current Base64 encoding scheme.
*/
@trusted
pure ubyte[] decode(R1, R2)(in R1 source, return scope R2 buffer) if (isArray!R1 && is(ElementType!R1 : dchar) &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
pure ubyte[] decode(R1, R2)(in R1 source, return scope R2 buffer)
if (isArray!R1 && is(ElementType!R1 : dchar) &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
in
{
assert(buffer.length >= realDecodeLength(source), "Insufficient buffer for decoding");
Expand Down Expand Up @@ -1065,9 +1072,10 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
/**
* ditto
*/
ubyte[] decode(R1, R2)(R1 source, R2 buffer) if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : dchar) && hasLength!R1 &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
ubyte[] decode(R1, R2)(R1 source, R2 buffer)
if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : dchar) && hasLength!R1 &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
in
{
assert(buffer.length >= decodeLength(source.length), "Insufficient buffer for decoding");
Expand Down Expand Up @@ -1156,8 +1164,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* base alphabet of the current Base64 encoding scheme.
*/
size_t decode(R1, R2)(in R1 source, auto ref R2 range)
if (isArray!R1 && is(ElementType!R1 : dchar) &&
!is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
if (isArray!R1 && is(ElementType!R1 : dchar) &&
!is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
out(result)
{
immutable expect = realDecodeLength(source);
Expand Down Expand Up @@ -1244,8 +1252,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
size_t decode(R1, R2)(R1 source, auto ref R2 range)
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : dchar) &&
hasLength!R1 && !is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : dchar) &&
hasLength!R1 && !is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
out(result)
{
// @@@BUG@@@ Workaround for DbC problem.
Expand Down Expand Up @@ -1334,7 +1342,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* A newly-allocated `ubyte[]` buffer containing the decoded string.
*/
@safe
pure ubyte[] decode(Range)(Range source) if (isArray!Range && is(ElementType!Range : dchar))
pure ubyte[] decode(Range)(Range source)
if (isArray!Range && is(ElementType!Range : dchar))
{
return decode(source, new ubyte[decodeLength(source.length)]);
}
Expand All @@ -1350,8 +1359,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
/**
* ditto
*/
ubyte[] decode(Range)(Range source) if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : dchar) && hasLength!Range)
ubyte[] decode(Range)(Range source)
if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : dchar) && hasLength!Range)
{
return decode(source, new ubyte[decodeLength(source.length)]);
}
Expand All @@ -1367,8 +1377,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Note: This struct is not intended to be created in user code directly;
* use the $(LREF decoder) function instead.
*/
struct Decoder(Range) if (isInputRange!Range && (is(ElementType!Range : const(char)[]) ||
is(ElementType!Range : const(ubyte)[])))
struct Decoder(Range)
if (isInputRange!Range && (is(ElementType!Range : const(char)[]) ||
is(ElementType!Range : const(ubyte)[])))
{
private:
Range range_;
Expand Down Expand Up @@ -1492,7 +1503,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* Note: This struct is not intended to be created in user code directly;
* use the $(LREF decoder) function instead.
*/
struct Decoder(Range) if (isInputRange!Range && is(ElementType!Range : char))
struct Decoder(Range)
if (isInputRange!Range && is(ElementType!Range : char))
{
private:
Range range_;
Expand Down Expand Up @@ -1683,7 +1695,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* }
* -----
*/
Decoder!(Range) decoder(Range)(Range range) if (isInputRange!Range)
Decoder!(Range) decoder(Range)(Range range)
if (isInputRange!Range)
{
return typeof(return)(range);
}
Expand Down
Loading
Loading