Skip to content

Commit 021e24d

Browse files
committed
Update .editorconfig with IDE rules
1 parent 027ff4e commit 021e24d

File tree

3 files changed

+135
-6
lines changed

3 files changed

+135
-6
lines changed

.editorconfig

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ insert_final_newline = true
1010
[*.{cs}]
1111
indent_size = 4
1212
trim_trailing_whitespace = true
13+
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
1314
csharp_space_before_open_square_brackets = true
1415
csharp_space_after_keywords_in_control_flow_statements = true
1516
csharp_space_before_open_square_brackets = false
17+
csharp_style_expression_bodied_constructors = when_on_single_line
18+
csharp_style_expression_bodied_methods = when_on_single_line
19+
csharp_style_expression_bodied_operators = when_on_single_line
20+
csharp_style_expression_bodied_properties = true
21+
csharp_style_expression_bodied_indexers = true
22+
csharp_style_expression_bodied_accessors = true
23+
csharp_style_expression_bodied_lambdas = when_on_single_line
1624

1725
# CS0168: The variable 'var' is declared but never used
1826
dotnet_diagnostic.CS0168.severity = error
@@ -22,6 +30,8 @@ dotnet_diagnostic.CS0169.severity = error
2230
dotnet_diagnostic.CS0219.severity = error
2331
# CS0414: The private field 'field' is assigned but its value is never used
2432
dotnet_diagnostic.CS0414.severity = error
33+
# CA1067: Should override Equals because it implements IEquatable<T>
34+
dotnet_diagnostic.CA1067.severity = silent
2535
# CA1068: CancellationToken parameters must come last
2636
dotnet_diagnostic.CA1068.severity = error
2737
# CA1822: Mark members as static
@@ -32,6 +42,8 @@ dotnet_diagnostic.CA1823.severity = error
3242
dotnet_diagnostic.CA2007.severity = error
3343
# CA2016: Forward the CancellationToken parameter to methods that take one
3444
dotnet_diagnostic.CA2016.severity = error
45+
# CA2254: The logging message template should not vary between calls to 'LoggerExtensions.*'
46+
dotnet_diagnostic.CA2254.severity = silent
3547

3648
# TODO: Enable all maintainability issues (dead code etc.) and enforce
3749
# See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
@@ -40,26 +52,30 @@ dotnet_analyzer_diagnostic.category-Maintainability.severity = error
4052
# TODO: Fix all of these issues and explicitly ignore the intentional ones!
4153

4254
# CA2016: Forward the CancellationToken parameter to methods that take one
43-
dotnet_diagnostic.CA2016.severity = suggestion
55+
dotnet_diagnostic.CA2016.severity = error
4456
# CS0618: A class member was marked with the Obsolete attribute
4557
dotnet_diagnostic.CS0618.severity = suggestion
4658
# CS0649: Uninitialized private or internal field declaration that is never assigned a value
47-
dotnet_diagnostic.CS0649.severity = suggestion
59+
dotnet_diagnostic.CS0649.severity = warning
4860
# CS1998: This async method lacks 'await' operators and will run synchronously
4961
dotnet_diagnostic.CS1998.severity = suggestion
5062
# CS4014: Consider applying the await operator to the result of the call
5163
dotnet_diagnostic.CS4014.severity = suggestion
5264

5365
# RCS1102: Make class static
54-
dotnet_diagnostic.RCS1102.severity = suggestion
66+
dotnet_diagnostic.RCS1102.severity = warning
5567
# RCS1139: Add summary element to documentation comment
5668
dotnet_diagnostic.RCS1139.severity = suggestion
5769
# RCS1194: Implement exception constructors
5870
dotnet_diagnostic.RCS1194.severity = suggestion
5971
# RCS1210: Return completed task instead of returning null
6072
dotnet_diagnostic.RCS1210.severity = suggestion
73+
# RCS1036: Remove unnecessary blank line
74+
dotnet_diagnostic.RCS1036.severity = warning
6175
# RCS1075: Avoid empty catch clause that catches System.Exception
6276
dotnet_diagnostic.RCS1075.severity = suggestion
77+
# RCS1170: Use read-only auto-implemented property
78+
dotnet_diagnostic.RCS1170.severity = warning
6379

