vinith17 commited on
Commit
3e4c18b
·
1 Parent(s): aa22482

System works with local rule engine when no API keys

Browse files
Files changed (1) hide show
  1. test_no_api.py +27 -0
test_no_api.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ sys.path.insert(0, "C:/Users/vinit/Projects/CodeBug")
4
+ import os
5
+
6
+ print("=== API Configuration ===")
7
+ print(f"HF_TOKEN set: {bool(os.environ.get('HF_TOKEN'))}")
8
+ print(f"OPENAI_API_KEY set: {bool(os.environ.get('OPENAI_API_KEY'))}")
9
+
10
+ from main import HAS_LLM, analyze_code_comprehensively
11
+
12
+ print(f"\nHAS_LLM: {HAS_LLM}")
13
+
14
+ test_cases = [
15
+ ("python", "query = f'SELECT * FROM users WHERE id={user_id}'"),
16
+ ("python", "import requests\nresponse = requests.get(url)"),
17
+ ("python", "api_key = 'sk-1234567890abcdef'"),
18
+ ("python", "@app.get('/users')\ndef get_users():\n return []"),
19
+ ("javascript", "fetch(url)"),
20
+ ]
21
+
22
+ for lang, code in test_cases:
23
+ result = analyze_code_comprehensively(code, lang)
24
+ print(f"\n=== {lang}: {code[:40]}... ===")
25
+ print(f"Bugs found: {len(result)}")
26
+ for bug in result:
27
+ print(f" - {bug['category']} ({bug['rule_id']}): {bug['comment'][:50]}")