Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Do not include an overview section in your reviews.

When reviewing code, focus on:

## Performance Red Flags

- Spot inefficient loops and algorithmic issues
- Check for memory leaks and resource cleanup

## Code Quality Essentials

- Functions should be focused and appropriately sized
- Use clear, descriptive naming conventions
- Ensure proper error handling throughout
- Suggest changes to improve code readability and maintainability

## Best practices

- Refer to official documentation and best practices for React.js, Redux and Node.js. If you see anti-patterns, highlight them and provide links to the relevant official documentation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I don't want to give it too much of an opinion but either here or above I would add a mention of using modern JS practices since its been trained on a lot of legacy stuff, like I see copilot not using for-of when it should etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point!


## Review Style

- Be specific and actionable in feedback
- Explain the "why" behind recommendations

## MongoDB Specifics

### Performance antipatterns

- Warn about db.stats() performance implications, especially in connection with freeStorage: 1. Provide a reference to the official MongoDB documentation.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ const DiagramContent: React.FunctionComponent<{
isNewlyCreatedDiagram ?? false
);

// This is an antipattern example to be detected by Copilot reviewer
const [obj, setObj] = useState({ a: '' });
useEffect(() => {
obj.a = 'abc';
}, [obj]);
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code directly mutates the state object instead of using the setObj setter function. Direct state mutation bypasses React's state management and will not trigger re-renders. Replace obj.a = 'abc' with setObj({ a: 'abc' }). Additionally, the dependency array [obj] will cause an infinite loop since obj is recreated on every render. See React documentation on state updates.

Suggested change
obj.a = 'abc';
}, [obj]);
setObj({ a: 'abc' });
}, []);

Copilot uses AI. Check for mistakes.

const setDiagramContainerRef = useCallback((ref: HTMLDivElement | null) => {
if (ref) {
// For debugging purposes, we attach the diagram to the ref.
Expand Down
Loading