|
27 | 27 | # For that, you might clone the repo locally and inform its path below: https://hg-edge.mozilla.org/mozilla-central |
28 | 28 | LOCAL_MERCURIAL_PATH = "" |
29 | 29 | REPORT_DIRECTORY = "" |
30 | | -REPORT_FILENAME_GPT = "generated_comment_gpt.csv" |
31 | | -REPORT_FILENAME_DEEPSEEK = "generated_comment_deepseek.csv" |
| 30 | +REPORT_FILENAME_GPT = "filtered_comment_gpt.csv" |
| 31 | +REPORT_FILENAME_DEEPSEEK = "filtered_comment_deepseek.csv" |
32 | 32 |
|
33 | 33 | OPEN_API_KEY = "" |
34 | 34 | OPEN_AI_MODEL = "gpt-4o-mini" |
|
99 | 99 | "filename": "netwerk/streamconv/converters/mozTXTToHTMLConv.cpp", |
100 | 100 | "start_line": 1211, |
101 | 101 | "content": "Ensure that the size of `tempString` does not exceed 256 characters. Using `nsAutoStringN<256>` is efficient for small strings, but exceeding the size can lead to buffer issues.", |
102 | | - "coment_type": "code validation" |
| 102 | + "label": "code validation" |
| 103 | + "label_justification": "Functional - Validation" |
103 | 104 | }} |
104 | 105 | ] |
105 | 106 |
|
|
128 | 129 | \"filename\": \"<file_path>\", |
129 | 130 | \"start_line\": <line_number>, |
130 | 131 | \"content\": \"<comment_content>\", |
131 | | - \"comment_type\": \"<comment_type>\" |
| 132 | + \"label\": \"<label>\", |
| 133 | + \"label_justification\": \"<label_justification>\" |
132 | 134 | }} |
133 | 135 | ] |
134 | 136 | ``` |
135 | 137 | 6. **Content of Comments**: |
136 | | - - Be concise, Comments should be short and to the point. |
| 138 | + - Be concise, comments should be short and to the point. |
137 | 139 | - Provide actionable feedback that would lide the the fixes from the Patch fixing the bug. |
138 | 140 | - Each comment should focus solely on potential issues introduced by the added '+' lines of code. |
139 | 141 | - Avoid referencing any external descriptions (like Jira tickets or Patchi fixing the bug). Focus on the Patch introducing the bug itself. |
140 | 142 | - The comment type could be: |
141 | | - * Functional - Functional defect: Functionality is missing or implemented incorrectly and such defects often require additional code or larger modifications to the existing solution. |
142 | | - * Functional - Logical: Control flow, comparison related, and logical errors. |
143 | | - * Functional - Validation: Validation mistakes or mistakes made when detecting an invalid value are of this class. Any kind of user data sanitization-related comments are in this category, too. |
144 | | - * Functional - Resource: Resource (variables, memory, files, database) initialization, manipulation, and release. |
145 | | - * Functional - Timing: Potential issues due to incorrect thread synchronization. |
146 | | - * Functional - Support: Issues related to support systems and libraries or their configurations. |
147 | | - * Functional - Interface: Mistakes when interacting with other parts of the software such as, existing code library, hardware device, database or operating system. |
148 | | - * Refactoring - Solution approach: Suggestions to adopt an alternate algorithm or data structure. |
149 | | - * Refactoring - Alternate Output: Comments that suggest modifying the error message, toast message, alert, or change what is returned by a function. |
150 | | - * Refactoring - Organization of the code: Refactoring suggestions. |
151 | | - * Refactoring - Naming Convention: Violations of identifier naming conventions. |
152 | | - * Refactoring - Visual Representation: Whitespace, blank lines, code rearrangements, and indentation-related comments. |
153 | | - * Documentation: Suggestions to add/modify comments or documentation to aid code comprehension. |
154 | | - * Discussion - Design discussion: Discussions on design direction, design pattern, and software architecture. |
155 | | - * Discussion - Question: Questions to understand the design or implementation choices. |
156 | | - * Discussion - Praise: Complement for a code. |
| 143 | + Categories and Subcategories |
| 144 | + 1. Readability: |
| 145 | + Focus: Making the code easier to read and understand. |
| 146 | + Subcategories include: |
| 147 | + * Refactoring - Consistency: Uniform coding styles and practices. |
| 148 | + * Refactoring - Naming Convention: Clear, descriptive identifiers. |
| 149 | + * Refactoring - Readability: General clarity improvements. |
| 150 | + * Refactoring - Simplification: Reducing unnecessary complexity. |
| 151 | + * Refactoring - Visual Representation: Improving code layout and formatting. |
| 152 | + 2. Design and Maintainability: |
| 153 | + Focus: Improving structure and long-term upkeep. |
| 154 | + Subcategories include: |
| 155 | + * Discussion - Design discussion: Architectural or structural decisions. |
| 156 | + * Functional - Support: Adding or enhancing support functionality. |
| 157 | + * Refactoring - Alternate Output: Changing what the code returns or prints. |
| 158 | + * Refactoring - Code Duplication: Removing repeated code. |
| 159 | + * Refactoring - Code Simplification: Streamlining logic. |
| 160 | + * Refactoring - Magic Numbers: Replacing hard-coded values with named constants. |
| 161 | + * Refactoring - Organization of the code: Logical structuring of code. |
| 162 | + * Refactoring - Solution approach: Rethinking problem-solving approaches. |
| 163 | + * Refactoring - Unused Variables: Removing variables not in use. |
| 164 | + * Refactoring - Variable Declarations: Improving how variables are declared or initialized. |
| 165 | + 3. Performance: |
| 166 | + Focus: Making the code faster or more efficient. |
| 167 | + Subcategories include: |
| 168 | + * Functional - Performance: General performance improvements. |
| 169 | + * Functional - Performance Optimization: Specific performance-focused refactoring. |
| 170 | + * Functional - Performance and Safety: Balancing speed and reliability. |
| 171 | + * Functional - Resource: Efficient use of memory, CPU, etc. |
| 172 | + * Refactoring - Performance Optimization: Improving performance through code changes. |
| 173 | + 4. Defect: |
| 174 | + Focus: Fixing bugs and potential issues. |
| 175 | + Subcategories include: |
| 176 | + * Functional - Conditional Compilation |
| 177 | + * Functional - Consistency and Thread Safety |
| 178 | + * Functional - Error Handling |
| 179 | + * Functional - Exception Handling |
| 180 | + * Functional - Initialization |
| 181 | + * Functional - Interface |
| 182 | + * Functional - Lambda Usage |
| 183 | + * Functional - Logical |
| 184 | + * Functional - Null Handling |
| 185 | + * Functional - Security |
| 186 | + * Functional - Serialization |
| 187 | + * Functional - Syntax |
| 188 | + * Functional - Timing |
| 189 | + * Functional - Type Safety |
| 190 | + * Functional - Validation |
| 191 | + 5. Other: |
| 192 | + Use only if none of the above apply: |
| 193 | + Subcategories include: |
| 194 | + * None of the above |
| 195 | + * Does not apply |
157 | 196 | - Keep It Focused: Limit your comments to the issues that could lead to problems identified by the Jira ticket and are directly related to the changes made in the Patch fixing the bug. |
158 | 197 | 7. **Limit the Comments**: Write as little amount of comments possible. |
159 | 198 |
|
|
173 | 212 | \"filename\": \"netwerk/streamconv/converters/mozTXTToHTMLConv.cpp\", |
174 | 213 | \"start_line\": 1211, |
175 | 214 | \"content\": \"The lack of input validation in this line could lead to an unexpected crash. Consider validating `tempString` length before using it.\", |
176 | | - \"comment_type\": \"code validation\" |
| 215 | + \"label\": \"Defect\", |
| 216 | + \"label_justification\": \"Functional - Validation\" |
177 | 217 | }} |
178 | 218 | ] |
179 | 219 | ``` |
@@ -300,8 +340,7 @@ def generate_code_review_comments( |
300 | 340 | return None |
301 | 341 |
|
302 | 342 | llm = ChatOpenAI( |
303 | | - model_name=OPEN_AI_MODEL, |
304 | | - temperature=TEMPERATURE, |
| 343 | + model_name=OPEN_AI_MODEL, temperature=TEMPERATURE, openai_api_key=OPEN_API_KEY |
305 | 344 | ) |
306 | 345 |
|
307 | 346 | summarization_chain = LLMChain( |
@@ -384,7 +423,8 @@ def save_output_comments( |
384 | 423 | "Filename", |
385 | 424 | "Start Line", |
386 | 425 | "Comment Content", |
387 | | - "Comment Type", |
| 426 | + "Label", |
| 427 | + "Justification", |
388 | 428 | ] |
389 | 429 |
|
390 | 430 | if len(comments) > 0: |
@@ -415,7 +455,8 @@ def save_output_comments( |
415 | 455 | "Filename": comment.get("filename", ""), |
416 | 456 | "Start Line": comment.get("start_line", ""), |
417 | 457 | "Comment Content": comment.get("content", ""), |
418 | | - "Comment Type": comment.get("comment_type", ""), |
| 458 | + "Label": comment.get("label", ""), |
| 459 | + "Justification": comment.get("label_justification", ""), |
419 | 460 | } |
420 | 461 | ) |
421 | 462 | print(f"CSV file has been successfully written to {output_csv_path}.") |
|
0 commit comments