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

Placate a bunch of Allman style violation for #8805 #8817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions std/base64.d
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,8 @@ class Base64Exception : Exception
// Verify that any existing workaround that uses & still works.
InputRange ir2;
OutputRange or2;
() @trusted {
() @trusted
{
Comment on lines +2063 to +2064
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifically I don't like this type of change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely looks more correct for allman style, would not remove this from D-Scanner but possibly add some kind of config for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great, thanks!

assert(Base64.encode(ir2, &or2) == 8);
}();
assert(or2.result == "Gis8TV1u");
Expand Down Expand Up @@ -2092,7 +2093,8 @@ class Base64Exception : Exception
// Verify that any existing workaround that uses & still works.
InputRange ir2;
OutputRange or2;
() @trusted {
() @trusted
{
assert(Base64.decode(ir2, &or2) == 6);
}();
assert(or2.result == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]);
Expand Down
3 changes: 2 additions & 1 deletion std/bigint.d
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,8 @@ unittest
// https://issues.dlang.org/show_bug.cgi?id=6850
@safe unittest
{
pure long pureTest() {
pure long pureTest()
{
BigInt a = 1;
BigInt b = 1336;
a += b;
Expand Down
21 changes: 14 additions & 7 deletions std/bitmanip.d
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ unittest
// https://issues.dlang.org/show_bug.cgi?id=6686
@safe unittest
{
union S {
union S
{
ulong bits = ulong.max;
mixin (bitfields!(
ulong, "back", 31,
Expand Down Expand Up @@ -509,7 +510,8 @@ unittest
@safe unittest
{
{
static struct Integrals {
static struct Integrals
{
bool checkExpectations(bool eb, int ei, short es) { return b == eb && i == ei && s == es; }

mixin(bitfields!(
Expand All @@ -531,7 +533,8 @@ unittest

//https://issues.dlang.org/show_bug.cgi?id=8876
{
struct MoreIntegrals {
struct MoreIntegrals
{
bool checkExpectations(uint eu, ushort es, uint ei) { return u == eu && s == es && i == ei; }

mixin(bitfields!(
Expand All @@ -554,7 +557,8 @@ unittest

enum A { True, False }
enum B { One, Two, Three, Four }
static struct Enums {
static struct Enums
{
bool checkExpectations(A ea, B eb) { return a == ea && b == eb; }

mixin(bitfields!(
Expand Down Expand Up @@ -609,7 +613,8 @@ unittest
// https://issues.dlang.org/show_bug.cgi?id=15305
@safe unittest
{
struct S {
struct S
{
mixin(bitfields!(
bool, "alice", 1,
ulong, "bob", 63,
Expand Down Expand Up @@ -659,7 +664,8 @@ Following arguments works the same way as `bitfield`'s. The bitfield must fit in
bits known to be zero because of the pointer alignment.
*/

template taggedPointer(T : T*, string name, Ts...) {
template taggedPointer(T : T*, string name, Ts...)
{
enum taggedPointer = createTaggedReference!(T*, T.alignof, name, Ts);
}

Expand Down Expand Up @@ -767,7 +773,8 @@ if (is(T == class))
Object, "a",
uint, "b", 4)));

struct S {
struct S
{
mixin(taggedClassRef!(
Object, "a",
bool, "b", 1));
Expand Down
8 changes: 6 additions & 2 deletions std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ if (!(is(S : T) &&
else static if (isPointer!S && isSomeChar!(PointerTarget!S))
{
// This is unsafe because we cannot guarantee that the pointer is null terminated.
return () @system {
return () @system
{
static if (is(S : const(char)*))
import core.stdc.string : strlen;
else
Expand Down Expand Up @@ -1208,7 +1209,8 @@ if (!(is(S : T) &&
*/
private template isSwitchable(E)
{
enum bool isSwitchable = is(typeof({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I really don't like this type of change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this looks like a bug in D-Scanner

enum bool isSwitchable = is(typeof(
{
switch (E.init) { default: }
}));
}
Expand Down Expand Up @@ -2786,12 +2788,14 @@ Lerr:
assertCTFEable!({ string s = "-1234abc"; assert(parse! int(s) == -1234 && s == "abc"); });
assertCTFEable!({ string s = "1234abc"; assert(parse!uint(s) == 1234 && s == "abc"); });

//dfmt off
assertCTFEable!({ string s = "1234abc"; assert(parse!( int, string, Yes.doCount)(s) ==
tuple( 1234, 4) && s == "abc"); });
assertCTFEable!({ string s = "-1234abc"; assert(parse!( int, string, Yes.doCount)(s) ==
tuple(-1234, 5) && s == "abc"); });
assertCTFEable!({ string s = "1234abc"; assert(parse!(uint, string, Yes.doCount)(s) ==
tuple( 1234 ,4) && s == "abc"); });
//dfmt on
}

// https://issues.dlang.org/show_bug.cgi?id=13931
Expand Down
3 changes: 2 additions & 1 deletion std/digest/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ ref T[N] asArray(size_t N, T)(ref T[] source, string errorMsg = "")
* Fill in a preallocated buffer with the ASCII hex representation from a byte buffer
*/
private void toHexStringImpl(Order order, LetterCase letterCase, BB, HB)
(scope const ref BB byteBuffer, ref HB hexBuffer){
(scope const ref BB byteBuffer, ref HB hexBuffer)
{
static if (letterCase == LetterCase.upper)
{
import std.ascii : hexDigits = hexDigits;
Expand Down
9 changes: 6 additions & 3 deletions std/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ private noreturn bailOut(E : Throwable = Exception)(string file, size_t line, sc
{
static int g;
~this() {} // impure & unsafe destructor
bool opCast(T:bool)() {
bool opCast(T:bool)()
{
int* p = cast(int*) 0; // unsafe operation
int n = g; // impure operation
return true;
Expand Down Expand Up @@ -1460,7 +1461,8 @@ version (StdUnittest)
assert(mayPointTo(voidArr, a)); // slice-contiaining void[N] might point at anything
assert(mayPointTo(voidArr, b));

static assert(() {
static assert(()
{
void[16] arr1 = void;
void[size_t.sizeof] arr2 = void;
int var;
Expand Down Expand Up @@ -2331,7 +2333,8 @@ pure nothrow @safe unittest

auto save = f.handle!(Exception,
RangePrimitive.save,
function(Exception e, ref ThrowingRange r) {
function(Exception e, ref ThrowingRange r)
{
return ThrowingRange();
})();

Expand Down
3 changes: 2 additions & 1 deletion std/experimental/allocator/building_blocks/affix_allocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ version (StdUnittest)
import std.experimental.allocator.building_blocks.bitmapped_block
: BitmappedBlock;
import std.experimental.allocator.common : testAllocator;
testAllocator!({
testAllocator!(
{
auto a = AffixAllocator!(BitmappedBlock!128, ulong, ulong)
(BitmappedBlock!128(new ubyte[128 * 4096]));
return a;
Expand Down
3 changes: 2 additions & 1 deletion std/experimental/allocator/building_blocks/bitmapped_block.d
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,8 @@ pure @safe unittest
import std.typecons : Ternary;

auto a = (() @trusted => BitmappedBlock!(64, 64, NullAllocator, Yes.multiblock)(new ubyte[10_240]))();
() nothrow @nogc {
() nothrow @nogc
{
assert(a.empty == Ternary.yes);
const b = a.allocate(100);
assert(b.length == 100);
Expand Down
3 changes: 2 additions & 1 deletion std/experimental/allocator/building_blocks/free_list.d
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ struct FreeList(ParentAllocator,
import std.experimental.allocator.building_blocks.stats_collector
: StatsCollector, Options;

struct StatsCollectorWrapper {
struct StatsCollectorWrapper
{
~this()
{
// buf2 should still be around and buf1 deallocated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ it actually returns memory to the operating system when possible.
from the garbage-collected heap. Each block is organized as a KR-style
heap. More blocks are allocated and freed on a need basis.
*/
AllocatorList!((n) {
AllocatorList!((n)
{
auto result = KRRegion!MmapAllocator(max(n * 2, 1024 * 1024));
return result;
}) alloc;
Expand Down
3 changes: 1 addition & 2 deletions std/experimental/allocator/building_blocks/stats_collector.d
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ public:
import std.array : array;
import std.range : repeat;

static PerCallStatistics s = { f, n, [ opts ],
repeat(0UL, opts.length).array };
static PerCallStatistics s = { f, n, [ opts ], repeat(0UL, opts.length).array };
static bool inserted;

if (!inserted)
Expand Down
19 changes: 13 additions & 6 deletions std/experimental/allocator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,8 @@ private ref RCIAllocator setupThreadAllocator()
assert(_threadAllocator.isNull);
import core.lifetime : emplace;
static ulong[stateSize!(ThreadAllocator).divideRoundUp(ulong.sizeof)] _threadAllocatorState;
() @trusted {
() @trusted
{
_threadAllocator = RCIAllocator(emplace!(ThreadAllocator)(_threadAllocatorState[], processAllocator()));
}();
return _threadAllocator;
Expand Down Expand Up @@ -1375,9 +1376,13 @@ nothrow @safe @nogc unittest
cast(void) Mallocator.instance.make!Pure(0);

static int g = 0;
static struct Impure { this(int) nothrow @nogc @safe {
g++;
} }
static struct Impure
{
this(int) nothrow @nogc @safe
{
g++;
}
}
static assert(!__traits(compiles, cast(void) Mallocator.instance.make!Impure(0)));
}

Expand Down Expand Up @@ -2047,7 +2052,8 @@ if (isInputRange!R && !isInfinite!R)
int val;
@disable this();

this(int b){
this(int b)
{
this.val = i++;
}

Expand Down Expand Up @@ -3743,7 +3749,8 @@ unittest

foreach (b; allox)
{
() pure nothrow @safe {
() pure nothrow @safe
{
void[] p;
Ternary r = (() @nogc => a.resolveInternalPointer(&b[0], p))();
assert(&p[0] == &b[0] && p.length >= b.length);
Expand Down
16 changes: 8 additions & 8 deletions std/format/internal/write.d
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ if (is(IntegralTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
if (f.spec == 'r')
{
// raw write, skip all else and write the thing
auto raw = (ref val) @trusted {
return (cast(const char*) &val)[0 .. val.sizeof];
}(val);
auto raw = (ref val) @trusted { return (cast(const char*) &val)[0 .. val.sizeof]; }(val);
import std.range.primitives : put;
if (needToSwapEndianess(f))
foreach_reverse (c; raw)
Expand Down Expand Up @@ -580,9 +578,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
if (spec == 'r')
{
// raw write, skip all else and write the thing
auto raw = (ref val) @trusted {
return (cast(const char*) &val)[0 .. val.sizeof];
}(val);
auto raw = (ref val) @trusted { return (cast(const char*) &val)[0 .. val.sizeof]; }(val);

if (needToSwapEndianess(f))
{
Expand Down Expand Up @@ -1840,7 +1836,8 @@ template hasToString(T, Char)
enum hasToString = HasToStringResult.none;
}
else static if (is(typeof(
(T val) {
(T val)
{
const FormatSpec!Char f;
static struct S {void put(scope Char s){}}
S s;
Expand All @@ -1854,7 +1851,8 @@ template hasToString(T, Char)
enum hasToString = HasToStringResult.customPutWriterFormatSpec;
}
else static if (is(typeof(
(T val) {
(T val)
{
static struct S {void put(scope Char s){}}
S s;
val.toString(s);
Expand Down Expand Up @@ -2206,6 +2204,7 @@ if (hasToString!(T, Char))
static union UF2 { string toString() { return ""; } }
static class CF2 { override string toString() { return ""; } }

//dfmt off
static interface IK1 { void toString(scope void delegate(scope const(char)[]) sink,
FormatSpec!char) const; }
static class CIK1 : IK1 { override void toString(scope void delegate(scope const(char)[]) sink,
Expand All @@ -2219,6 +2218,7 @@ if (hasToString!(T, Char))
static class KC1 { void toString(scope void delegate(scope const(char)[]) sink,
FormatSpec!char) const { sink("KC1"); } }

//dfmt on
IF1 cif1 = new CIF1;
assertThrown!FormatException(format("%f", cif1));
assertThrown!FormatException(format("%f", SF1()));
Expand Down
3 changes: 2 additions & 1 deletion std/format/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,8 @@ if (isSomeString!(typeof(fmt)))
assert(sformat(buf[], "foo%%") == "foo%");
assert(sformat(buf[], "foo%s", 'C') == "fooC");
assert(sformat(buf[], "%s foo", "bar") == "bar foo");
() @trusted {
() @trusted
{
assertThrown!RangeError(sformat(buf[], "%s foo %s", "bar", "abc"));
} ();
assert(sformat(buf[], "foo %d", -123) == "foo -123");
Expand Down
3 changes: 2 additions & 1 deletion std/format/write.d
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,8 @@ void formatValue(Writer, T, Char)(auto ref Writer w, auto ref T val, scope const
@safe pure unittest
{
static enum State: ubyte { INACTIVE }
static struct S {
static struct S
{
State state = State.INACTIVE;
int generation = 1;
alias state this;
Expand Down
12 changes: 8 additions & 4 deletions std/getopt.d
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ GetoptResult getopt(T...)(ref string[] args, T opts)
You can pass them to `getopt` in any position, except in between an option
string and its bound pointer.
*/
enum config {
enum config
{
/// Turn case sensitivity on
caseSensitive,
/// Turn case sensitivity off (default)
Expand All @@ -485,14 +486,16 @@ enum config {

`helpWanted` is set if the option `--help` or `-h` was passed to the option parser.
*/
struct GetoptResult {
struct GetoptResult
{
bool helpWanted; /// Flag indicating if help was requested
Option[] options; /// All possible options
}

/** Information about an option.
*/
struct Option {
struct Option
{
string optShort; /// The short symbol for this option
string optLong; /// The long symbol for this option
string help; /// The description of this option
Expand Down Expand Up @@ -1485,7 +1488,8 @@ private void setConfig(ref configuration cfg, config option) @safe pure nothrow
{
import std.exception;

enum Foo {
enum Foo
{
bar,
baz
}
Expand Down
Loading
Loading