6480
# VSTHRD002: Avoid problematic synchronous waits
6581
dotnet_diagnostic.VSTHRD002.severity = suggestion
@@ -79,9 +95,118 @@ dotnet_diagnostic.VSTHRD114.severity = suggestion
7995
dotnet_diagnostic.VSTHRD200.severity = suggestion
8096

8197
# xUnit2013: Do not use equality check to check for collection size
82-
dotnet_diagnostic.xUnit2013.severity = suggestion
83-
# IDE0003: this and Me preferences
84-
dotnet_diagnostic.IDE0003.severity = suggestion
98+
dotnet_diagnostic.xUnit2013.severity = warning
99+
# xUnit1004: Test methods should not be skipped
100+
dotnet_diagnostic.xUnit1004.severity = suggestion
101+
102+
# IDE0001: Simplify name
103+
dotnet_diagnostic.IDE0001.severity = warning
104+
# IDE0002: Simplify member access
105+
dotnet_diagnostic.IDE0001.severity = warning
106+
# IDE0003: Remove this or Me qualification
107+
dotnet_diagnostic.IDE0003.severity = warning
108+
# IDE0004: Remove unnecessary cast
109+
dotnet_diagnostic.IDE0004.severity = warning
110+
# IDE0005: Remove unnecessary import
111+
dotnet_diagnostic.IDE0005.severity = suggestion
112+
# IDE0008: Use explicit type instead of var
113+
dotnet_diagnostic.IDE0008.severity = warning
114+
# IDE0011: Add braces
115+
dotnet_diagnostic.IDE0011.severity = warning
116+
# IDE0016: Use throw expression
117+
dotnet_diagnostic.IDE0016.severity = warning
118+
# IDE0017: Use object initializers
119+
dotnet_diagnostic.IDE0017.severity = warning
120+
# IDE0018: Inline variable declaration
121+
dotnet_diagnostic.IDE0018.severity = warning
122+
# IDE0019: Use pattern matching to avoid 'as' followed by a 'null' check
123+
dotnet_diagnostic.IDE0019.severity = warning
124+
# IDE0020: Use pattern matching to avoid 'is' check followed by a cast (with variable)
125+
dotnet_diagnostic.IDE0020.severity = warning
126+
# IDE0021: Use expression body for constructors
127+
dotnet_diagnostic.IDE0021.severity = warning
128+
# IDE0022: Use expression body for methods
129+
dotnet_diagnostic.IDE0022.severity = warning
130+
# IDE0023: Use expression body for conversion operators
131+
dotnet_diagnostic.IDE0023.severity = warning
132+
# IDE0024: Use expression body for operators
133+
dotnet_diagnostic.IDE0024.severity = warning
134+
# IDE0025: Use expression body for properties
135+
dotnet_diagnostic.IDE0025.severity = warning
136+
# IDE0026: Use expression body for indexers
137+
dotnet_diagnostic.IDE0026.severity = warning
138+
# IDE0027: Use expression body for accessors
139+
dotnet_diagnostic.IDE0027.severity = warning
140+
# IDE0028: Use collection initializers
141+
dotnet_diagnostic.IDE0028.severity = warning
142+
# IDE0029: Use coalesce expression (non-nullable types)
143+
dotnet_diagnostic.IDE0029.severity = warning
144+
# IDE0030: Use coalesce expression (nullable types)
145+
dotnet_diagnostic.IDE0030.severity = warning
146+
# IDE0031: Use null propagation
147+
dotnet_diagnostic.IDE0031.severity = warning
148+
# IDE0032: Use auto property
149+
dotnet_diagnostic.IDE0032.severity = warning
150+
# IDE0033: Use explicitly provided tuple name
151+
dotnet_diagnostic.IDE0033.severity = warning
152+
# IDE0034: Simplify 'default' expression
153+
dotnet_diagnostic.IDE0034.severity = warning
154+
# IDE0035: Remove unreachable code
155+
dotnet_diagnostic.IDE0035.severity = warning
156+
# IDE0036: Order modifiers
157+
dotnet_diagnostic.IDE0036.severity = warning
158+
# IDE0037: Use inferred member name
159+
dotnet_diagnostic.IDE0037.severity = warning
160+
# IDE0038: Use pattern matching to avoid is check followed by a cast (without variable)
161+
dotnet_diagnostic.IDE0038.severity = suggestion
162+
# IDE0040: Add accessibility modifiers
163+
dotnet_diagnostic.IDE0040.severity = warning
164+
# IDE0041: Use is null check
165+
dotnet_diagnostic.IDE0041.severity = warning
166+
# IDE0042: Deconstruct variable declaration
167+
dotnet_diagnostic.IDE0042.severity = warning
168+
# IDE0044: Add readonly modifier
169+
dotnet_diagnostic.IDE0044.severity = warning
170+
# IDE0045: Use conditional expression for assignment
171+
dotnet_diagnostic.IDE0045.severity = warning
172+
# IDE0046: Use conditional expression for return
173+
dotnet_diagnostic.IDE0046.severity = silent
174+
# IDE0047: Remove unnecessary parentheses
175+
dotnet_diagnostic.IDE0047.severity = warning
176+
# IDE0049: Use language keywords instead of framework type names for type references
177+
dotnet_diagnostic.IDE0049.severity = warning
178+
# IDE0051: Remove unused private member
179+
dotnet_diagnostic.IDE0051.severity = warning
180+
# IDE0052: Remove unread private member
181+
dotnet_diagnostic.IDE0052.severity = suggestion
182+
# IDE0053: Use expression body for lambdas
183+
dotnet_diagnostic.IDE0053.severity = warning
184+
# IDE0054: Use compound assignment
185+
dotnet_diagnostic.IDE0054.severity = warning
186+
# IDE0063: Use simple 'using' statement
187+
dotnet_diagnostic.IDE0063.severity = warning
188+
# IDE0066: Use switch expression
189+
dotnet_diagnostic.IDE0066.severity = warning
190+
# IDE0071: Simplify interpolation
191+
dotnet_diagnostic.IDE0071.severity = warning
192+
# IDE0073: Require file header
193+
dotnet_diagnostic.IDE0073.severity = warning
194+
# IDE0075: Simplify conditional expression
195+
dotnet_diagnostic.IDE0075.severity = warning
196+
# IDE0078: Use pattern matching
197+
dotnet_diagnostic.IDE0078.severity = warning
198+
# IDE0082: Convert typeof to nameof
199+
dotnet_diagnostic.IDE0082.severity = warning
200+
# IDE0083: Use pattern matching (not operator)
201+
dotnet_diagnostic.IDE0083.severity = warning
202+
# IDE0090: Simplify new expression
203+
dotnet_diagnostic.IDE0090.severity = warning
204+
# IDE0100: Remove unnecessary equality operator
205+
dotnet_diagnostic.IDE0100.severity = warning
206+
# IDE0110: Remove unnecessary discard
207+
dotnet_diagnostic.IDE0110.severity = warning
208+
# IDE1005: Use conditional delegate call
209+
dotnet_diagnostic.IDE1005.severity = warning
85210

