-
Notifications
You must be signed in to change notification settings - Fork 11
/
lint_local.py
120 lines (112 loc) · 3.01 KB
/
lint_local.py
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
import subprocess
import argparse
from pathlib import Path
env = {
"SUPPRESS_POSSUM": "true",
"RUN_LOCAL": "true",
"USE_FIND_ALGORITHM": "true",
"LOG_LEVEL": "VERBOSE",
}
validators = {
"VALIDATE_ANSIBLE",
"VALIDATE_ARM",
"VALIDATE_BASH",
"VALIDATE_BASH_EXEC",
"VALIDATE_CPP",
"VALIDATE_CLANG_FORMAT",
"VALIDATE_CLOJURE",
"VALIDATE_CLOUDFORMATION",
"VALIDATE_COFFEESCRIPT",
"VALIDATE_CSHARP",
"VALIDATE_CSS",
"VALIDATE_DART",
"VALIDATE_DOCKERFILE_HADOLINT",
"VALIDATE_EDITORCONFIG",
"VALIDATE_ENV",
"VALIDATE_GHERKIN",
"VALIDATE_GITHUB_ACTIONS",
"VALIDATE_GITLEAKS",
"VALIDATE_GO",
"VALIDATE_GOOGLE_JAVA_FORMAT",
"VALIDATE_GROOVY",
"VALIDATE_HTML",
"VALIDATE_JAVA",
"VALIDATE_JAVASCRIPT_ES",
"VALIDATE_JAVASCRIPT_STANDARD",
"VALIDATE_JSCPD",
"VALIDATE_JSON",
"VALIDATE_JSX",
"VALIDATE_KOTLIN",
"VALIDATE_KOTLIN_ANDROID",
"VALIDATE_KUBERNETES_KUBECONFORM",
"VALIDATE_LATEX",
"VALIDATE_LUA",
"VALIDATE_MARKDOWN",
"VALIDATE_NATURAL_LANGUAGE",
"VALIDATE_OPENAPI",
"VALIDATE_PERL",
"VALIDATE_PHP",
"VALIDATE_PHP_BUILTIN",
"VALIDATE_PHP_PHPCS",
"VALIDATE_PHP_PHPSTAN",
"VALIDATE_PHP_PSALM",
"VALIDATE_POWERSHELL",
"VALIDATE_PROTOBUF",
"VALIDATE_PYTHON",
"VALIDATE_PYTHON_BLACK",
"VALIDATE_PYTHON_FLAKE8",
"VALIDATE_PYTHON_ISORT",
"VALIDATE_PYTHON_MYPY",
"VALIDATE_PYTHON_PYLINT",
"VALIDATE_R",
"VALIDATE_RAKU",
"VALIDATE_RUBY",
"VALIDATE_RUST_2015",
"VALIDATE_RUST_2018",
"VALIDATE_RUST_2021",
"VALIDATE_RUST_CLIPPY",
"VALIDATE_SCALAFMT",
"VALIDATE_SHELL_SHFMT",
"VALIDATE_SNAKEMAKE_LINT",
"VALIDATE_SNAKEMAKE_SNAKEFMT",
"VALIDATE_STATES",
"VALIDATE_SQL",
"VALIDATE_SQLFLUFF",
"VALIDATE_TEKTON",
"VALIDATE_TERRAFORM_FMT",
"VALIDATE_TERRAFORM_TERRASCAN",
"VALIDATE_TERRAFORM_TFLINT",
"VALIDATE_TERRAGRUNT",
"VALIDATE_TSX",
"VALIDATE_TYPESCRIPT_ES",
"VALIDATE_TYPESCRIPT_STANDARD",
"VALIDATE_XML",
"VALIDATE_YAML",
}
# To fix
# BASH:[14]
# DOCKERFILE_HADOLINT:[2]
# PYTHON_PYLINT:[4]
# PYTHON_FLAKE8:[17]
# PYTHON_ISORT:[25]
# PYTHON_MYPY:[13]
# TERRAFORM_TFLINT:[8]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--dir", default=".")
parser.add_argument("--image", default="github/super-linter:latest")
parser.add_argument("-l", "--lint", default="")
args = parser.parse_args()
volume = Path(args.dir).resolve()
cmd = ["docker", "run", "-v", f"{volume}:/tmp/lint"]
linters = [x.strip() for x in args.lint.split(",") if x.strip() != ""]
for key, value in env.items():
cmd.append("-e")
cmd.append(f"{key}={value}")
for validator in validators:
if not any(linter.lower() in validator.lower() for linter in linters):
cmd.append("-e")
cmd.append(f"{validator}=false")
cmd.append(args.image)
p = subprocess.run(cmd)
exit(p.returncode)