forked from HAL9000/cleveragents-core
7e6f6fae37
Add comprehensive semantic validation test suites covering five
new fixture categories: language porting mismatches, dependency
graph violations, API surface changes, cross-file symbols, and
circular import detection.
New BDD scenarios (38) exercise all six built-in rules against
fixture-driven inputs. Robot Framework integration tests (11)
validate end-to-end rule execution via the SemanticValidationService.
ASV benchmarks (6 suites) establish performance baselines for
batch validation throughput and per-rule latency.
Files added:
- features/fixtures/validation/{language_porting_mismatches,
dependency_graph_violations, api_surface_changes,
cross_file_symbols, circular_import_detection}.json
- features/semantic_validation_suite.feature
- features/steps/semantic_validation_suite_steps.py
- robot/semantic_validation_suite.robot
- robot/helper_semantic_validation_suite.py
- benchmarks/semantic_validation_suite_bench.py
- docs/reference/semantic_validation_coverage.md
All 11 nox sessions pass (lint, format, typecheck, security_scan,
dead_code, unit_tests, integration_tests, docs, build, benchmark,
coverage_report). Coverage remains at 97%.
ISSUES CLOSED: #316
79 lines
3.8 KiB
JSON
79 lines
3.8 KiB
JSON
{
|
|
"fixtures": [
|
|
{
|
|
"name": "list_comprehension_side_effect",
|
|
"description": "List comprehension used purely for side effects — not portable to languages without expression-level iteration",
|
|
"source": "import os\n\n[os.remove(f) for f in ['a.tmp', 'b.tmp']]\n",
|
|
"filename": "cleanup.py",
|
|
"expected_rule": "api_misuse",
|
|
"expected_passed": true,
|
|
"note": "api_misuse only flags dangerous APIs; this is a porting smell but not an API misuse"
|
|
},
|
|
{
|
|
"name": "dynamic_attribute_access",
|
|
"description": "Getattr with string-based attribute names — no static equivalent in most typed languages",
|
|
"source": "class Config:\n debug = True\n verbose = False\n\ndef get_flag(name):\n return getattr(Config, name)\n",
|
|
"filename": "config.py",
|
|
"expected_rule": "broken_reference",
|
|
"expected_passed": true,
|
|
"note": "getattr is valid Python; broken_reference cannot detect dynamic access issues"
|
|
},
|
|
{
|
|
"name": "multiple_inheritance_diamond",
|
|
"description": "Diamond inheritance with MRO — difficult to port to single-inheritance languages",
|
|
"source": "class Base:\n def method(self):\n return 'base'\n\nclass Left(Base):\n def method(self):\n return 'left'\n\nclass Right(Base):\n def method(self):\n return 'right'\n\nclass Diamond(Left, Right):\n pass\n\nresult = Diamond().method()\n",
|
|
"filename": "diamond.py",
|
|
"expected_rule": "syntax_error",
|
|
"expected_passed": true,
|
|
"note": "Syntactically valid Python; porting concern is semantic not syntactic"
|
|
},
|
|
{
|
|
"name": "metaclass_usage",
|
|
"description": "Metaclass pattern — no direct equivalent in most target languages",
|
|
"source": "class Meta(type):\n def __new__(mcs, name, bases, namespace):\n cls = super().__new__(mcs, name, bases, namespace)\n return cls\n\nclass MyClass(metaclass=Meta):\n pass\n",
|
|
"filename": "meta.py",
|
|
"expected_rule": "syntax_error",
|
|
"expected_passed": true,
|
|
"note": "Valid Python; metaclasses are a porting concern"
|
|
},
|
|
{
|
|
"name": "unpacking_star_expression",
|
|
"description": "Star unpacking not available in many target languages",
|
|
"source": "first, *rest = [1, 2, 3, 4, 5]\nresult = first + sum(rest)\n",
|
|
"filename": "unpack.py",
|
|
"expected_rule": "broken_reference",
|
|
"expected_passed": true,
|
|
"note": "Valid Python; star unpacking is a porting concern"
|
|
},
|
|
{
|
|
"name": "walrus_operator",
|
|
"description": "Assignment expression (:=) not available in most languages",
|
|
"source": "data = [1, 2, 3, 4, 5, 6]\nresult = [y for x in data if (y := x * 2) > 5]\n",
|
|
"filename": "walrus.py",
|
|
"expected_rule": "syntax_error",
|
|
"expected_passed": true,
|
|
"note": "Valid Python 3.8+; walrus operator is a porting concern"
|
|
},
|
|
{
|
|
"name": "eval_in_porting_context",
|
|
"description": "eval() used for dynamic dispatch — API misuse flagged regardless of porting intent",
|
|
"source": "def dynamic_call(fn_name, arg):\n return eval(fn_name + '(' + repr(arg) + ')')\n",
|
|
"filename": "dynamic_dispatch.py",
|
|
"expected_rule": "api_misuse",
|
|
"expected_passed": false,
|
|
"expected_message_contains": "API misuse",
|
|
"expected_data_contains": {"filename": "dynamic_dispatch.py"}
|
|
},
|
|
{
|
|
"name": "exec_for_code_generation",
|
|
"description": "exec() used for code generation — common in porting but always flagged as API misuse",
|
|
"source": "def make_class(name):\n exec(f'class {name}: pass')\n",
|
|
"filename": "codegen.py",
|
|
"expected_rule": "api_misuse",
|
|
"expected_passed": false,
|
|
"expected_message_contains": "API misuse",
|
|
"expected_data_contains": {"filename": "codegen.py"}
|
|
}
|
|
]
|
|
}
|