-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from reconsumeralization/sweep/sweep-ai-code-i…
…mprovement Implement Sweep AI for Code Improvement (✓ Sandbox Passed)
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ast | ||
|
||
import flake8.main.application | ||
import pylint.lint | ||
import sweep | ||
|
||
|
||
def analyze_codebase(codebase_dir): | ||
with open(codebase_dir, 'r') as file: | ||
code = file.read() | ||
|
||
tree = ast.parse(code) | ||
|
||
pylint_report = pylint.lint.Run([codebase_dir], do_exit=False) | ||
flake8_app = flake8.main.application.Application() | ||
flake8_app.run([codebase_dir]) | ||
flake8_report = flake8_app.get_reports() | ||
|
||
improvements = sweep.analyze(tree, pylint_report, flake8_report) | ||
|
||
for improvement in improvements: | ||
generate_sweep_issue(improvement) | ||
|
||
def generate_sweep_issue(improvement): | ||
issue = sweep.Issue( | ||
title=f"Code Improvement: {improvement['description']}", | ||
body=f"Suggested changes: {improvement['suggestion']}" | ||
) | ||
issue.save() | ||
|
||
if __name__ == "__main__": | ||
analyze_codebase('path_to_codebase') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters