-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsqlfluff.ts
569 lines (569 loc) · 18.5 KB
/
sqlfluff.ts
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
const completionSpec: Fig.Spec = {
name: "sqlfluff",
description: "A dialect-flexible and configurable SQL linter",
options: [
{
name: "--version",
description: "Show the version and exit",
isPersistent: true,
},
{
name: ["--help", "-h"],
description: "Show help for sqlfluff",
isPersistent: true,
},
],
subcommands: [
{
name: "lint",
description: "Lint SQL files via passing a list of files or using stdin",
args: {
template: "filepaths",
isOptional: true,
isVariadic: true,
},
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--ignore", "-i"],
description:
"Ignore particular families of errors so that they don’t cause a failed run. -–ignore behaves somewhat like noqa comments, except it applies globally",
args: { name: "error" },
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
{
name: ["--exclude-rules", "-e"],
description:
"Exclude specific rules. This could either be the allowlist, or the general set if there is no specific allowlist",
args: {
name: "exclude_rules",
},
},
{
name: ["--rules", "-r"],
description: "Narrow the search to only specific rules",
args: {
name: "rules",
},
},
{
name: ["--templater", "-t"],
description: "The templater to use (default=jinja)",
args: {
name: "templater",
description: "Name of templater to use, eg. raw",
suggestions: ["raw", "jinja", "python", "placeholders"],
},
},
{
name: ["--dialect", "-d"],
description: "The dialect of SQL to lint",
args: {
name: "dialect",
description: "Name of dialect, eg. ANSI",
suggestions: [
"ansi",
"bigquery",
"exasol",
"hive",
"mysql",
"oracle",
"postgres",
"redshift",
"snowflake",
"spark3",
"sqllite",
"teradata",
"tsql",
],
},
},
{
name: ["--format", "-f"],
description:
"What format to return the lint result in (default=human)",
args: {
name: "format",
suggestions: [
"human",
"json",
"yaml",
"github-annotation",
"github-annotation-native",
],
},
},
{
name: ["--processes", "-p"],
description:
"The number of parallel processes to run. Positive numbers work as expected. Zero and negative numbers will work as number_of_cpus - number. e.g -1 means all cpus except one. 0 means all cpus",
args: {
name: "processes",
},
},
{
name: "--disable-noqa",
description: "Set this flag to ignore inline noqa comments",
},
{
name: "--bench",
description: "Set this flag to engage the benchmarking tool output",
},
{
name: "--logger",
description: "Choose to limit the logging to one of the loggers",
args: {
name: "logger",
description: "Name of logger to limit to, eg. templater",
suggestions: ["templater", "lexer", "parser", "linter", "rules"],
},
},
{
name: "--encoding",
description:
"Specify encoding to use when reading and writing files. Defaults to autodetect",
args: {
name: "encoding",
},
},
{
name: "--ignore-local-config",
description:
"Ignore config files in default search path locations. This option allows the user to lint with the default config or can be used in conjunction with –config to only reference the custom config file",
},
{
name: "--config",
description:
"Include additional config file. By default the config is generated from the standard configuration files described in the documentation. This argument allows you to specify an additional configuration file that overrides the standard configuration files. N.B. cfg format is required",
args: {
name: "extra_config_path",
template: "filepaths",
},
},
{
name: "--write-output",
description:
"Optionally provide a filename to write the results to, mostly used in tandem with –format. NB: Setting an output file re-enables normal stdout logging",
args: {
name: "write_output",
template: "filepaths",
},
},
{
name: "--annotation-level",
description:
"When format is set to github-annotation or github-annotation-native, default annotation level (default=notice). failure and error are equivalent",
args: {
name: "annotation-level",
description: "Level of annotation, eg. notice",
suggestions: ["notice", "warning", "failure", "error"],
},
},
{
name: "--disregard-sqlfluffignores",
description:
"Perform the operation regardless of .sqlfluffignore configurations",
},
{
name: "--disable-progress-bar",
description: "Disables progress bars",
},
{
name: "--nofail",
description:
"If set, the exit code will always be zero, regardless of violations found. This is potentially useful during rollout",
},
{
name: ["--help", "-h"],
description: "Show help for sqlfluff",
},
],
},
{
name: "fix",
description: "Fix SQL files",
args: {
template: "filepaths",
isOptional: true,
isVariadic: true,
},
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--ignore", "-i"],
description:
"Ignore particular families of errors so that they don’t cause a failed run. -–ignore behaves somewhat like noqa comments, except it applies globally",
args: {
name: "errors",
},
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
{
name: ["--exclude-rules", "-e"],
description:
"Exclude specific rules. This could either be the allowlist, or the general set if there is no specific allowlist",
args: {
name: "exclude_rules",
},
},
{
name: ["--rules", "-r"],
description: "Narrow the search to only specific rules",
args: {
name: "rules",
},
},
{
name: ["--templater", "-t"],
description: "The templater to use (default=jinja)",
args: {
name: "templater",
description: "Name of templater to use, eg. raw",
suggestions: ["raw", "jinja", "python", "placeholders"],
},
},
{
name: ["--dialect", "-d"],
description: "The dialect of SQL to lint",
args: {
name: "dialect",
description: "Name of dialect, eg. ANSI",
suggestions: [
"ansi",
"bigquery",
"exasol",
"hive",
"mysql",
"oracle",
"postgres",
"redshift",
"snowflake",
"spark3",
"sqllite",
"teradata",
"tsql",
],
},
},
{
name: ["--format", "-f"],
description:
"What format to return the lint result in (default=human)",
args: {
name: "format",
suggestions: [
"human",
"json",
"yaml",
"github-annotation",
"github-annotation-native",
],
},
},
{
name: ["--processes", "-p"],
description:
"The number of parallel processes to run. Positive numbers work as expected. Zero and negative numbers will work as number_of_cpus - number. e.g -1 means all cpus except one. 0 means all cpus",
args: {
name: "processes",
},
},
{
name: ["--fixed-suffix", "-x"],
description: "An optional suffix to add to fixed files",
args: {
name: "fixed_suffix",
},
},
{
name: "--disable-noqa",
description: "Set this flag to ignore inline noqa comments",
},
{
name: "--bench",
description: "Set this flag to engage the benchmarking tool output",
},
{
name: "--logger",
description: "Choose to limit the logging to one of the loggers",
args: {
name: "logger",
description: "Name of logger to limit to, eg. templater",
suggestions: ["templater", "lexer", "parser", "linter", "rules"],
},
},
{
name: "--encoding",
description:
"Specify encoding to use when reading and writing files. Defaults to autodetect",
args: {
name: "encoding",
},
},
{
name: "--ignore-local-config",
description:
"Ignore config files in default search path locations. This option allows the user to lint with the default config or can be used in conjunction with –config to only reference the custom config file",
},
{
name: "--config",
description:
"Include additional config file. By default the config is generated from the standard configuration files described in the documentation. This argument allows you to specify an additional configuration file that overrides the standard configuration files. N.B. cfg format is required",
args: {
name: "extra_config_path",
template: "filepaths",
},
},
{
name: "--write-output",
description:
"Optionally provide a filename to write the results to, mostly used in tandem with –format. NB: Setting an output file re-enables normal stdout logging",
args: {
name: "write_output",
template: "filepaths",
},
},
{
name: "--disable-progress-bar",
description: "Disables progress bars",
},
{
name: "--FIX-EVEN-UNPARSABLE",
description:
"Enables fixing of files that have templating or parse errors",
},
{
name: "--show-lint-violations",
description: "Show lint violations",
},
],
},
{
name: "parse",
description: "Parse SQL files and just spit out the result",
args: {
template: "filepaths",
},
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--ignore", "-i"],
description:
"Ignore particular families of errors so that they don’t cause a failed run. -–ignore behaves somewhat like noqa comments, except it applies globally",
args: {
name: "errors",
},
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
{
name: ["--exclude-rules", "-e"],
description:
"Exclude specific rules. This could either be the allowlist, or the general set if there is no specific allowlist",
args: {
name: "exclude_rules",
},
},
{
name: ["--rules", "-r"],
description: "Narrow the search to only specific rules",
args: {
name: "rules",
},
},
{
name: ["--templater", "-t"],
description: "The templater to use (default=jinja)",
args: {
name: "templater",
description: "Name of templater to use, eg. raw",
suggestions: ["raw", "jinja", "python", "placeholders"],
},
},
{
name: ["--dialect", "-d"],
description: "The dialect of SQL to lint",
args: {
name: "dialect",
description: "Name of dialect, eg. ANSI",
suggestions: [
"ansi",
"bigquery",
"exasol",
"hive",
"mysql",
"oracle",
"postgres",
"redshift",
"snowflake",
"spark3",
"sqllite",
"teradata",
"tsql",
],
},
},
{
name: ["--code-only", "-c"],
description: "Output only the code elements of the parse tree",
},
{
name: ["--include-meta", "-m"],
description:
"Include meta segments (indents, dedents and placeholders) in the output. This only applies when outputting json or yaml",
},
{
name: ["--format", "-f"],
description:
"What format to return the lint result in (default=human)",
args: {
name: "format",
suggestions: [
"human",
"json",
"yaml",
"github-annotation",
"github-annotation-native",
],
},
},
{
name: "--disable-noqa",
description: "Set this flag to ignore inline noqa comments",
},
{
name: "--bench",
description: "Set this flag to engage the benchmarking tool output",
},
{
name: "--recurse",
description: "The depth to recursively parse to (0 for unlimited)",
args: {
name: "recurse",
},
},
{
name: "--logger",
description: "Choose to limit the logging to one of the loggers",
args: {
name: "logger",
description: "Name of logger to limit to, eg. templater",
suggestions: ["templater", "lexer", "parser", "linter", "rules"],
},
},
{
name: "--encoding",
description:
"Specify encoding to use when reading and writing files. Defaults to autodetect",
args: {
name: "encoding",
},
},
{
name: "--ignore-local-config",
description:
"Ignore config files in default search path locations. This option allows the user to lint with the default config or can be used in conjunction with –config to only reference the custom config file",
},
{
name: "--config",
description:
"Include additional config file. By default the config is generated from the standard configuration files described in the documentation. This argument allows you to specify an additional configuration file that overrides the standard configuration files. N.B. cfg format is required",
args: {
name: "extra_config_path",
template: "filepaths",
},
},
{
name: "--write-output",
description:
"Optionally provide a filename to write the results to, mostly used in tandem with –format. NB: Setting an output file re-enables normal stdout logging",
args: {
name: "write_output",
template: "filepaths",
},
},
{
name: "--profiler",
description: "Set this flag to engage the python profiler",
},
{
name: "--nofail",
description:
"If set, the exit code will always be zero, regardless of violations found. This is potentially useful during rollout",
},
],
},
{
name: "dialects",
description: "Show the current dialects available",
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
],
},
{
name: "version",
description: "Show the version of sqlfluff",
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
],
},
{
name: "rules",
description: "Show the current rules in use",
options: [
{
name: ["--nocolor", "-n"],
description: "No color - output will be without ANSI color codes",
},
{
name: ["--verbose", "-v"],
description:
"Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv",
isRepeatable: 5,
},
],
},
],
};
export default completionSpec;