Comment markers in headers only, rename script, update github actions

This commit is contained in:
disinvite 2023-12-10 20:47:12 -05:00
parent 5d0788457c
commit 07c0753a01
5 changed files with 29 additions and 12 deletions

View File

@ -13,7 +13,7 @@ jobs:
run: |
pip install -r tools/requirements.txt
- name: Run checkorder.py
- name: Run decomplint.py
run: |
python3 tools/checkorder/checkorder.py --verbose --enforce ISLE
python3 tools/checkorder/checkorder.py --verbose --enforce LEGO1
python3 tools/decomplint/decomplint.py --enforce ISLE --module ISLE
python3 tools/decomplint/decomplint.py --enforce LEGO1 --module LEGO1

View File

@ -35,6 +35,9 @@ class ParserError(Enum):
# state of SEARCH
UNEXPECTED_END_OF_FILE = 108
# WARN: We found a marker to be referenced by name outside of a header file.
BYNAME_FUNCTION_IN_CPP = 109
# This code or higher is an error, not a warning
DECOMP_ERROR_START = 200

View File

@ -2,13 +2,6 @@
from .error import ParserAlert, ParserError
# TODO: You get an error for each function out of order.
# Same as the verbose display but just as main line errors.
# TODO: Sort alerts by line number at the end?
# TODO: No more verbose mode. This is a linter and you get warnings always.
# TODO: --warnfail flag?
def get_checkorder_filter(module):
"""Return a filter function on implemented functions in the given module"""
return lambda fun: fun.module == module and not fun.lookup_by_name
@ -65,8 +58,17 @@ def _check_symbol_uniqueness(self):
pass
def _check_byname_allowed(self):
# TODO
pass
if self.file_is_header():
return
for fun in self._parser.functions:
if fun.lookup_by_name:
self.alerts.append(
ParserAlert(
code=ParserError.BYNAME_FUNCTION_IN_CPP,
line_number=fun.line_number,
)
)
def check_lines(self, lines, filename, module=None):
"""`lines` is a generic iterable to allow for testing with a list of strings.

View File

@ -68,3 +68,15 @@ def test_module_isolation(linter):
assert linter.check_lines(lines, "test.cpp", "TEST") is True
assert linter.check_lines(lines, "test.cpp", "ALPHA") is True
def test_byname_headers_only(linter):
"""Markers that ar referenced by name with cvdump belong in header files only."""
lines = [
"// FUNCTION: TEST 0x1000",
"// MyClass::~MyClass",
]
assert linter.check_lines(lines, "test.h", "TEST") is True
assert linter.check_lines(lines, "test.cpp", "TEST") is False
assert linter.alerts[0].code == ParserError.BYNAME_FUNCTION_IN_CPP