forked from ExtremeFLOW/neko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflinter_rc.yml
446 lines (390 loc) · 9.55 KB
/
flinter_rc.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
436
437
438
439
440
441
442
443
444
445
446
# Flinter configuration file.
extension: f\d*
# These are all the regexp rules
# Set active to false is you want to skip rule
# All are regexp rules, meaning you can add new rules simply by editing this file
# test your rule on https://regex101.com/ if needed
regexp-rules:
# -------------------------------------------------------------------------- #
# Meta rules
line-too-long:
message: Line too long
regexp: .{{81,}}
replacement: null
active: true
prepend-openmp-with-!$:
message: Should prepend with "!$"
regexp: ^\s*use omp_lib
replacement: '\1!$ use omp_lib'
active: true
useless-eol-semicolon:
message: Useless ";" at end of line
regexp: ;\s*$
replacement: \n
active: true
recommended-use-mpi_f08:
message: Should use `use mpi_f08` instead (or `use mpi` if not available)
regexp: include ["\']mpif.h[\'"]
replacement: null
active: true
not-recommended-use-include:
message: include is discouraged, prefer use.
regexp: ^include.*$
replacement: null
active: true
# -------------------------------------------------------------------------- #
# White space rules
trailing-white-spaces:
message: Trailing white-spaces
regexp: ([ ]+|\t+)\n
replacement: ""
active: true
include-comments: true
tabulation-instead-of-two-spaces:
message: Should use 2 spaces instead of tabulation
regexp: \t
replacement: " "
active: true
# -------------------------------------------------------------------------- #
# Types and intrinsic rules
# Case sensitive rules do not work
intrinsics-should-be-lowercased:
message: Intrinsics keywords should be lowercased
regexp: \b({intrinsics_upper}|end({blocks_upper}|{structs_upper}))\b
case-sensitive: true
active: false
intrinsics-args-should-be-lowercased:
message: Intrinsics named argument should be lowercased
regexp: \b({named-args_upper})(?=\s*=)
case-sensitive: true
active: false
types-should-be-lowercased:
message: Types should be lowercased
regexp: \b({types_upper})\b
case-sensitive: true
active: false
use-new-syntax-type:
message: Use new syntax TYPE(kind)
regexp: ({types})\*(\w+)
replacement: \1(\2)
active: true
recommended-use-of-sp-dp:
message: You should use "sp" or "dp" instead
regexp: \(kind\s*=\s*\d\s*\)
replacement: null
active: true
not-recommended-use-double-precision:
message: double precision is discouraged; use real instead.
regexp: ^double precision.*$
replacement: null
active: true
# -------------------------------------------------------------------------- #
# Syntax rules
recommended-use-of-brackets:
message: You should use "[]" instead
regexp: (\(\/)|(\/\))
replacement: '[\1]'
active: true
not-recommended-bare-end:
message: Bare end statement not recommended
regexp: \s^end$
replacement: null
active: true
not-recommended-bare-stop:
message: Bare stop statement not recommended
regexp: \s^stop$
replacement: null
active: true
not-recommended-use-exit:
message: exit is an extension and should be avoided
regexp: ^exit$
replacement: null
active: true
not-recommended-use-goto:
message: goto is hard to maintain, prone to spaghetti code.
regexp: ^goto.*$
replacement: null
active: true
not-recommended-use-pause:
message: pause is discouraged.
regexp: ^pause.*$
replacement: null
active: true
scope-not-specified:
message: Module usage should be explicit
regexp: ((^\s+use +)(?!(\bneko\b)|(\bdevice\b)|(\bcomm\b)|(\bmpi_f08\b)|(\bhdf5\b))\w+\b)(?!, only)
replacement: null
active: true
# -------------------------------------------------------------------------- #
# Formatting and code style rules
missing-spaces-around-operator:
message: Missing spaces around operator
regexp: (\w|\))({operators})(\w|\()
replacement: \1 \2 \3
active: true
missing-spaces-before-operator:
message: Missing space before operator
regexp: (\w|\))({operators})
replacement: \1 \2
active: true
missing-spaces-after-operator:
message: Missing space after operator
regexp: ({operators})(\w|\()
replacement: \1 \2
active: true
incorrect-spaces-before-separator:
message: Incorrect space before separator
regexp: (allocate\()?(^\s*\w+(?<!allocate)\b)?(?(1).*(?<=\s)::|(?(2).*(?<=\S)::|\0))
replacement: '\1 ::'
active: false
incorrect-spaces-after-separator:
message: Incorrect space after separator
regexp: (allocate\()?(^\s*\w+(?<!allocate)\b)?(?(1).*::(?=\s)|(?(2).*::(?=\S)|\0))
replacement: ':: \1'
active: false
# Look through the list of punctuation, but skip if inside format string '()'
# However, we do allow a single letter variable or 2 digit number to be used
# without spaces.
missing-spaces-after-punctuation:
message: Missing space after punctuation
regexp: ((,(?!.*\)[\'\"]))|(,(?=.*[\'\"]\()))(?=\d\d\d|[a-zA-Z]\w|[(\'\"])
replacement: \1 \2
active: true
missing-space-before-parenthesis:
message: Missing space before parenthesis
regexp: (\b{structs}\b)\(
replacement: \1 (
active: true
nospace-end:
message: Missing space after `end'
regexp: (?<!\#)end(if|do|subroutine|function)
replacement: end \1
active: true
missing-spaces-before-=:
message: Missing spaces before "="
regexp: ([^ \=\n]+)(?<!(kind|.len|..\'d|..\'n))((?<![\/=<>])=(?![>=]))
replacement: ' = \2'
active: true
missing-spaces-after-=:
message: Missing spaces after "="
regexp: (?<!(kind|.len|..\'d|..\'n))((?<![=<>\/])=(?![>=]))([^ ]\S*)
replacement: ' = \2'
active: true
# -------------------------------------------------------------------------- #
# Work in progress rules
# Exception: ´!` is allowed at the end of a string.
one-space-before-comment:
message: At least one space before comment
regexp: (\S+)\!(?!'|")
replacement: \1 !
active: false
one-space-after-comment:
message: Exactly one space after comment
regexp: (\!)(?![\!\'])(\S+)
replacement: '\1 \2'
active: false
excessive-use-of-space:
message: Except for indentation, single spaces are sufficient
regexp: (?<=\S) +(?=[^\s!])
replacement: " "
active: false
double-spacing:
message: Double spacing
regexp: \S+\s{{2,}}\S+
replacement: \n
active: false
# ============================================================================ #
# These are rules that span over multiple lines, not accessible by regexp
# If you want to edit these rules or add your own, two options:
# - ask us.
# - fork the code.
structure-rules:
max-statements-in-context: 2000
max-declared-locals: 35
min-varlen: 1
max-varlen: 30
max-arguments: 20
min-arglen: 1
max-arglen: 70
max-nesting-levels: 8
var-declaration: '(?:{types})\s*(?:\(.*\))?\s*(?:::| )\s*([A-Za-z_]\w*(?:\s*,\s*[A-Za-z_]\w*)*)'
# ============================================================================ #
# These are the fortran syntax we use to parse the source
# A priori there is no need to edit, but Fortran is so vast in time...
# ============================================================================ #
fortran-syntax:
types:
- real
- character
- logical
- integer
- complex
- double precision
types_upper:
- REAL
- CHARACTER
- LOGICAL
- INTEGER
- COMPLEX
- DOUBLE PRECISION
operators:
- '\.eq\.'
- "=="
- '\.neq\.'
- "/="
- '\.gt\.'
- ">"
- '\.lt\.'
- "<"
- '\.geq\.'
- ">="
- '\.leq\.'
- "<="
- '\.le\.'
- '\.ge\.'
- '\.and\.'
- '\.or\.'
structs:
- "if"
- "select"
- "case"
- "while"
- "is"
- "select type"
structs_upper:
- "IF"
- "SELECT"
- "CASE"
- "WHILE"
- "IS"
- "SELECT TYPE"
punctuations:
- ","
- '\)'
- ";"
namespace_blocks:
- "program"
- "module"
context_blocks:
- function
- subroutine
blocks:
- "program"
- "subroutine"
- "module"
- "function"
- "blockdata"
blocks_upper:
- PROGRAM
- MODULE
- FUNCTION
- SUBROUTINE
intrinsics_upper:
- ALLOCATABLE
- ALLOCATE
- ASSIGN
- ASSIGNMENT
- BACKSPACE
- BLOCK
- CALL
- CASE
- CLOSE
- COMMON
- CONTAINS
- CONTINUE
- CYCLE
- DATA
- DEALLOCATE
- DEFAULT
- DIMENSION
- DO
- ELSE
- ELSEWHERE
- END
- ENDFILE
- ENTRY
- EQUIVALENCE
- EXIT
- EXTERNAL
- FUNCTION
- GO
- GOTO
- IF
- IMPLICIT
- IN
- INOUT
- INQUIRE
- INTENT
- INTERFACE
- INTRINSIC
- MODULE
- NAMELIST
- NONE
- NULLIFY
- ONLY
- OPEN
- OPERATOR
- OPTIONAL
- OUT
- PARAMETER
- PAUSE
- POINTER
- PRINT
- PRIVATE
- PROCEDURE
- PROGRAM
- PUBLIC
- READ
- RECURSIVE
- RESULT
- RETURN
- REWIND
- SAVE
- SELECT
- SEQUENCE
- STOP
- SUBROUTINE
- TARGET
- THEN
- TO
- TYPE
- USE
- WHERE
- WHILE
- WRITE
named-args_upper:
- ACCESS
- ACTION
- ADVANCE
- BLANK
- DELIM
- DIRECT
- EOR
- ERR
- EXIST
- FILE
- FMT
- FORM
- FORMAT
- FORMATTED
- IOLENGTH
- IOSTAT
- KIND
- LEN
- NAME
- NAMED
- NEXTREC
- NML
- NUMBER
- OPENED
- PAD
- POSITION
- READWRITE
- REC
- RECL
- SEQUENTIAL
- SIZE
- STAT
- STATUS
- UNFORMATTED
- UNIT