forked from devstress/FlinkDotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.editorconfig
More file actions
354 lines (280 loc) · 16.1 KB
/
.editorconfig
File metadata and controls
354 lines (280 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# EditorConfig is awesome: https://EditorConfig.org
# Top-most EditorConfig file
root = true
# Universal EOL and charset behavior
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# Indentation and spacing
[*.cs]
indent_style = space
indent_size = 4
tab_width = 4
# Newline preferences
dotnet_style_new_line_before_open_brace = all
dotnet_style_new_line_before_else = true
dotnet_style_new_line_before_catch = true
dotnet_style_new_line_before_finally = true
dotnet_style_new_line_before_members_in_object_initializers = true
dotnet_style_new_line_before_members_in_anonymous_types = true
dotnet_style_new_line_between_query_expression_clauses = true
# Code style settings
# this. and Me. preferences
dotnet_style_qualification_for_field = true:suggestion
dotnet_style_qualification_for_property = true:suggestion
dotnet_style_qualification_for_method = true:suggestion
dotnet_style_qualification_for_event = true:suggestion
# Language keywords vs framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
# Modifier preferences
dotnet_style_require_accessibility_modifiers = always:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
csharp_style_throw_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
# Unnecessary code suggestions
dotnet_remove_unnecessary_casts = true:suggestion
dotnet_style_prefer_readonly_struct = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
# Naming conventions
# Rules are specified using the following format:
# dotnet_naming_rule.<naming_rule_name>.severity = <severity>
# dotnet_naming_rule.<naming_rule_name>.symbols = <symbol_kind_group_name>
# dotnet_naming_rule.<naming_rule_name>.style = <naming_style_name>
# Symbol kind group names:
# Namespace, Class, Struct, Enum, Interface, Delegate, Event, Method, Property, Field,
# Parameter, TypeParameter, Local, LocalFunction
# Naming style names:
# PascalCase, CamelCase, FirstUpper, AllUpper, AllLower
# Interfaces should start with 'I' (PascalCase)
dotnet_naming_rule.interface_should_be_pascal_case_with_i.symbols = Interface
dotnet_naming_rule.interface_should_be_pascal_case_with_i.style = PascalCaseWithI
dotnet_naming_rule.interface_should_be_pascal_case_with_i.severity = suggestion
dotnet_naming_symbols.Interface.applicable_kinds = interface
dotnet_naming_style.PascalCaseWithI.required_prefix = I
dotnet_naming_style.PascalCaseWithI.capitalization = pascal_case
# Async methods should end with 'Async'
dotnet_naming_rule.async_methods_should_end_with_async.symbols = Method
dotnet_naming_rule.async_methods_should_end_with_async.style = EndsWithAsync
dotnet_naming_rule.async_methods_should_end_with_async.severity = suggestion
dotnet_naming_symbols.Method.applicable_kinds = method
dotnet_naming_style.EndsWithAsync.required_suffix = Async
dotnet_naming_style.EndsWithAsync.capitalization = pascal_case
# Public members should be PascalCase
dotnet_naming_rule.public_members_should_be_pascal_case.symbols = PublicMembers
dotnet_naming_rule.public_members_should_be_pascal_case.style = PascalCase
dotnet_naming_rule.public_members_should_be_pascal_case.severity = suggestion
dotnet_naming_symbols.PublicMembers.applicable_kinds = class, struct, enum, property, method, event, delegate
dotnet_naming_symbols.PublicMembers.applicable_accessibilities = public, internal, protected, protected_internal
dotnet_naming_style.PascalCase.capitalization = pascal_case
# Non-public fields should be camelCase and start with _
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.symbols = PrivateInstanceFields
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.style = CamelCaseWithUnderscore
dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore.severity = suggestion
dotnet_naming_symbols.PrivateInstanceFields.applicable_kinds = field
dotnet_naming_symbols.PrivateInstanceFields.applicable_accessibilities = private
dotnet_naming_symbols.PrivateInstanceFields.required_modifiers = instance # static fields are covered by another rule
dotnet_naming_style.CamelCaseWithUnderscore.required_prefix = _
dotnet_naming_style.CamelCaseWithUnderscore.capitalization = camel_case
# Static fields (public or non-public)
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = StaticFields
dotnet_naming_rule.static_fields_should_be_pascal_case.style = PascalCase
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_symbols.StaticFields.applicable_kinds = field
dotnet_naming_symbols.StaticFields.required_modifiers = static
# Constants should be PascalCase (or AllUpper if preferred, but PascalCase is common in .NET)
dotnet_naming_rule.constants_should_be_pascal_case.symbols = Constants
dotnet_naming_rule.constants_should_be_pascal_case.style = PascalCase
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
dotnet_naming_symbols.Constants.applicable_kinds = field
dotnet_naming_symbols.Constants.required_modifiers = const
# Local variables should be camelCase
dotnet_naming_rule.locals_should_be_camel_case.symbols = Locals
dotnet_naming_rule.locals_should_be_camel_case.style = CamelCase
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
dotnet_naming_symbols.Locals.applicable_kinds = local
dotnet_naming_style.CamelCase.capitalization = camel_case
# Parameters should be camelCase
dotnet_naming_rule.parameters_should_be_camel_case.symbols = Parameters
dotnet_naming_rule.parameters_should_be_camel_case.style = CamelCase
dotnet_naming_rule.parameters_should_be_camel_case.severity = suggestion
dotnet_naming_symbols.Parameters.applicable_kinds = parameter
dotnet_naming_style.CamelCase.capitalization = camel_case
# Type parameters should start with 'T' (PascalCase)
dotnet_naming_rule.type_parameters_should_be_pascal_case_with_t.symbols = TypeParameters
dotnet_naming_rule.type_parameters_should_be_pascal_case_with_t.style = PascalCaseWithT
dotnet_naming_rule.type_parameters_should_be_pascal_case_with_t.severity = suggestion
dotnet_naming_symbols.TypeParameters.applicable_kinds = type_parameter
dotnet_naming_style.PascalCaseWithT.required_prefix = T
dotnet_naming_style.PascalCaseWithT.capitalization = pascal_case
# Rules to encourage SOLID-like principles (limited by .editorconfig capabilities)
# These are more about code complexity and readability, which indirectly support SOLID.
# Avoid long lines (helps with readability)
max_line_length = 120:suggestion
# C# specific formatting options
csharp_preserve_single_line_blocks = false
csharp_preserve_single_line_statements = false
# Spacing options
csharp_space_after_cast = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Wrapping and new lines
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Blank line preferences
csharp_blank_lines_around_accessor_blocks = 0
csharp_blank_lines_between_consecutive_braces = 0
csharp_blank_lines_between_imports = 1
csharp_blank_lines_between_members_in_anonymous_types = 0
csharp_blank_lines_between_members_in_object_initializers = 0
csharp_blank_lines_between_single_line_members = 1
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion
# var preferences
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
# Using directive preferences
csharp_using_directive_placement = outside_namespace:warning
dotnet_sort_system_directives_first = true
dotnet_diagnostic.IDE0005.severity = error
dotnet_diagnostic.CS8019.severity = error
# WARNING ENFORCEMENT: Critical code quality rules are now errors
# Async/await patterns
dotnet_diagnostic.CS1998.severity = error # Async method without await
dotnet_diagnostic.S6966.severity = error # Use RunAsync instead of Run
# Exception handling
dotnet_diagnostic.S2139.severity = error # Log and handle or rethrow with context
# Code cleanup
dotnet_diagnostic.S125.severity = error # Remove commented out code
dotnet_diagnostic.S1172.severity = error # Remove unused method parameters
dotnet_diagnostic.S1481.severity = error # Remove unused local variables
dotnet_diagnostic.S4487.severity = error # Remove unused private fields
# Class design
dotnet_diagnostic.S1118.severity = error # Add protected constructor or static keyword
dotnet_diagnostic.S3260.severity = error # Mark private classes as sealed
dotnet_diagnostic.S2325.severity = error # Make methods static when possible
# URI and security
dotnet_diagnostic.S1075.severity = error # No hardcoded absolute paths or URIs
# Method complexity and length
dotnet_diagnostic.S3776.severity = error # Cognitive complexity limit
dotnet_diagnostic.S138.severity = error # Method length limit
# Logging
dotnet_diagnostic.S6677.severity = error # Unique message template placeholders
# Code block preferences
csharp_prefer_braces = true:suggestion
# XML Documentation Comments
# IDE0055: Fix formatting of XML documentation comments
dotnet_diagnostic.IDE0055.severity = suggestion
# IDE0072: Add missing cases to switch expression
dotnet_diagnostic.IDE0072.severity = warning
# IDE0073: Require file header
dotnet_diagnostic.IDE0073.severity = silent
# csharp_style_require_file_header_template = unset
# The following rules are examples of what might be used for complexity,
# but actual enforcement often needs dedicated analyzers.
# .editorconfig has limited direct support for "max method length" or "max class size".
# However, some Roslyn analyzers might be configurable via .editorconfig using their diagnostic IDs.
# Example: Potentially configure a Roslyn analyzer for complexity if its ID is known
# and it supports .editorconfig severity setting.
# dotnet_diagnostic.<AnalyzerRuleId>.severity = warning
# For instance, if there was an analyzer rule `MyCompany.CodeAnalysis.TooManyLinesInMethod`
# you might try:
# dotnet_diagnostic.MyCompany.CodeAnalysis.TooManyLinesInMethod.severity = warning
# dotnet_diagnostic.MyCompany.CodeAnalysis.TooManyLinesInMethod.max_lines = 100
# Similarly for class size:
# dotnet_diagnostic.MyCompany.CodeAnalysis.ClassTooLarge.severity = warning
# dotnet_diagnostic.MyCompany.CodeAnalysis.ClassTooLarge.max_lines = 500
# Since standard .editorconfig doesn't have these directly, these are placeholders.
# The primary way to enforce these types of rules is through Roslyn analyzers
# referenced in the project file, which then respect severity settings from .editorconfig.
# The `max_line_length` is a general setting that helps a bit.
# Roslynator rules fine-tuned for SOLID principles (severity set to warning, will be error due to TreatWarningsAsErrors=true)
# SRP & Complexity related
dotnet_diagnostic.RCS1208.severity = warning # Reduce 'if' nesting
dotnet_diagnostic.RCS1060.severity = warning # Declare each type in separate file
# Note: Direct method/class size rules are not easily available via Roslynator .editorconfig alone.
# OCP & DIP related (promoting abstractions, immutability)
dotnet_diagnostic.RCS1102.severity = warning # Make class static (if applicable, encourages utility classes over instantiable ones for stateless helpers)
dotnet_diagnostic.RCS1160.severity = warning # Abstract type should not have public constructors
dotnet_diagnostic.RCS1169.severity = warning # Make field read-only (where possible)
dotnet_diagnostic.RCS1170.severity = warning # Use read-only auto-implemented property (where possible)
dotnet_diagnostic.RCS1172.severity = warning # Use 'is' operator instead of 'as' operator (prompts review of type checking)
# ISP related
dotnet_diagnostic.RCS1213.severity = warning # Remove unused member declaration (can indicate fat interfaces/classes)
# General good practices supporting SOLID
dotnet_diagnostic.RCS1059.severity = warning # Avoid locking on publicly accessible instance
dotnet_diagnostic.RCS1075.severity = warning # Avoid empty catch clause that catches System.Exception or System.Object
dotnet_diagnostic.RCS1155.severity = warning # Use StringComparison when comparing strings
dotnet_diagnostic.RCS1210.severity = warning # Return completed task instead of returning null (for async methods)
dotnet_diagnostic.RCS1215.severity = warning # Expression is always equal to true/false
# End of Roslynator SOLID tuning
# SonarAnalyzer.CSharp rules for code metrics (severity set to warning, will be error due to TreatWarningsAsErrors=true)
# Cognitive Complexity of methods should not be too high
dotnet_diagnostic.S3776.severity = warning
# Methods should not have too many lines of code
dotnet_diagnostic.S138.severity = warning
# Files should not have too many lines of code
dotnet_diagnostic.S110.severity = warning
# Methods should not have too many parameters
dotnet_diagnostic.S107.severity = warning
# Control flow statements should not be nested too deeply
# dotnet_diagnostic.S121.severity = warning # Overridden below
# Disable S121 (SonarCloud: Add curly braces when block has one statement) globally
dotnet_diagnostic.S121.severity = none
# Classes should not be coupled to too many other classes
dotnet_diagnostic.S1699.severity = warning
# Inheritance tree of classes should not be too deep
dotnet_diagnostic.S1109.severity = warning
# Unused private members should be removed (helps with ISP and SRP)
dotnet_diagnostic.S1144.severity = warning
# Unused method parameters should be removed (supports SRP)
dotnet_diagnostic.S1066.severity = warning
# HTTP protocol security rule - use HTTPS instead of HTTP
dotnet_diagnostic.S5332.severity = warning
# Fields should be readonly where possible
dotnet_diagnostic.S2933.severity = warning
# End of SonarAnalyzer.CSharp metric rules