This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
diktat-analysis.yml
435 lines (435 loc) · 13 KB
/
diktat-analysis.yml
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
- name: DIKTAT_COMMON
enabled: true
configuration:
domainName: com.saveourtool.diktat
kotlinVersion: 1.5
srcDirectories: main,commonMain,jvmMain,jsMain
testDirs: test,commonTest,jvmTest,jsTest
- name: CLASS_NAME_INCORRECT
enabled: true
configuration: {}
- name: CONSTANT_UPPERCASE
enabled: true
configuration: {}
- name: ENUM_VALUE
enabled: true
configuration:
enumStyle: SNAKE_CASE
- name: EXCEPTION_SUFFIX
enabled: true
configuration: {}
# so that diktat doesn't emit error on temporary file name
- name: FILE_NAME_INCORRECT
enabled: false
configuration: {}
# so that diktat doesn't emit error on temporary file name
- name: FILE_NAME_MATCH_CLASS
enabled: false
configuration: {}
- name: FUNCTION_BOOLEAN_PREFIX
enabled: true
configuration: {}
- name: FUNCTION_NAME_INCORRECT_CASE
enabled: true
configuration: {}
- name: GENERIC_NAME
enabled: true
configuration: {}
- name: IDENTIFIER_LENGTH
enabled: true
configuration: {}
- name: OBJECT_NAME_INCORRECT
enabled: true
configuration: {}
- name: PACKAGE_NAME_INCORRECT_CASE
enabled: true
configuration: {}
- name: PACKAGE_NAME_INCORRECT_PREFIX
enabled: true
configuration: {}
- name: PACKAGE_NAME_INCORRECT_SYMBOLS
enabled: true
configuration: {}
- name: PACKAGE_NAME_INCORRECT_PATH
enabled: true
configuration: {}
- name: PACKAGE_NAME_MISSING
enabled: true
configuration: {}
- name: VARIABLE_HAS_PREFIX
enabled: true
configuration: {}
- name: VARIABLE_NAME_INCORRECT
enabled: true
configuration: {}
- name: VARIABLE_NAME_INCORRECT_FORMAT
enabled: true
configuration: {}
- name: MISSING_KDOC_ON_FUNCTION
enabled: true
configuration: {}
- name: MISSING_KDOC_TOP_LEVEL
enabled: true
configuration: {}
- name: MISSING_KDOC_CLASS_ELEMENTS
enabled: true
configuration: {}
- name: KDOC_WITHOUT_PARAM_TAG
enabled: true
configuration: {}
- name: KDOC_WITHOUT_RETURN_TAG
enabled: true
configuration: {}
- name: KDOC_WITHOUT_THROWS_TAG
enabled: true
configuration: {}
- name: KDOC_EMPTY_KDOC
enabled: true
configuration: {}
- name: INCORRECT_PACKAGE_SEPARATOR
enabled: true
configuration: {}
- name: KDOC_NO_DEPRECATED_TAG
enabled: true
configuration: {}
- name: KDOC_NO_EMPTY_TAGS
enabled: true
configuration: {}
- name: KDOC_WRONG_SPACES_AFTER_TAG
enabled: true
configuration: {}
- name: KDOC_WRONG_TAGS_ORDER
enabled: true
configuration: {}
- name: KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS
enabled: true
configuration: {}
- name: KDOC_NEWLINES_BEFORE_BASIC_TAGS
enabled: true
configuration: {}
- name: KDOC_NO_NEWLINE_AFTER_SPECIAL_TAGS
enabled: true
configuration: {}
- name: KDOC_TRIVIAL_KDOC_ON_FUNCTION
enabled: 'true'
configuration: {}
- name: HEADER_WRONG_FORMAT
enabled: true
configuration: {}
- name: HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE
enabled: true
configuration: {}
- name: HEADER_MISSING_OR_WRONG_COPYRIGHT
enabled: true
configuration:
isCopyrightMandatory: false
copyrightText: ''
- name: HEADER_NOT_BEFORE_PACKAGE
enabled: true
configuration: {}
- name: KDOC_CONTAINS_DATE_OR_AUTHOR
enabled: true
configuration: {}
- name: FILE_IS_TOO_LONG
enabled: true
configuration:
maxSize: '2000'
ignoreFolders: ''
- name: COMMENTED_OUT_CODE
enabled: true
configuration: {}
- name: FILE_CONTAINS_ONLY_COMMENTS
enabled: true
configuration: {}
# order imports alphabetically
- name: FILE_UNORDERED_IMPORTS
enabled: true
configuration:
# use logical imports grouping with sorting inside of a group
useRecommendedImportsOrder: true
- name: FILE_INCORRECT_BLOCKS_ORDER
enabled: true
configuration: {}
- name: FILE_NO_BLANK_LINE_BETWEEN_BLOCKS
enabled: true
configuration: {}
- name: FILE_WILDCARD_IMPORTS
enabled: true
configuration: {}
- name: NO_BRACES_IN_CONDITIONALS_AND_LOOPS
enabled: true
configuration: {}
- name: WRONG_ORDER_IN_CLASS_LIKE_STRUCTURES
enabled: true
configuration: {}
- name: BLANK_LINE_BETWEEN_PROPERTIES
enabled: true
configuration: {}
- name: BRACES_BLOCK_STRUCTURE_ERROR
enabled: true
configuration:
openBraceNewline: 'True'
closeBraceNewline: 'True'
- name: WRONG_INDENTATION
enabled: true
configuration:
newlineAtEnd: true
extendedIndentOfParameters: false
alignedParameters: true
extendedIndentAfterOperators: true
extendedIndentBeforeDot: false
indentationSize: 4
- name: EMPTY_BLOCK_STRUCTURE_ERROR
enabled: true
configuration:
styleEmptyBlockWithNewline: 'True'
allowEmptyBlocks: 'False'
- name: MORE_THAN_ONE_STATEMENT_PER_LINE
enabled: true
configuration: {}
- name: LONG_LINE
enabled: true
configuration:
lineLength: '180'
- name: REDUNDANT_SEMICOLON
enabled: true
configuration: {}
- name: WRONG_NEWLINES
enabled: true
configuration:
maxParametersInOneLine: 2
- name: TOO_MANY_CONSECUTIVE_SPACES
enabled: true
configuration:
max_spaces: '1'
saveInitialFormattingForEnums: false
- name: TOO_MANY_BLANK_LINES
enabled: true
configuration: {}
- name: WRONG_WHITESPACE
enabled: true
configuration: {}
- name: BACKTICKS_PROHIBITED
enabled: true
configuration: {}
- name: STRING_CONCATENATION
enabled: true
configuration: {}
- name: WHEN_WITHOUT_ELSE
enabled: true
configuration: {}
- name: ANNOTATION_NEW_LINE
enabled: true
configuration: {}
- name: ENUMS_SEPARATED
enabled: true
configuration: {}
- name: LONG_NUMERICAL_VALUES_SEPARATED
enabled: true
configuration:
maxNumberLength: '5'
maxBlockLength: '3'
# Checks magic number
- name: MAGIC_NUMBER
enabled: true
configuration:
# Ignore numbers
ignoreNumbers: "-1, 1, 0, 2"
# Is ignore override hashCode function
ignoreHashCodeFunction: "true"
# Is ignore property
ignorePropertyDeclaration: "false"
# Is ignore local variable
ignoreLocalVariableDeclaration: "false"
# Is ignore constant
ignoreConstantDeclaration: "true"
# Is ignore property in companion object
ignoreCompanionObjectPropertyDeclaration: "true"
# Is ignore numbers in enum
ignoreEnums: "false"
# Is ignore number in ranges
ignoreRanges: "false"
# Is ignore number in extension function
ignoreExtensionFunctions: "false"
- name: WRONG_DECLARATIONS_ORDER
enabled: true
configuration:
sortEnum: true
sortProperty: true
- name: WRONG_MULTIPLE_MODIFIERS_ORDER
enabled: true
configuration: {}
- name: CONFUSING_IDENTIFIER_NAMING
enabled: true
configuration: {}
- name: WRONG_COPYRIGHT_YEAR
enabled: true
configuration: {}
# Inspection that checks if local variables are declared close to the first usage site
- name: LOCAL_VARIABLE_EARLY_DECLARATION
enabled: true
configuration: {}
# Try to avoid initialize val by null (e.g. val a: Int? = null -> val a: Int = 0)
- name: NULLABLE_PROPERTY_TYPE
enabled: true
configuration: {}
# Inspection that checks if there is a blank line before kDoc and none after
- name: WRONG_NEWLINES_AROUND_KDOC
enabled: true
configuration: {}
# Inspection that checks if there is no blank lines before first comment
- name: FIRST_COMMENT_NO_BLANK_LINE
enabled: true
configuration: {}
# Inspection that checks if there are blank lines between code and comment and between code start token and comment's text
- name: COMMENT_WHITE_SPACE
enabled: true
configuration:
maxSpacesBeforeComment: 2
maxSpacesInComment: 1
# Inspection that checks if all comment's are inside if-else code blocks. Exception is general if comment
- name: IF_ELSE_COMMENTS
enabled: true
configuration: {}
# Type aliases provide alternative names for existing types when type's reference text is longer 25 chars
- name: TYPE_ALIAS
enabled: true
configuration:
typeReferenceLength: '25' # max length of type reference
- name: SMART_CAST_NEEDED
enabled: true
configuration: {}
- name: GENERIC_VARIABLE_WRONG_DECLARATION
enabled: true
configuration: {}
# Inspection that checks if string template has redundant curly braces
- name: STRING_TEMPLATE_CURLY_BRACES
enabled: true
configuration: {}
# Variables with `val` modifier - are immutable (read-only). Usage of such variables instead of `var` variables increases
# robustness and readability of code, because `var` variables can be reassigned several times in the business logic.
# This rule prohibits usage of `var`s as local variables - the only exception is accumulators and counters
- name: SAY_NO_TO_VAR
enabled: true
configuration: {}
# Inspection that checks if string template has redundant quotes
- name: STRING_TEMPLATE_QUOTES
enabled: true
configuration: {}
# Check if there are redundant nested if-statements, which could be collapsed into a single one by concatenating their conditions
- name: COLLAPSE_IF_STATEMENTS
enabled: true
configuration:
startCollapseFromNestedLevel: 2
# Checks that floating-point values are not used in arithmetic expressions
- name: FLOAT_IN_ACCURATE_CALCULATIONS
enabled: true
configuration: {}
# Checks that function length isn't too long
- name: TOO_LONG_FUNCTION
enabled: true
configuration:
maxFunctionLength: '30' # max length of function
isIncludeHeader: 'false' # count function's header
# Warns if there are nested functions
- name: AVOID_NESTED_FUNCTIONS
enabled: true
configuration: {}
# Checks that lambda inside function parameters is in the end
- name: LAMBDA_IS_NOT_LAST_PARAMETER
enabled: true
configuration: {}
# Checks that function doesn't contains too many parameters
- name: TOO_MANY_PARAMETERS
enabled: true
configuration:
maxParameterListSize: '5' # max parameters size
# Checks that function doesn't have too many nested blocks
- name: NESTED_BLOCK
enabled: true
configuration:
maxNestedBlockQuantity: '4'
# Checks that function use default values, instead overloading
- name: WRONG_OVERLOADING_FUNCTION_ARGUMENTS
enabled: true
configuration: {}
# Checks that property in constructor doesn't contains comment
- name: KDOC_NO_CONSTRUCTOR_PROPERTY
enabled: true
configuration: {}
# Checks if class can be made as data class
- name: USE_DATA_CLASS
enabled: true
configuration: {}
# Checks that never use the name of a variable in the custom getter or setter
- name: WRONG_NAME_OF_VARIABLE_INSIDE_ACCESSOR
enabled: true
configuration: {}
# Checks that classes have only one init block
- name: MULTIPLE_INIT_BLOCKS
enabled: true
configuration: {}
# Checks that there are abstract functions in abstract class
- name: CLASS_SHOULD_NOT_BE_ABSTRACT
enabled: true
configuration: {}
# Checks if there are any trivial getters or setters
- name: TRIVIAL_ACCESSORS_ARE_NOT_RECOMMENDED
enabled: true
# Checks that no custom getters and setters are used for properties. It is a more wide rule than TRIVIAL_ACCESSORS_ARE_NOT_RECOMMENDED
# Kotlin compiler automatically generates `get` and `set` methods for properties and also lets the possibility to override it.
# But in all cases it is very confusing when `get` and `set` are overridden for a developer who uses this particular class.
# Developer expects to get the value of the property, but receives some unknown value and some extra side effect hidden by the custom getter/setter.
# Use extra functions for it instead.
- name: CUSTOM_GETTERS_SETTERS
enabled: true
# Checks if null-check was used explicitly (for example: if (a == null))
# Try to avoid explicit null checks (explicit comparison with `null`)
# Kotlin is declared as [Null-safe](https://kotlinlang.org/docs/reference/null-safety.html) language.
# But Kotlin architects wanted Kotlin to be fully compatible with Java, that's why `null` keyword was also introduced in Kotlin.
# There are several code-structures that can be used in Kotlin to avoid null-checks. For example: `?:`, `.let {}`, `.also {}`, e.t.c
- name: AVOID_NULL_CHECKS
enabled: true
# Checks if class instantiation can be wrapped in `apply` for better readability
- name: COMPACT_OBJECT_INITIALIZATION
enabled: true
# Checks explicit supertype qualification
- name: USELESS_SUPERTYPE
enabled: true
# Checks if extension function with the same signature don't have related classes
- name: EXTENSION_FUNCTION_SAME_SIGNATURE
enabled: true
# Checks if there is empty primary constructor
- name: EMPTY_PRIMARY_CONSTRUCTOR
enabled: true
# In case of not using field keyword in property accessors,
# there should be explicit backing property with the name of real property
# Example: val table get() {if (_table == null) ...} -> table should have _table
- name: NO_CORRESPONDING_PROPERTY
enabled: true
# Checks if there is class/object that can be replace with extension function
- name: AVOID_USING_UTILITY_CLASS
enabled: true
# If there is stateless class it is preferred to use object
- name: OBJECT_IS_PREFERRED
enabled: true
# Checks trailing comma
- name: TRAILING_COMMA
enabled: true
configuration:
# VALUE_ARGUMENT
valueArgument: true
# VALUE_PARAMETER
valueParameter: true
# REFERENCE_EXPRESSION
indices: true
# WHEN_CONDITION_WITH_EXPRESSION
whenConditions: true
# STRING_TEMPLATE
collectionLiteral: true
# TYPE_PROJECTION
typeArgument: true
# TYPE_PARAMETER
typeParameter: true
# DESTRUCTURING_DECLARATION_ENTRY
destructuringDeclaration: true