86211
[*.{json}]
87212
indent_size = 2

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,12 @@ private static object GetPSVersion()
408408
// which is expensive.
409409
// Rather than do that, we instead go straight to the source,
410410
// which is a static property, internal in WinPS and public in PS 6+
411+
#pragma warning disable CA1825
411412
return typeof(PSObject).Assembly
412413
.GetType("System.Management.Automation.PSVersionInfo")
413414
.GetMethod("get_PSVersion", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
414415
.Invoke(null, new object[0] /* Cannot use Array.Empty, since it must work in net452 */);
416+
#pragma warning restore CA1825
415417
}
416418
}
417419
}

src/PowerShellEditorServices.Hosting/Internal/NamedPipeUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public static bool IsPipeNameValid(string pipeName)
137137
/// </summary>
138138
/// <param name="pipeName">The simple name of the named pipe.</param>
139139
/// <returns>The full path of the named pipe.</returns>
140+
#pragma warning disable IDE0022
140141
public static string GetNamedPipePath(string pipeName)
141142
{
142143
#if CoreCLR
@@ -149,4 +150,5 @@ public static string GetNamedPipePath(string pipeName)
149150
return $@"\\.\pipe\{pipeName}";
150151
}
151152
}
153+
#pragma warning restore IDE0022
152154
}

0 commit comments

Comments
 (0)