Skip to content

Commit 56087a9

Browse files
Added IDE analyzers checks and enabled certain checks (#8336)
* added IDE code style checks as warning, set the currently violated rules to suggestion * auto-fixed IDE0011 - add braces to statement * auto-fixed IDE0036 - Modifiers are not ordered * auto fixed IDE0040 - Accessibility modifiers required * auto-fixed IDE0055 - fix formatting * auto-fixed SA1110 and SA1111 - parenthesis formatting manually fixed unresolvable cases * auto-fixed IDE0073 - A source file contains a header that does not match the required text * moved IDE rules to .editorconfig as they need to be filtered * added IDE0020 - use pattern matching to be excluded * extra disable format due to chunk of code conditioned for DEBUG only * added comment in Version line to bypass the check clarified CTA on how to bypass the error * extra disable format due to chunk of code conditioned for DEBUG only
1 parent f4ed498 commit 56087a9

File tree

1,675 files changed

+13003
-13318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,675 files changed

+13003
-13318
lines changed

.editorconfig

+188-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ dotnet_code_quality.ca2208.api_surface = public
163163
dotnet_diagnostic.RS0037.severity = none
164164

165165
# License header
166-
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\n
166+
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
167167

168168
# C++ Files
169169
[*.{cpp,h,in}]
@@ -200,5 +200,192 @@ end_of_line = lf
200200
end_of_line = crlf
201201

202202
[src/**/*.{cs,vb}]
203+
# Code style checks
204+
dotnet_analyzer_diagnostic.category-Style.severity = warning
205+
206+
# Cast is redundant
207+
dotnet_diagnostic.IDE0004.severity = suggestion
208+
203209
# IDE0005: Remove unnecessary usings/imports
204210
dotnet_diagnostic.IDE0005.severity = warning
211+
212+
# Use explicit type instead of 'var'
213+
dotnet_diagnostic.IDE0008.severity = suggestion
214+
215+
# Populate switch
216+
dotnet_diagnostic.IDE0010.severity = suggestion
217+
218+
# Null check can be simplified
219+
dotnet_diagnostic.IDE0016.severity = suggestion
220+
221+
# Object initialization can be simplified
222+
dotnet_diagnostic.IDE0017.severity = suggestion
223+
224+
# Variable declaration can be inlined
225+
dotnet_diagnostic.IDE0018.severity = suggestion
226+
227+
# Use pattern matching
228+
dotnet_diagnostic.IDE0019.severity = suggestion
229+
dotnet_diagnostic.IDE0020.severity = suggestion
230+
231+
# Use expression body for constructor
232+
dotnet_diagnostic.IDE0021.severity = suggestion
233+
234+
# Use expression body for method
235+
dotnet_diagnostic.IDE0022.severity = suggestion
236+
237+
# Use expression body for conversion operator
238+
dotnet_diagnostic.IDE0023.severity = suggestion
239+
240+
# Use block body for operator
241+
dotnet_diagnostic.IDE0024.severity = suggestion
242+
243+
# Use expression body for property
244+
dotnet_diagnostic.IDE0025.severity = suggestion
245+
246+
# Use expression body for indexer
247+
dotnet_diagnostic.IDE0026.severity = suggestion
248+
249+
# Use expression body for accessor
250+
dotnet_diagnostic.IDE0027.severity = suggestion
251+
252+
# Collection initialization can be simplified
253+
dotnet_diagnostic.IDE0028.severity = suggestion
254+
255+
# Null check can be simplified
256+
dotnet_diagnostic.IDE0031.severity = suggestion
257+
258+
# Use auto property
259+
dotnet_diagnostic.IDE0032.severity = suggestion
260+
261+
# 'default' expression can be simplified
262+
dotnet_diagnostic.IDE0034.severity = suggestion
263+
264+
# Member name can be simplified
265+
dotnet_diagnostic.IDE0037.severity = suggestion
266+
267+
# Use local function
268+
dotnet_diagnostic.IDE0039.severity = suggestion
269+
270+
# Null check can be simplified
271+
dotnet_diagnostic.IDE0041.severity = suggestion
272+
273+
# Variable declaration can be deconstructed
274+
dotnet_diagnostic.IDE0042.severity = suggestion
275+
276+
# Made field readonly
277+
dotnet_diagnostic.IDE0044.severity = suggestion
278+
279+
# 'if' statement can be simplified
280+
dotnet_diagnostic.IDE0045.severity = suggestion
281+
dotnet_diagnostic.IDE0046.severity = suggestion
282+
283+
# Parentheses can be removed
284+
dotnet_diagnostic.IDE0047.severity = suggestion
285+
286+
# Parentheses should be added for clarity
287+
dotnet_diagnostic.IDE0048.severity = suggestion
288+
289+
# Member name can be simplified
290+
dotnet_diagnostic.IDE0049.severity = suggestion
291+
292+
# Use compound assignment
293+
dotnet_diagnostic.IDE0054.severity = suggestion
294+
295+
# Indexing can be simplified
296+
dotnet_diagnostic.IDE0056.severity = suggestion
297+
298+
# Slice can be simplified
299+
dotnet_diagnostic.IDE0057.severity = suggestion
300+
301+
# Expression value is never used
302+
dotnet_diagnostic.IDE0058.severity = suggestion
303+
304+
# Unnecessary assignment of a value
305+
dotnet_diagnostic.IDE0059.severity = suggestion
306+
307+
# Remove unused parameter
308+
dotnet_diagnostic.IDE0060.severity = suggestion
309+
310+
# Use expression body for a local function
311+
dotnet_diagnostic.IDE0061.severity = suggestion
312+
313+
# Local function can be made static
314+
dotnet_diagnostic.IDE0062.severity = suggestion
315+
316+
# Using directives must be placed outside of a namespace declaration
317+
dotnet_diagnostic.IDE0065.severity = suggestion
318+
319+
# Use 'switch' expression
320+
dotnet_diagnostic.IDE0066.severity = suggestion
321+
322+
# 'GetHashCode' implementation can be simplified
323+
dotnet_diagnostic.IDE0070.severity = suggestion
324+
325+
# Interpolation can be simplified
326+
dotnet_diagnostic.IDE0071.severity = suggestion
327+
328+
# Populate switch
329+
dotnet_diagnostic.IDE0072.severity = suggestion
330+
331+
# Use compound assignment
332+
dotnet_diagnostic.IDE0074.severity = suggestion
333+
334+
# Conditional expression can be simplified
335+
dotnet_diagnostic.IDE0075.severity = suggestion
336+
337+
# Use pattern matching
338+
dotnet_diagnostic.IDE0078.severity = suggestion
339+
dotnet_diagnostic.IDE0083.severity = suggestion
340+
341+
# 'typeof' can be converted to 'nameof'
342+
dotnet_diagnostic.IDE0082.severity = suggestion
343+
344+
# 'new' expression can be simplified
345+
dotnet_diagnostic.IDE0090.severity = suggestion
346+
347+
# Simplify LINQ expression
348+
dotnet_diagnostic.IDE0120.severity = suggestion
349+
350+
# namespace does not match folder structure
351+
dotnet_diagnostic.IDE0130.severity = suggestion
352+
353+
# Null check can be clarified
354+
dotnet_diagnostic.IDE0150.severity = suggestion
355+
356+
# Convert to block scoped namespaces
357+
dotnet_diagnostic.IDE0160.severity = suggestion
358+
359+
# Simplify property pattern
360+
dotnet_diagnostic.IDE0170.severity = suggestion
361+
362+
# Use tuple to swap values
363+
dotnet_diagnostic.IDE0180.severity = suggestion
364+
365+
# Use tuple to swap values
366+
dotnet_diagnostic.IDE0180.severity = suggestion
367+
368+
# Lambda expression can be removed
369+
dotnet_diagnostic.IDE0200.severity = suggestion
370+
371+
# Convert to top-level statements
372+
dotnet_diagnostic.IDE0210.severity = suggestion
373+
374+
# 'foreach' statement implicitly converts
375+
dotnet_diagnostic.IDE0220.severity = suggestion
376+
377+
# Use UTF-8 string literal
378+
dotnet_diagnostic.IDE0230.severity = suggestion
379+
380+
# Nullable directives
381+
dotnet_diagnostic.IDE0240.severity = suggestion
382+
dotnet_diagnostic.IDE0241.severity = suggestion
383+
384+
# Struct can be made 'readonly'
385+
dotnet_diagnostic.IDE0250.severity = suggestion
386+
387+
# Null check can be simplified
388+
dotnet_diagnostic.IDE0270.severity = suggestion
389+
390+
# naming rule violation
391+
dotnet_diagnostic.IDE1006.severity = suggestion

eng/Common.globalconfig

+4-3
Original file line numberDiff line numberDiff line change
@@ -782,10 +782,10 @@ dotnet_diagnostic.SA1107.severity = suggestion
782782
dotnet_diagnostic.SA1108.severity = none
783783

784784
# Opening parenthesis or bracket should be on declaration line
785-
dotnet_diagnostic.SA1110.severity = suggestion
785+
dotnet_diagnostic.SA1110.severity = warning
786786

787787
# Closing parenthesis should be on line of last parameter
788-
dotnet_diagnostic.SA1111.severity = suggestion
788+
dotnet_diagnostic.SA1111.severity = warning
789789

790790
dotnet_diagnostic.SA1112.severity = none
791791

@@ -1093,7 +1093,8 @@ dotnet_diagnostic.SA1627.severity = suggestion
10931093
dotnet_diagnostic.SA1629.severity = suggestion
10941094

10951095
# File should have header
1096-
dotnet_diagnostic.SA1633.severity = suggestion
1096+
# Superseded by IDE0073
1097+
dotnet_diagnostic.SA1633.severity = none
10971098

10981099
# Constructor summary documentation should begin with standard text
10991100
dotnet_diagnostic.SA1642.severity = suggestion

eng/build.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function Check-RequiredVersionBumps() {
169169
if (($LASTEXITCODE -ne 0) -and (-not $versionLineChanged)) {
170170
throw "##vso[task.logissue type=error] Detected changes in Framework\EngineServices.cs without a version bump. " +
171171
"If you are making API changes, please bump the version. " +
172-
"If the changes in the file are cosmetic, please add/change a comment on the Version prop to silence the error."
172+
"If the changes in the file are cosmetic, please change an inline comment on the `"int Version =`" line in EngineServices.cs to silence the error."
173173
}
174174
}
175175
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All rights reserved.
2-
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;

src/Build.OM.UnitTests/AssemblyResources.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Copyright (c) Microsoft. All rights reserved.
2-
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
55

0 commit comments

Comments
 (0)