Skip to content

RCS1260 - "omit_when_single_line" should check if braces are on single line #1675

@francescodente

Description

@francescodente

When configuring rule RCS1260 (Add/remove trailing comma) using the option "omit_when_single_line", the analyzer emits warnings in the following case:

var foo = new Foo
{
    Bar = 1,
};

meaning that the condition used to determine if an object is defined "in a single line" is if there is only one property.

In my opinion, the condition should be that the curly braces are on the same line, in order to produce the following behavior:

// Correct
var foo = new Foo
{
    Bar = 1,
};

// Correct
var foo = new Foo { Bar = 1 };

// Warning
var foo = new Foo
{
    Bar = 1
};

// Warning
var foo = new Foo { Bar = 1, };

If the current behavior is still desirable for some users, having another option to support the one described above should be enough.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions