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

Update documentation for SA1413 to include rationale #2418

Merged
merged 2 commits into from
Jun 16, 2017
Merged
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
14 changes: 12 additions & 2 deletions documentation/SA1413.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@

## Cause

The last statement in a multi-line C# initializer is missing a trailing comma.
The last statement in a multi-line C# initializer or list is missing a trailing comma.

### Rationale

This rule is specifically designed to work well with the most widely used source control systems as an aid to long-term
code review. By placing a comma on the last line of a multi-line sequence, developers who append an item to the list or
reorder the list at some point in the future will not need to modify any more lines than absolutely necessary for the
change. As a result, the size of the subsequent code review is minimized and focused, and tools like **git blame**
continue to show the original author and commit for the item that was previously last in the list.

## Rule description

A violation of this rule occurs when the last statement of a C# initializer is missing a trailing comma.
A violation of this rule occurs when the last statement of a C# initializer or list is missing a trailing comma.

For example, the following code would generate one instance of this violation:

Expand All @@ -47,6 +55,8 @@ var x = new Barnacle
};
```

This diagnostic is also reported for other forms of comma-separated list, such as enum members.

## How to fix violations

To fix a violation of this rule, add a trailing comma to the last statement in the initializer.
Expand Down