mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 07:12:11 -05:00
adding black
This commit is contained in:
parent
ed3ae28ee8
commit
1f2c569c21
8 changed files with 233 additions and 70 deletions
|
@ -8,19 +8,21 @@ from dotenv import load_dotenv # pylint: disable=import-error
|
|||
import requests # pylint: disable=import-error
|
||||
|
||||
env = load_dotenv()
|
||||
api_url = getenv('API_URL', default='https://api.github.com/graphql')
|
||||
api_url = getenv("API_URL", default="https://api.github.com/graphql")
|
||||
github_token = getenv("GITHUB_TOKEN", default=None)
|
||||
|
||||
if github_token is None:
|
||||
sys.exit("GitHub Token is not set." +
|
||||
"Please set the GITHUB_TOKEN env variable in your system or " +
|
||||
"the .env file of your project.")
|
||||
sys.exit(
|
||||
"GitHub Token is not set."
|
||||
+ "Please set the GITHUB_TOKEN env variable in your system or "
|
||||
+ "the .env file of your project."
|
||||
)
|
||||
|
||||
client_id = getenv('CLIENT_ID', default='copy_labels.py')
|
||||
client_id = getenv("CLIENT_ID", default="copy_labels.py")
|
||||
headers = {
|
||||
'Authorization': 'bearer {github_token}'.format(github_token=github_token),
|
||||
'Accept': 'application/vnd.github.bane-preview+json',
|
||||
'Content-Type': 'application/json'
|
||||
"Authorization": "bearer {github_token}".format(github_token=github_token),
|
||||
"Accept": "application/vnd.github.bane-preview+json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,20 +42,21 @@ def create_label(repo_id, label):
|
|||
"color": label["color"],
|
||||
"description": label["description"],
|
||||
"name": label["name"],
|
||||
"repositoryId": repo_id
|
||||
"repositoryId": repo_id,
|
||||
}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/create_label.gql'), 'r') as query_file:
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/create_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
print('Created label {label}'.format(label=label["name"]))
|
||||
print("Created label {label}".format(label=label["name"]))
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_labels(owner, repo):
|
||||
"""
|
||||
Gets a list of labels from the supplied repo.
|
||||
|
@ -64,9 +67,14 @@ def get_labels(owner, repo):
|
|||
:return: A tuple with the GitHub id for the repository and a list of labels defined in the repository
|
||||
"""
|
||||
|
||||
query_variables = {"owner": owner, "name": repo, }
|
||||
query_variables = {
|
||||
"owner": owner,
|
||||
"name": repo,
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/get_repo_data.gql'), 'r') as query_file:
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/get_repo_data.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
|
@ -82,9 +90,10 @@ def get_labels(owner, repo):
|
|||
return repo_id, labels
|
||||
else:
|
||||
raise Exception(
|
||||
'[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}'.format(
|
||||
status_code=status_code, result=result["message"]))
|
||||
|
||||
"[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}".format(
|
||||
status_code=status_code, result=result["message"]
|
||||
)
|
||||
)
|
||||
|
||||
def delete_label(label_id):
|
||||
"""
|
||||
|
@ -95,13 +104,12 @@ def delete_label(label_id):
|
|||
"""
|
||||
|
||||
query_variables = {
|
||||
"deleteLabelInput": {
|
||||
"clientMutationId": client_id,
|
||||
"id": label_id,
|
||||
}
|
||||
"deleteLabelInput": {"clientMutationId": client_id, "id": label_id}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/delete_label.gql'), 'r') as query_file:
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/delete_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
|
@ -109,11 +117,10 @@ def delete_label(label_id):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--dry', is_flag=True)
|
||||
@click.argument('source_repo')
|
||||
@click.argument('target_repo')
|
||||
@click.option("--dry", is_flag=True)
|
||||
@click.argument("source_repo")
|
||||
@click.argument("target_repo")
|
||||
def copy_labels(source_repo, target_repo, dry):
|
||||
"""
|
||||
Copy labels from the source repository to the target repository.
|
||||
|
@ -128,31 +135,55 @@ def copy_labels(source_repo, target_repo, dry):
|
|||
target_owner, target_repo_name = target_repo.split("/")
|
||||
|
||||
try:
|
||||
print('Fetching labels for {source_repo_name} repo.'.format(source_repo_name=source_repo_name))
|
||||
print(
|
||||
"Fetching labels for {source_repo_name} repo.".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
_, source_repo_labels = get_labels(source_owner, source_repo_name)
|
||||
print('Fetched labels for {source_repo_name}'.format(source_repo_name=source_repo_name))
|
||||
print(
|
||||
"Fetched labels for {source_repo_name}".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
print('Fetching labels for {target_repo_name} repo.'.format(target_repo_name=target_repo_name))
|
||||
print(
|
||||
"Fetching labels for {target_repo_name} repo.".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
target_repo_id, target_repo_labels = get_labels(target_owner, target_repo_name)
|
||||
print('Fetched labels for {target_repo_name}'.format(target_repo_name=target_repo_name))
|
||||
print(
|
||||
"Fetched labels for {target_repo_name}".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
filtered_labels = list(filter(lambda x: x not in target_repo_labels, source_repo_labels))
|
||||
filtered_labels = list(
|
||||
filter(lambda x: x not in target_repo_labels, source_repo_labels)
|
||||
)
|
||||
|
||||
if dry:
|
||||
print('This is just a dry run. No labels will be copied/created.')
|
||||
print('{label_count} labels would have been created.'.format(label_count=len(filtered_labels)))
|
||||
print("This is just a dry run. No labels will be copied/created.")
|
||||
print(
|
||||
"{label_count} labels would have been created.".format(
|
||||
label_count=len(filtered_labels)
|
||||
)
|
||||
)
|
||||
pprint(filtered_labels, indent=4)
|
||||
else:
|
||||
print('Preparing to created {label_count} labels in {target_repo}'.format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo))
|
||||
print(
|
||||
"Preparing to created {label_count} labels in {target_repo}".format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo
|
||||
)
|
||||
)
|
||||
|
||||
for label in filtered_labels:
|
||||
create_label(target_repo_id, label)
|
||||
except Exception as error:
|
||||
sys.exit(error)
|
||||
|
||||
print('Done')
|
||||
|
||||
print("Done")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Pylint doesn't know that @click.command takes care of injecting the
|
||||
|
|
|
@ -73,8 +73,8 @@ RUN apk add --update --no-cache \
|
|||
py3-setuptools \
|
||||
R \
|
||||
readline-dev \
|
||||
ruby ruby-dev ruby-bundler ruby-rdoc
|
||||
|
||||
ruby ruby-dev ruby-bundler ruby-rdoc
|
||||
|
||||
|
||||
########################################
|
||||
# Copy dependencies files to container #
|
||||
|
@ -308,8 +308,9 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
|
|||
VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \
|
||||
VALIDATE_PROTOBUF=${VALIDATE_PROTOBUF} \
|
||||
VALIDATE_PYTHON=${VALIDATE_PYTHON} \
|
||||
VALIDATE_PYTHON_PYLINT=${VALIDATE_PYTHON_PYLINT} \
|
||||
VALIDATE_PYTHON_BLACK=${VALIDATE_PYTHON_BLACK} \
|
||||
VALIDATE_PYTHON_FLAKE8=${VALIDATE_PYTHON_FLAKE8} \
|
||||
VALIDATE_PYTHON_PYLINT=${VALIDATE_PYTHON_PYLINT} \
|
||||
VALIDATE_R=${VALIDATE_R} \
|
||||
VALIDATE_RAKU=${VALIDATE_RAKU} \
|
||||
VALIDATE_RUBY=${VALIDATE_RUBY} \
|
||||
|
|
|
@ -68,7 +68,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **PHP** | [PHP built-in linter](https://www.php.net/) / [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) / [PHPStan](https://phpstan.org/n) / [Psalm](https://psalm.dev/) |
|
||||
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
||||
| **Protocol Buffers** | [protolint](https://github.com/yoheimuta/protolint) |
|
||||
| **Python3** | [pylint](https://www.pylint.org/) / [flake8](https://flake8.pycqa.org/en/latest/) |
|
||||
| **Python3** | [pylint](https://www.pylint.org/) / [flake8](https://flake8.pycqa.org/en/latest/) / [black](https://github.com/psf/black) |
|
||||
| **R** | [lintr](https://github.com/jimhester/lintr) |
|
||||
| **Raku** | [Raku](https://raku.org) |
|
||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||
|
@ -226,6 +226,7 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) (keep for backward compatibility) |
|
||||
| **VALIDATE_PYTHON_PYLINT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: pylint) |
|
||||
| **VALIDATE_PYTHON_FLAKE8** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: flake8) |
|
||||
| **VALIDATE_PYTHON_BLACK** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: black) |
|
||||
| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the Powershell language. |
|
||||
| **VALIDATE_R** | `true` | Flag to enable or disable the linting process of the R language. |
|
||||
| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. |
|
||||
|
|
12
dependencies/Pipfile
vendored
12
dependencies/Pipfile
vendored
|
@ -6,12 +6,16 @@ verify_ssl = true
|
|||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
yamllint = "*"
|
||||
pylint = "*"
|
||||
yq = "*"
|
||||
black = "*"
|
||||
cfn-lint = "*"
|
||||
terrascan = "*"
|
||||
flake8 = "*"
|
||||
pylint = "*"
|
||||
terrascan = "*"
|
||||
yamllint = "*"
|
||||
yq = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
|
||||
[pipenv]
|
||||
allow_prereleases = true
|
||||
|
|
100
dependencies/Pipfile.lock
generated
vendored
100
dependencies/Pipfile.lock
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "f8ea3853c4bb4533103043533d08982436551678c827f59809c94bf0ee54a187"
|
||||
"sha256": "1f13d59524584eca4db2ae57cf6d3acd02250a28bce7bee9414f21c45cae09af"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
@ -16,6 +16,13 @@
|
|||
]
|
||||
},
|
||||
"default": {
|
||||
"appdirs": {
|
||||
"hashes": [
|
||||
"sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41",
|
||||
"sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"
|
||||
],
|
||||
"version": "==1.4.4"
|
||||
},
|
||||
"argcomplete": {
|
||||
"hashes": [
|
||||
"sha256:2fbe5ed09fd2c1d727d4199feca96569a5b50d44c71b16da9c742201f7cc295c",
|
||||
|
@ -28,6 +35,7 @@
|
|||
"sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703",
|
||||
"sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386"
|
||||
],
|
||||
"markers": "python_version >= '3.5'",
|
||||
"version": "==2.4.2"
|
||||
},
|
||||
"attrs": {
|
||||
|
@ -35,6 +43,7 @@
|
|||
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
|
||||
"sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==19.3.0"
|
||||
},
|
||||
"aws-sam-translator": {
|
||||
|
@ -45,19 +54,27 @@
|
|||
],
|
||||
"version": "==1.26.0"
|
||||
},
|
||||
"black": {
|
||||
"hashes": [
|
||||
"sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b",
|
||||
"sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==19.10b0"
|
||||
},
|
||||
"boto3": {
|
||||
"hashes": [
|
||||
"sha256:640a8372ce0edfbb84a8f63584a0b64c78d61a751a27c2a47f92d2ebaf021ce4",
|
||||
"sha256:a6c9a3d3abbad2ff2e5751af599492a9271633a7c9fef343482524464c53e451"
|
||||
"sha256:1cfbadf41777dade69a3e5eaf1b71d15b4ae616fd94d16a894b692e14319f4a2",
|
||||
"sha256:cc3636828f1677ff93e8b1130c90dfe800187964e33786711450e8653d3f245f"
|
||||
],
|
||||
"version": "==1.14.43"
|
||||
"version": "==1.14.46"
|
||||
},
|
||||
"botocore": {
|
||||
"hashes": [
|
||||
"sha256:3fb144d2b5d705127f394f7483737ece6fa79577ca7c493e4f42047ac8636200",
|
||||
"sha256:f8801ce7f7603922ccab1c86c448e802f94183e31d99457e85fb9985a20d3abc"
|
||||
"sha256:2f15a755b990db13a7a9e06a124c6ca5fa1c4470d76672363024d7f2a6c2566c",
|
||||
"sha256:6b134681c938f00b28424abf4b46fa6034b516d8add3a3f524e2292db61aa070"
|
||||
],
|
||||
"version": "==1.17.43"
|
||||
"version": "==1.17.46"
|
||||
},
|
||||
"cfn-lint": {
|
||||
"hashes": [
|
||||
|
@ -67,6 +84,14 @@
|
|||
"index": "pypi",
|
||||
"version": "==0.35.0"
|
||||
},
|
||||
"click": {
|
||||
"hashes": [
|
||||
"sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
|
||||
"sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==7.1.2"
|
||||
},
|
||||
"decorator": {
|
||||
"hashes": [
|
||||
"sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760",
|
||||
|
@ -80,6 +105,7 @@
|
|||
"sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827",
|
||||
"sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99"
|
||||
],
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==0.15.2"
|
||||
},
|
||||
"flake8": {
|
||||
|
@ -95,6 +121,7 @@
|
|||
"sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1",
|
||||
"sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==4.3.21"
|
||||
},
|
||||
"jmespath": {
|
||||
|
@ -102,6 +129,7 @@
|
|||
"sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9",
|
||||
"sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f"
|
||||
],
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==0.10.0"
|
||||
},
|
||||
"jsonpatch": {
|
||||
|
@ -117,6 +145,7 @@
|
|||
"sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362",
|
||||
"sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.0"
|
||||
},
|
||||
"jsonschema": {
|
||||
|
@ -156,6 +185,7 @@
|
|||
"sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4",
|
||||
"sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==1.4.3"
|
||||
},
|
||||
"mccabe": {
|
||||
|
@ -185,6 +215,7 @@
|
|||
"sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367",
|
||||
"sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.6.0"
|
||||
},
|
||||
"pyflakes": {
|
||||
|
@ -192,6 +223,7 @@
|
|||
"sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92",
|
||||
"sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.2.0"
|
||||
},
|
||||
"pyhcl": {
|
||||
|
@ -219,6 +251,7 @@
|
|||
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
|
||||
"sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==2.8.1"
|
||||
},
|
||||
"pyyaml": {
|
||||
|
@ -238,6 +271,32 @@
|
|||
"markers": "python_version != '3.4'",
|
||||
"version": "==5.3.1"
|
||||
},
|
||||
"regex": {
|
||||
"hashes": [
|
||||
"sha256:0dc64ee3f33cd7899f79a8d788abfbec168410be356ed9bd30bbd3f0a23a7204",
|
||||
"sha256:1269fef3167bb52631ad4fa7dd27bf635d5a0790b8e6222065d42e91bede4162",
|
||||
"sha256:14a53646369157baa0499513f96091eb70382eb50b2c82393d17d7ec81b7b85f",
|
||||
"sha256:3a3af27a8d23143c49a3420efe5b3f8cf1a48c6fc8bc6856b03f638abc1833bb",
|
||||
"sha256:46bac5ca10fb748d6c55843a931855e2727a7a22584f302dd9bb1506e69f83f6",
|
||||
"sha256:4c037fd14c5f4e308b8370b447b469ca10e69427966527edcab07f52d88388f7",
|
||||
"sha256:51178c738d559a2d1071ce0b0f56e57eb315bcf8f7d4cf127674b533e3101f88",
|
||||
"sha256:5ea81ea3dbd6767873c611687141ec7b06ed8bab43f68fad5b7be184a920dc99",
|
||||
"sha256:6961548bba529cac7c07af2fd4d527c5b91bb8fe18995fed6044ac22b3d14644",
|
||||
"sha256:75aaa27aa521a182824d89e5ab0a1d16ca207318a6b65042b046053cfc8ed07a",
|
||||
"sha256:7a2dd66d2d4df34fa82c9dc85657c5e019b87932019947faece7983f2089a840",
|
||||
"sha256:8a51f2c6d1f884e98846a0a9021ff6861bdb98457879f412fdc2b42d14494067",
|
||||
"sha256:9c568495e35599625f7b999774e29e8d6b01a6fb684d77dee1f56d41b11b40cd",
|
||||
"sha256:9eddaafb3c48e0900690c1727fba226c4804b8e6127ea409689c3bb492d06de4",
|
||||
"sha256:bbb332d45b32df41200380fff14712cb6093b61bd142272a10b16778c418e98e",
|
||||
"sha256:bc3d98f621898b4a9bc7fecc00513eec8f40b5b83913d74ccb445f037d58cd89",
|
||||
"sha256:c11d6033115dc4887c456565303f540c44197f4fc1a2bfb192224a301534888e",
|
||||
"sha256:c50a724d136ec10d920661f1442e4a8b010a4fe5aebd65e0c2241ea41dbe93dc",
|
||||
"sha256:d0a5095d52b90ff38592bbdc2644f17c6d495762edf47d876049cfd2968fbccf",
|
||||
"sha256:d6cff2276e502b86a25fd10c2a96973fdb45c7a977dca2138d661417f3728341",
|
||||
"sha256:e46d13f38cfcbb79bfdb2964b0fe12561fe633caf964a77a5f8d4e45fe5d2ef7"
|
||||
],
|
||||
"version": "==2020.7.14"
|
||||
},
|
||||
"s3transfer": {
|
||||
"hashes": [
|
||||
"sha256:2482b4259524933a022d59da830f51bd746db62f047d6eb213f2f8855dcb8a13",
|
||||
|
@ -250,6 +309,7 @@
|
|||
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
|
||||
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"version": "==1.15.0"
|
||||
},
|
||||
"terrascan": {
|
||||
|
@ -267,6 +327,32 @@
|
|||
],
|
||||
"version": "==0.10.1"
|
||||
},
|
||||
"typed-ast": {
|
||||
"hashes": [
|
||||
"sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355",
|
||||
"sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919",
|
||||
"sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa",
|
||||
"sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652",
|
||||
"sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75",
|
||||
"sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01",
|
||||
"sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d",
|
||||
"sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1",
|
||||
"sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907",
|
||||
"sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c",
|
||||
"sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3",
|
||||
"sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b",
|
||||
"sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614",
|
||||
"sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb",
|
||||
"sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b",
|
||||
"sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41",
|
||||
"sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6",
|
||||
"sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34",
|
||||
"sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe",
|
||||
"sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4",
|
||||
"sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7"
|
||||
],
|
||||
"version": "==1.4.1"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a",
|
||||
|
|
|
@ -41,8 +41,9 @@ For some linters it is also possible to override rules on a case by case level w
|
|||
- [Perl](#perl)
|
||||
- [PHP](#php)
|
||||
- [Protocol Buffers](#protocol-buffers)
|
||||
- [Python3 pylint](#python3-pylint)
|
||||
- [Python3 black](#python3-black)
|
||||
- [Python3 flake8](#python3-flake8)
|
||||
- [Python3 pylint](#python3-pylint)
|
||||
- [R](#r)
|
||||
- [Raku](#raku)
|
||||
- [Ruby](#ruby)
|
||||
|
@ -940,6 +941,29 @@ var = "terrible code down here..."
|
|||
```
|
||||
|
||||
---
|
||||
|
||||
## Python3 black
|
||||
|
||||
- `https://black.readthedocs.io/en/stable/installation_and_usage.html#`
|
||||
|
||||
### Black Config file
|
||||
|
||||
- There is no top level _configuration file_ available at this time
|
||||
|
||||
### Black disable single line
|
||||
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
### Black disable code block
|
||||
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
### Black disable entire file
|
||||
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
---
|
||||
|
||||
## R
|
||||
|
||||
- [lintr](https://github.com/jimhester/lintr)
|
||||
|
|
|
@ -133,7 +133,7 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya
|
|||
#######################################
|
||||
# Linter array for information prints #
|
||||
#######################################
|
||||
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'cfn-lint' 'checkstyle' 'chktex' 'clj-kondo' 'coffeelint'
|
||||
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'black' 'cfn-lint' 'checkstyle' 'chktex' 'clj-kondo' 'coffeelint'
|
||||
'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint'
|
||||
'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lintr' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint'
|
||||
'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint'
|
||||
|
@ -146,7 +146,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT'
|
|||
'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML'
|
||||
'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL'
|
||||
'PROTOBUF' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'STATES' 'SQL' 'TERRAFORM'
|
||||
'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'STATES' 'SQL' 'TERRAFORM'
|
||||
'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
|
||||
############################################
|
||||
|
@ -202,8 +202,9 @@ VALIDATE_PHP_PHPCS="${VALIDATE_PHP_PHPCS}" # Boolean t
|
|||
VALIDATE_PHP_PHPSTAN="${VALIDATE_PHP_PHPSTAN}" # Boolean to validate language
|
||||
VALIDATE_PHP_PSALM="${VALIDATE_PHP_PSALM}" # Boolean to validate language
|
||||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_FLAKE8="${VALIDATE_PYTHON_FLAKE8}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_BLACK="${VALIDATE_PYTHON_BLACK}" # Boolean to validate language
|
||||
VALIDATE_PYTHON_PYLINT="${VALIDATE_PYTHON:-$VALIDATE_PYTHON_PYLINT}" # Boolean to validate language
|
||||
VALIDATE_R="${VALIDATE_R}" # Boolean to validate language
|
||||
VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language
|
||||
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
||||
|
@ -302,6 +303,7 @@ FILE_ARRAY_PHP_PHPSTAN=() # Array of files to check
|
|||
FILE_ARRAY_PHP_PSALM=() # Array of files to check
|
||||
FILE_ARRAY_POWERSHELL=() # Array of files to check
|
||||
FILE_ARRAY_PROTOBUF=() # Array of files to check
|
||||
FILE_ARRAY_PYTHON_BLACK=() # Array of files to check
|
||||
FILE_ARRAY_PYTHON_PYLINT=() # Array of files to check
|
||||
FILE_ARRAY_PYTHON_FLAKE8=() # Array of files to check
|
||||
FILE_ARRAY_R=() # Array of files to check
|
||||
|
@ -349,8 +351,8 @@ ERRORS_FOUND_GROOVY=0 # Count of errors found
|
|||
export ERRORS_FOUND_GROOVY # Workaround SC2034
|
||||
ERRORS_FOUND_HTML=0 # Count of errors found
|
||||
export ERRORS_FOUND_HTML # Workaround SC2034
|
||||
ERRORS_FOUND_JAVA=0
|
||||
export ERRORS_FOUND_JAVA
|
||||
ERRORS_FOUND_JAVA=0 # Count of errors found
|
||||
export ERRORS_FOUND_JAVA # Workaround SC2034
|
||||
ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found
|
||||
export ERRORS_FOUND_JAVASCRIPT_STANDARD # Workaround SC2034
|
||||
ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found
|
||||
|
@ -383,6 +385,8 @@ ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
|||
export ERRORS_FOUND_POWERSHELL # Workaround SC2034
|
||||
ERRORS_FOUND_PROTOBUF=0 # Count of errors found
|
||||
export ERRORS_FOUND_PROTOBUF # Workaround SC2034
|
||||
ERRORS_FOUND_PYTHON_BLACK=0 # Count of errors found
|
||||
export ERRORS_FOUND_PYTHON_BLACK # Workaround SC2034
|
||||
ERRORS_FOUND_PYTHON_PYLINT=0 # Count of errors found
|
||||
export ERRORS_FOUND_PYTHON_PYLINT # Workaround SC2034
|
||||
ERRORS_FOUND_PYTHON_FLAKE8=0 # Count of errors found
|
||||
|
@ -1700,9 +1704,20 @@ if [ "${VALIDATE_PROTOBUF}" == "true" ]; then
|
|||
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}"
|
||||
fi
|
||||
|
||||
##################
|
||||
# PYTHON LINTING #
|
||||
##################
|
||||
########################
|
||||
# PYTHON BLACK LINTING #
|
||||
########################
|
||||
if [ "${VALIDATE_PYTHON_BLACK}" == "true" ]; then
|
||||
#########################
|
||||
# Lint the python files #
|
||||
#########################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "PYTHON_BLACK" "black" "black --diff --check" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_BLACK[@]}"
|
||||
fi
|
||||
|
||||
#########################
|
||||
# PYTHON PYLINT LINTING #
|
||||
#########################
|
||||
if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then
|
||||
#########################
|
||||
# Lint the python files #
|
||||
|
@ -1711,9 +1726,9 @@ if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then
|
|||
LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_PYLINT[@]}"
|
||||
fi
|
||||
|
||||
##################
|
||||
# PYTHON LINTING #
|
||||
##################
|
||||
#########################
|
||||
# PYTHON FLAKE8 LINTING #
|
||||
#########################
|
||||
if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then
|
||||
#########################
|
||||
# Lint the python files #
|
||||
|
@ -1722,9 +1737,9 @@ if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then
|
|||
LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON_FLAKE8[@]}"
|
||||
fi
|
||||
|
||||
################
|
||||
#############
|
||||
# R LINTING #
|
||||
################
|
||||
#############
|
||||
if [ "${VALIDATE_R}" == "true" ]; then
|
||||
##########################
|
||||
# Check for local config #
|
||||
|
|
|
@ -220,7 +220,7 @@ function LintCodebase() {
|
|||
fi
|
||||
LINT_CMD=$(
|
||||
cd "$r_dir" || exit
|
||||
R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1
|
||||
R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1
|
||||
)
|
||||
#LINTER_COMMAND="lintr::lint('${FILE}')"
|
||||
else
|
||||
|
@ -452,8 +452,8 @@ function TestCodebase() {
|
|||
#######################################
|
||||
LINT_CMD=$(
|
||||
cd "${GITHUB_WORKSPACE}" || exit
|
||||
R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1
|
||||
)
|
||||
R --slave -e "errors <- lintr::lint('$FILE');print(errors);quit(save = 'no', status = if (length(errors) > 0) 1 else 0)" 2>&1
|
||||
)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
|
@ -636,8 +636,9 @@ function RunTestCases() {
|
|||
TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi"
|
||||
TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell"
|
||||
TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf"
|
||||
TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python"
|
||||
TestCodebase "PYTHON_BLACK" "black" "black --diff --check" ".*\.\(py\)\$" "python"
|
||||
TestCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config ${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "python"
|
||||
TestCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "python"
|
||||
TestCodebase "R" "lintr" "lintr::lint()" ".*\.\(r\|rmd\)\$" "r"
|
||||
TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku"
|
||||
TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby"
|
||||
|
|
Loading…
Reference in a new issue