Create models/other_models.py
Browse files- models/other_models.py +21 -0
models/other_models.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class OtherModels:
|
2 |
+
def __init__(self):
|
3 |
+
pass
|
4 |
+
|
5 |
+
def analyze(self, repo_data, github_api):
|
6 |
+
if isinstance(repo_data, str): # Error handling from github_api
|
7 |
+
return repo_data
|
8 |
+
bug_hunting_results = []
|
9 |
+
# Example: Simple keyword-based bug hunting
|
10 |
+
keywords = ["TODO", "FIXME", "BUG", "error", "exception"]
|
11 |
+
for file in repo_data:
|
12 |
+
if file["type"] == "file" and file["name"].endswith((".py", ".js", ".java", ".c", ".cpp")):
|
13 |
+
content = github_api.get_file_content(file["download_url"])
|
14 |
+
if isinstance(content, str) and content.startswith("Error"): #Error Handling for file content.
|
15 |
+
bug_hunting_results.append(f"{file['name']}: {content}")
|
16 |
+
continue
|
17 |
+
for keyword in keywords:
|
18 |
+
if keyword in content:
|
19 |
+
bug_hunting_results.append(f"{file['name']}: Potential issue found - '{keyword}'")
|
20 |
+
break #only add one issue per file.
|
21 |
+
return "\n".join(bug_hunting_results)
|