-
Notifications
You must be signed in to change notification settings - Fork 0
Test/pr review #2
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
b039e29
413b204
7ea8dd9
b168fbb
194ff77
dff15ad
20dc125
a8ad756
cddbb8a
781fd2b
afac357
89f99ba
fc6e2b7
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,36 @@ | ||
| import os | ||
| import sys | ||
| import requests | ||
|
|
||
| API_KEY = "sk-1234567890abcdef" | ||
|
Owner
Author
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. [HIGH] SECURITY API key and database credentials are hardcoded in plain text. Fix:
Owner
Author
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. [HIGH] SECURITY API key and database credentials are hardcoded in plain text. Fix:
Owner
Author
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. [HIGH] SECURITY Hardcoded database URL contains plain text password. Fix: |
||
| DB_URL = "postgresql://admin:password123@localhost/prod" | ||
| MAX = 100 | ||
|
|
||
|
Owner
Author
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. [HIGH] NAMING Function 'p' and variable 'd' have single-letter names. Function 'p' should be renamed to something descriptive like 'process_data' and variable 'd' should be renamed to something like 'data_dict'. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'x' has a single-letter name. It should be renamed to something descriptive like 'data_list'. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'res' has a misleading name. It should be renamed to something descriptive like 'result_list'. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'tmp' has a misleading name. It should be renamed to something descriptive like 'doubled_value'. Fix:
Owner
Author
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. [HIGH] CUSTOM Function 'p' is missing a docstring. It should have a docstring that describes its purpose and parameters. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'MAX' is not descriptive and should be renamed to something more meaningful. Fix:
Owner
Author
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. [MEDIUM] MAGIC_VALUES Magic values (e.g., MAX) are used without explanation. Fix: |
||
| def p(d): | ||
|
Owner
Author
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. [HIGH] NAMING Function 'p' has a single-letter name and unclear purpose. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'd' has a single-letter name and unclear purpose. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'x' has a single-letter name and unclear purpose. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'res' has a misleading name. Fix:
Owner
Author
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. [HIGH] NAMING Variable 'tmp' has a misleading name. Fix: |
||
| x = d['data'] | ||
|
Owner
Author
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. [HIGH] NAMING Function 'p' and variable 'd' have single-letter names and should be renamed for clarity. Fix:
Owner
Author
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. [MEDIUM] COMPLEXITY Function 'p' can be simplified using list comprehension. Fix:
Owner
Author
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. [HIGH] CUSTOM None of the functions have docstrings. Fix: |
||
| res = [] | ||
|
Owner
Author
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. [MEDIUM] NAMING Function p and variable names (d, x, res, tmp) are unclear and do not follow naming conventions. Fix:
Owner
Author
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. [HIGH] CUSTOM None of the functions have docstrings. Fix: |
||
| for i in range(len(x)): | ||
| tmp = x[i] * 2 | ||
|
Owner
Author
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. [HIGH] COMPLEXITY Function 'calc' has deeply nested conditionals. It should be refactored to reduce nesting. Fix:
Owner
Author
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. [HIGH] COMPLEXITY Function 'calc' has too many parameters. It should be refactored to reduce the number of parameters. Fix:
Owner
Author
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. [HIGH] CUSTOM Function 'calc' is missing a docstring. It should have a docstring that describes its purpose and parameters. Fix: |
||
| res.append(tmp) | ||
| return res | ||
|
|
||
|
Owner
Author
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. [HIGH] COMPLEXITY Function 'calc' has deeply nested conditionals. Fix:
Owner
Author
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. [HIGH] NAMING Function 'calc' has unclear purpose and takes too many arguments. Fix:
Owner
Author
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. [HIGH] CUSTOM Function 'calc' contains a print statement, which is not allowed in production code. Fix: |
||
| def calc(a,b,c,d,e,f): | ||
| if a > 0: | ||
| if b > 0: | ||
| if c > 0: | ||
|
Owner
Author
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. [HIGH] COMPLEXITY Function 'calc' has deeply nested conditionals and should be refactored. Fix:
Owner
Author
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. [HIGH] COMPLEXITY The calc function has deeply nested conditionals and does more than one thing. Fix:
Owner
Author
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. [HIGH] CUSTOM The calc function contains a print statement, which is not allowed in production code. Fix: |
||
| if d > 0: | ||
| result = a+b+c+d+e+f | ||
| print("result: " + str(result)) | ||
| return result | ||
|
Owner
Author
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. [HIGH] CUSTOM Print statement is used in production code. Fix: |
||
| return 0 | ||
|
|
||
| def fetch(u): | ||
|
Owner
Author
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. [HIGH] CUSTOM Function 'fetch' does not have a docstring. Fix:
Owner
Author
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. [HIGH] ERROR_HANDLING Function 'fetch' does not handle potential exceptions from the requests library. Fix:
Owner
Author
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. [HIGH] CUSTOM Function 'fetch' does not set a timeout for the HTTP request. Fix: |
||
| r = requests.get(u) | ||
| return r.json() | ||
|
|
||
|
Owner
Author
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. [HIGH] CUSTOM Function 'fetch' does not have a timeout set for the HTTP request. Fix: |
||
| def save(d, f): | ||
|
Owner
Author
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. [HIGH] CUSTOM Function 'save' does not have a docstring. Fix:
Owner
Author
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. [HIGH] ERROR_HANDLING Function 'save' does not handle potential exceptions from file operations. Fix: |
||
| file = open(f, 'w') | ||
|
Owner
Author
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. [MEDIUM] CUSTOM The fetch function does not have a timeout set for the HTTP request. Fix: |
||
| file.write(str(d)) | ||
|
Owner
Author
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. [HIGH] ERROR_HANDLING Function 'save' does not handle potential file I/O errors. Fix: |
||
| file.close() | ||
|
|
||
|
Owner
Author
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. [HIGH] ERROR_HANDLING The save function does not handle potential file I/O errors. Fix:
Owner
Author
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. [LOW] DEAD_CODE Variable 'unused_var' is not used anywhere in the code. Fix: |
||
| unused_var = "hello" | ||
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.
[HIGH] SECURITY
API key and database credentials are hardcoded in plain text.
Fix:
Store sensitive information securely using environment variables or a secrets manager.