# Code Review Guidelines
This document outlines guidelines for reviewing code changes, focusing on aspects that might be missed by automated tools.
## Security Vulnerabilities
When reviewing code, look for these potential security issues:
- **Injection vulnerabilities**: SQL, Command, LDAP, XPath, or other injection flaws
- **Authentication issues**: Weak authentication mechanisms, hardcoded credentials
- **Authorization problems**: Missing or incorrect permission checks
- **Sensitive data exposure**: Unencrypted sensitive data, improper handling of secrets
- **Insecure cryptographic implementations**: Weak algorithms, improper key management
- **CSRF/XSS vulnerabilities**: Missing CSRF tokens, unescaped user input
- **Insecure deserialization**: Deserializing untrusted data without proper validation
- **Dependency vulnerabilities**: Outdated libraries with known security issues
- **Insecure file operations**: Path traversal vulnerabilities, unsafe file handling
- **Race conditions**: Time-of-check to time-of-use (TOCTOU) bugs
## Hard-to-Notice Bugs
Pay special attention to these subtle issues:
- **Off-by-one errors**: Boundary conditions in loops and array accesses
- **Null pointer dereferences**: Missing null checks before accessing objects
- **Resource leaks**: Unclosed files, connections, or other resources
- **Concurrency issues**: Race conditions, deadlocks, improper synchronization
- **Exception handling**: Swallowed exceptions, overly broad catch blocks
- **State management**: Incorrect state transitions, missing state validation
- **Edge cases**: Handling of empty collections, extreme values, or special inputs
- **Floating-point precision issues**: Equality comparisons with floating-point values
- **Internationalization bugs**: Locale-dependent operations, character encoding issues
- **Logical errors**: Incorrect boolean expressions, misplaced parentheses
## Unintended Code
Look for code that was likely not intended to be committed:
- **Debug print statements**: Console.log, System.out.println, print, etc.
- **Commented-out code**: Large blocks of commented code without explanation
- **TODO/FIXME comments**: Especially those indicating incomplete work
- **Test or mock data**: Hardcoded test values in production code
- **Temporary workarounds**: Code marked as temporary or with "hack" comments
- **Gibberish or placeholder text**: Random characters, "asdf", "test123", etc.
- **Development configuration**: Local paths, development API keys
- **Disabled functionality**: Commented-out method calls or conditionals
- **Debugging flags**: Enabled debug modes or verbose logging
- **Incomplete refactoring**: Partially renamed variables or methods
## Code Style Issues
Review for these code style problems:
- **Inconsistent naming conventions**: Mixed camelCase/snake_case, inconsistent prefixes
- **Poor code organization**: Overly long methods or classes, poor separation of concerns
- **Duplicated code**: Copy-pasted logic that should be refactored
- **Magic numbers/strings**: Unexplained literals that should be constants
- **Misleading comments**: Comments that don't match the actual code behavior
- **Inconsistent formatting**: Mixed indentation, line length violations
- **Poor variable names**: Cryptic or overly abbreviated identifiers
- **Excessive nesting**: Deeply nested conditionals or loops
- **Unused imports/variables**: Dead code that should be removed
- **Overly complex expressions**: Code that's difficult to understand at a glance
## Additional Concerns
Other issues to watch for:
- **Performance problems**: Inefficient algorithms, unnecessary computations
- **Maintainability issues**: Code that's difficult to modify or extend
- **Accessibility concerns**: UI changes that might affect accessibility
- **Backwards compatibility**: Breaking changes to public APIs
- **Error handling**: Missing or inappropriate error handling
- **Documentation**: Missing or outdated documentation
- **Test coverage**: Insufficient test coverage for new or modified code
- **Dependency management**: Unnecessary or conflicting dependencies
- **Configuration issues**: Hardcoded configuration that should be externalized
- **Compliance concerns**: Code that might violate legal or regulatory requirements
编辑并改进提交信息
在您已经提交更改后,您仍然可以编辑您的提交消息。 使用 AI Assistant 来帮助您分析并更好地描述提交的更改。
在左下角点击 (在 DataGrip 中 ,点击页眉中的 More tool windows 并选择 Git ),或按 Alt+9 打开版本控制工具窗口。
在提交窗格中,右键点击您要更新的提交,并在上下文菜单中选择 编辑提交消息。
在打开的对话框中,点击 使用 AI Assistant 改进提交信息。
AI Assistant 分析提交的更改并生成改进的消息。
如有必要,请编辑新消息,然后点击 确定 以保存更改。
如果提交已经推送到远程存储库,请按 Ctrl+Shift+K 以同时推送更新后的提交信息。
解释提交
AI Assistant 可以总结一个或多个提交中的更改。
点击左下角的 或按 Alt+9 打开版本控制工具窗口(在 DataGrip 中 ,点击页眉中的 More tool windows 并选择 Git)。
在提交窗格中,选择您要总结的提交或多个提交,右键点击它们,然后在上下文菜单中选择 Explain Commit with AI Assistant。
AI Assistant 提供所选提交的摘要。
为拉取请求和合并请求生成标题和描述
AI Assistant 可以直接从 JetBrains IDE 为拉取请求和合并请求生成标题和描述。
在相应的工具窗口中创建新的拉取请求或合并请求时,在描述字段中点击 使用 AI Assistant 生成标题和描述。
使用 AI 解决 Git 冲突
当多个贡献者处理代码库的同一部分时,您可能会遇到无法自动合并的重叠更改。
JetBrains IDE 提供了解决此类冲突的工具,而 AI Assistant 可通过自动合并冲突更改来协助您。
在 合并修订 对话框中,点击 Merge with AI。
AI Assistant 然后合并非冲突和冲突的更改。
在对话框的中央窗格中查看合并结果,必要时编辑,然后点击 Apply。
通过点击 还原 撤销修改行中的更改。
生成传入拉取请求的摘要
AI Assistant 可以生成 传入拉取请求的摘要,捕捉关键细节并提供更改的简要描述。 要启用此功能: