CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
106 lines
2.8 KiB
Python
106 lines
2.8 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Common lint functions applicable to multiple types of files.
|
|
|
|
from __future__ import print_function
|
|
import re
|
|
|
|
|
|
def VerifyLineLength(filename, lines, max_length):
|
|
"""Checks to make sure the file has no lines with lines exceeding the length
|
|
limit.
|
|
|
|
Args:
|
|
filename: the file under consideration as string
|
|
lines: contents of the file as string array
|
|
max_length: maximum acceptable line length as number
|
|
|
|
Returns:
|
|
A list of tuples with format [(filename, line number, msg), ...] with any
|
|
violations found.
|
|
"""
|
|
lint = []
|
|
line_num = 1
|
|
for line in lines:
|
|
length = len(line.rstrip("\n"))
|
|
if length > max_length:
|
|
lint.append(
|
|
(
|
|
filename,
|
|
line_num,
|
|
"Line exceeds %d chars (%d)" % (max_length, length),
|
|
)
|
|
)
|
|
line_num += 1
|
|
return lint
|
|
|
|
|
|
def VerifyTabs(filename, lines):
|
|
"""Checks to make sure the file has no tab characters.
|
|
|
|
Args:
|
|
filename: the file under consideration as string
|
|
lines: contents of the file as string array
|
|
|
|
Returns:
|
|
A list of tuples with format [(line_number, msg), ...] with any violations
|
|
found.
|
|
"""
|
|
lint = []
|
|
tab_re = re.compile(r"\t")
|
|
line_num = 1
|
|
for line in lines:
|
|
if tab_re.match(line.rstrip("\n")):
|
|
lint.append((filename, line_num, "Tab found instead of whitespace"))
|
|
line_num += 1
|
|
return lint
|
|
|
|
|
|
def VerifyTrailingWhitespace(filename, lines):
|
|
"""Checks to make sure the file has no lines with trailing whitespace.
|
|
|
|
Args:
|
|
filename: the file under consideration as string
|
|
lines: contents of the file as string array
|
|
|
|
Returns:
|
|
A list of tuples with format [(filename, line number, msg), ...] with any
|
|
violations found.
|
|
"""
|
|
lint = []
|
|
trailing_whitespace_re = re.compile(r"\s+$")
|
|
line_num = 1
|
|
for line in lines:
|
|
if trailing_whitespace_re.match(line.rstrip("\n")):
|
|
lint.append((filename, line_num, "Trailing whitespace"))
|
|
line_num += 1
|
|
return lint
|
|
|
|
|
|
class BaseLint:
|
|
def RunOnFile(filename, lines):
|
|
raise Exception("RunOnFile() unimplemented")
|
|
|
|
|
|
def RunLintOverAllFiles(linter, filenames):
|
|
"""Runs linter over the contents of all files.
|
|
|
|
Args:
|
|
lint: subclass of BaseLint, implementing RunOnFile()
|
|
filenames: list of all files whose contents will be linted
|
|
|
|
Returns:
|
|
A list of tuples with format [(filename, line number, msg), ...] with any
|
|
violations found.
|
|
"""
|
|
lint = []
|
|
for filename in filenames:
|
|
file = open(filename, "r")
|
|
if not file:
|
|
print("Could not open %s" % filename)
|
|
continue
|
|
lines = file.readlines()
|
|
lint.extend(linter.RunOnFile(filename, lines))
|
|
|
|
return lint
|