Protokoll #28033

ID28033
Zeitstempel2025-12-28 12:43:31.781243
Clientroot
IP145.224.72.140
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens901 (Input: 766, Output: 135)
Dauer165 ms
Request-Zeit2025-12-28 12:43:31.781243
Response-Zeit2025-12-28 12:43:31.945981

Request

{
    "event": "PreToolUse",
    "tool_name": "Bash",
    "tool_input": {
        "command": "python3 -c \"\nfrom quality import pre_rules, post_rules\n\nprint('=== P8.x Deterministic Tests ===')\n\n# Test P8.2: date()\ntest_date = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test\n\\$formatted = date(\\\"Y-m-d\\\");\n'''\nresult = pre_rules.check('\/src\/Test.php', test_date)\nprint('P8.2 date() blockiert:', 'P8.2' in result.get('message', ''))\n\n# Test P8.3: rand()\ntest_rand = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test\n\\$num = rand();\n'''\nresult = pre_rules.check('\/src\/Test.php', test_rand)\nprint('P8.3 rand() blockiert:', 'P8.3' in result.get('message', ''))\n\n# Test P8.6: global\ntest_global = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: Test\nglobal \\$config;\n'''\nresult = pre_rules.check('\/src\/Test.php', test_global)\nprint('P8.6 global blockiert:', 'P8.6' in result.get('message', ''))\n\n# Test Allowlist: Clock in Infrastructure\ntest_clock_infra = '''<?php\ndeclare(strict_types=1);\n\/\/ @responsibility: System Clock Implementation\n\\$now = time();\n'''\nresult = pre_rules.check('\/src\/Infrastructure\/Clock\/SystemClock.php', test_clock_infra)\nprint('Allowlist \/Infrastructure\/Clock\/ erlaubt time():', result.get('allowed', False))\n\nprint('\\\\n=== W8.x Fail Fast Tests ===')\n\n# Test W8.2: Error suppression\ntest_suppress = '''<?php\n\\$result = @file_get_contents(\\$path);\n'''\nresult = post_rules.check('\/src\/Test.php', test_suppress)\nprint('W8.2 @-Operator warnt:', any('W8.2' in w for w in result.get('warnings', [])))\n\n# Test W8.3: Catch only return\ntest_catch_return = '''<?php\ntry {\n    doSomething();\n} catch (Exception \\$e) {\n    return null;\n}\n'''\nresult = post_rules.check('\/src\/Test.php', test_catch_return)\nprint('W8.3 Catch-only-return warnt:', any('W8.3' in w for w in result.get('warnings', [])))\n\nprint('\\\\n=== W15.x Least Surprise Tests ===')\n\n# Test W15.2: Setter with return\ntest_setter_return = '''<?php\nclass Test {\n    public function setName(string \\$name): User {\n        \\$this->name = \\$name;\n        return \\$this->findUser();\n    }\n}\n'''\nresult = post_rules.check('\/src\/Test.php', test_setter_return)\nprint('W15.2 Setter mit Return warnt:', any('W15.2' in w for w in result.get('warnings', [])))\n\n# Test W15.3: Bool method without prefix\ntest_bool = '''<?php\nclass Test {\n    public function validate(): bool {\n        return true;\n    }\n}\n'''\nresult = post_rules.check('\/src\/Test.php', test_bool)\nprint('W15.3 Bool ohne Präfix warnt:', any('W15.3' in w for w in result.get('warnings', [])))\n\n# Test W15.3: Bool method with correct prefix (should NOT warn)\ntest_bool_ok = '''<?php\nclass Test {\n    public function isValid(): bool {\n        return true;\n    }\n}\n'''\nresult = post_rules.check('\/src\/Test.php', test_bool_ok)\nprint('W15.3 isValid() warnt NICHT:', not any('W15.3' in w for w in result.get('warnings', [])))\n\nprint('\\\\nAlle erweiterten Tests bestanden!')\n\"\n",
        "description": "Extended quality rules tests"
    }
}

Response

{
    "tool_response": {
        "stdout": "=== P8.x Deterministic Tests ===\nP8.2 date() blockiert: True\nP8.3 rand() blockiert: True\nP8.6 global blockiert: True\nAllowlist \/Infrastructure\/Clock\/ erlaubt time(): True\n\n=== W8.x Fail Fast Tests ===\nW8.2 @-Operator warnt: True\nW8.3 Catch-only-return warnt: True\n\n=== W15.x Least Surprise Tests ===\nW15.2 Setter mit Return warnt: True\nW15.3 Bool ohne Präfix warnt: True\nW15.3 isValid() warnt NICHT: True\n\nAlle erweiterten Tests bestanden!",
        "stderr": "",
        "interrupted": false,
        "isImage": false
    }
}
← Vorheriger Zur Liste Nächster →