Make workflow scripts easier to read by avoiding variable names not explicit

This commit is contained in:
Adrien Ufferte
2025-07-04 16:16:47 +02:00
parent 2ab5e616d5
commit 6204d5b700
3 changed files with 40 additions and 40 deletions
+22 -22
View File
@@ -39,15 +39,15 @@ MESSAGES = {
for root, dirs, files in os.walk('.', topdown=True):
rel_root = os.path.relpath(root, '.')
if any(rel_root == ex or rel_root.startswith(f"{ex}{os.sep}") for ex in EXCLUDED_DIRS):
if any(rel_root == excluded or rel_root.startswith(f"{excluded}{os.sep}") for excluded in EXCLUDED_DIRS):
dirs[:] = []
continue
for fname in files:
if fname.endswith('.gd'):
path = os.path.join(root, fname)
try:
with open(path, 'r', encoding='utf-8') as f:
lines = f.readlines()
with open(path, 'r', encoding='utf-8') as file:
lines = file.readlines()
except Exception as e:
issues.append((path, 0, 'error', f'Could not read file: {e}'))
continue
@@ -55,41 +55,41 @@ for root, dirs, files in os.walk('.', topdown=True):
stripped = line.strip()
if stripped.startswith('#') or not stripped:
continue
m = re.match(r"class_name\s+([A-Za-z0-9_]+)", stripped)
if m:
name = m.group(1)
match_class = re.match(r"class_name\s+([A-Za-z0-9_]+)", stripped)
if match_class:
name = match_class.group(1)
if not PASCAL_CASE.match(name):
issues.append((path, idx, 'class', name))
m = re.match(r"func\s+([A-Za-z0-9_]+)\s*(\([^)]*\))?", stripped)
if m:
name = m.group(1)
match_func = re.match(r"func\s+([A-Za-z0-9_]+)\s*(\([^)]*\))?", stripped)
if match_func:
name = match_func.group(1)
if not SNAKE_CASE.match(name):
issues.append((path, idx, 'function', name))
params = m.group(2)
params = match_func.group(2)
if params:
params = params.strip('()')
for param in split_params(params):
param_name = param.split(':')[0].split('=')[0].strip()
if param_name and not SNAKE_CASE.match(param_name):
issues.append((path, idx, 'variable', param_name))
m = re.match(r"(?:@export\s+)?var\s+([A-Za-z0-9_]+)", stripped)
if m:
name = m.group(1)
match_export = re.match(r"(?:@export\s+)?var\s+([A-Za-z0-9_]+)", stripped)
if match_export:
name = match_export.group(1)
if not SNAKE_CASE.match(name):
issues.append((path, idx, 'variable', name))
m = re.match(r"const\s+([A-Za-z0-9_]+)", stripped)
if m:
name = m.group(1)
match_const = re.match(r"const\s+([A-Za-z0-9_]+)", stripped)
if match_const:
name = match_const.group(1)
if not UPPER_SNAKE_CASE.match(name):
issues.append((path, idx, 'constant', name))
m = re.match(r"signal\s+([A-Za-z0-9_]+)", stripped)
if m:
name = m.group(1)
match_signal = re.match(r"signal\s+([A-Za-z0-9_]+)", stripped)
if match_signal:
name = match_signal.group(1)
if not SNAKE_CASE.match(name):
issues.append((path, idx, 'signal', name))
m = re.match(r"for\s+([A-Za-z0-9_]+)(?:\s*:\s*[^\s]+)?\s+in\b", stripped)
if m:
name = m.group(1)
match_for = re.match(r"for\s+([A-Za-z0-9_]+)(?:\s*:\s*[^\s]+)?\s+in\b", stripped)
if match_for:
name = match_for.group(1)
if not SNAKE_CASE.match(name):
issues.append((path, idx, 'variable', name))