-
Notifications
You must be signed in to change notification settings - Fork 0
Test code review #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||
def run(): | ||||||||||||||||||||||||||||
code = "print('Hello World')" | ||||||||||||||||||||||||||||
eval(code) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
user_input = input("Enter a number: ") | ||||||||||||||||||||||||||||
try: | ||||||||||||||||||||||||||||
result = int(user_input) / 0 | ||||||||||||||||||||||||||||
print( result ) | ||||||||||||||||||||||||||||
except: | ||||||||||||||||||||||||||||
print("something went wrong") | ||||||||||||||||||||||||||||
Comment on lines
+5
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guaranteed Dividing by zero always throws, and the bare - user_input = input("Enter a number: ")
- try:
- result = int(user_input) / 0
- print( result )
- except:
- print("something went wrong")
+ user_input = input("Enter a number: ")
+ try:
+ value = float(user_input)
+ result = value / 2 # example divisor
+ print(f"Result: {result}")
+ except ValueError:
+ print("Please enter a valid number.") 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.11.9)9-9: Do not use bare (E722) 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
temp = [] | ||||||||||||||||||||||||||||
for i in range(0,10): | ||||||||||||||||||||||||||||
temp.append(i) | ||||||||||||||||||||||||||||
for i in range(0,10): | ||||||||||||||||||||||||||||
temp.append(i) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,19 +98,21 @@ jobs: | |
if [ -f original_files_temp.json ]; then | ||
jq -s '.[0] * .[1]' diff.json original_files_temp.json > combined.json | ||
mv combined.json diff.json | ||
fi | ||
|
||
- name: Display Processed Diff (Debug) | ||
run: cat diff.json | ||
|
||
- name: Analyze with OpenAI | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
MODELNAME: ${{ vars.MODELNAME }} | ||
run: | | ||
DIFF_CONTENT=$(jq -r '.diff' diff.json) | ||
ORIGINAL_FILES=$(jq -r '."original files"' diff.json) | ||
PROMPT="Please review the following code changes for any obvious quality or security issues. Provide a brief report in markdown format:\n\nDIFF:\n${DIFF_CONTENT}\n\nORIGINAL FILES:\n${ORIGINAL_FILES}" | ||
jq -n --arg prompt "$PROMPT" '{ | ||
"model": "gpt-4", | ||
jq -n --arg model "$MODELNAME" --arg prompt "$PROMPT" '{ | ||
"model": "\($model)", | ||
"messages": [ | ||
Comment on lines
+114
to
116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable already interpolated – lose the extra quotes
"model": "\($model)" results in - jq -n --arg model "$MODELNAME" --arg prompt "$PROMPT" '{
- "model": "\($model)",
+ jq -n --arg model "$MODELNAME" --arg prompt "$PROMPT" '{
+ "model": $model, 🤖 Prompt for AI Agents
|
||
{ "role": "system", "content": "You are a code reviewer." }, | ||
{ "role": "user", "content": $prompt } | ||
|
@@ -257,4 +259,4 @@ Commit this workflow to your repository, then open a new PR. The workflow will r | |
|
||
 | ||
|
||
 | ||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval()
is unnecessary and unsafeExecuting arbitrary strings invites RCE. Replace with a direct call:
📝 Committable suggestion
🤖 Prompt for AI Agents