Skip to content

Commit c1850a2

Browse files
committed
fix(app): regression on dispute load and other fixes
1 parent 4496622 commit c1850a2

26 files changed

+3055
-549
lines changed

.cursor/rules/sonar.mdc

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
alwaysApply: true
3+
---
4+
# Cursor Rules for Dispute Resolver Project
5+
6+
## SonarCloud Quality Assurance
7+
8+
### Always Check SonarCloud Issues Before Code Changes
9+
10+
When asked about SonarCloud issues or code quality, use this recipe:
11+
12+
1. **Primary Method - IDE Diagnostics (Real-time)**:
13+
```
14+
mcp__ide__getDiagnostics() # Get all current issues
15+
```
16+
17+
2. **Verify SonarLint Extension**:
18+
```bash
19+
code --list-extensions | grep -i sonar
20+
```
21+
Expected: `sonarsource.sonarlint-vscode`
22+
23+
3. **Check Specific Files** (for modified files from git status):
24+
```
25+
mcp__ide__getDiagnostics(uri="file:///absolute/path/to/file.js")
26+
```
27+
28+
4. **Fallback - Read Existing Reports**:
29+
```
30+
Read("sonarcloud-issues-report.md")
31+
Read("sonarcloud-remaining-issues.md")
32+
```
33+
34+
### Interpretation Guidelines
35+
36+
- **Empty diagnostics = Clean code** - No SonarCloud violations
37+
- **Focus on real-time data** - IDE diagnostics over static reports
38+
- **Check modified files first** - Use git status to identify changed files
39+
- **Verify extension status** - Ensure SonarLint is active for accurate results
40+
41+
### Code Quality Standards
42+
43+
- **Before making changes**: Check existing SonarCloud issues in target files
44+
- **During development**: Follow established patterns and avoid introducing new issues
45+
- **After changes**: Verify no new SonarCloud violations appear
46+
- **Critical/Blocker issues**: Must be fixed immediately
47+
- **Major issues**: Fix when touching the code
48+
- **Minor issues**: Fix opportunistically
49+
50+
### Project-Specific Commands
51+
52+
```bash
53+
# Development
54+
npm start
55+
56+
# Testing
57+
npm test
58+
59+
# Build
60+
npm run build
61+
62+
# Linting (if available)
63+
npm run lint
64+
```
65+
66+
### Technology Stack Context
67+
68+
- React 17 with Create React App
69+
- Web3/Ethereum integration with ethers.js
70+
- SCSS styling with Bootstrap
71+
- SonarCloud for code quality analysis
72+
73+
### Quality Gates
74+
75+
- Maintain or improve SonarCloud quality rating
76+
- Keep code coverage stable or increasing
77+
- Ensure no security issues are introduced
78+
- Follow established code style and patterns
79+
80+
## General Development Rules
81+
82+
- **File Creation**: Only create new files when absolutely necessary
83+
- **Prefer Editing**: Always prefer editing existing files over creating new ones
84+
- **No Unsolicited Documentation**: Never create README or .md files unless explicitly requested
85+
- **Follow Patterns**: Mimic existing code style and conventions
86+
- **Security First**: Never expose secrets, keys, or sensitive information
87+
- **Test After Changes**: Run tests to ensure no regressions
88+
89+
This ensures consistent SonarCloud quality checking across all AI interactions with the project.

CLAUDE.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Claude AI Agent Guidelines for Dispute Resolver
2+
3+
## Code Quality Standards
4+
5+
This project uses SonarCloud for code quality analysis. The SonarQube extension is already configured and connected to our SonarCloud project.
6+
7+
### Before Making Any Code Changes
8+
9+
1. **Check Current Diagnostics**: Review any existing SonarCloud issues in files you plan to modify
10+
2. **Understand Context**: Read the existing code patterns and follow established conventions
11+
3. **Plan Changes**: Ensure changes align with SonarCloud quality profile
12+
13+
### During Code Development
14+
15+
1. **Follow SonarCloud Rules**: Never introduce code that would trigger SonarCloud warnings
16+
2. **Fix Existing Issues**: When modifying a file, fix any existing SonarCloud issues if possible
17+
3. **Maintain Quality**: Ensure all new code meets or exceeds current quality standards
18+
19+
### After Code Changes
20+
21+
1. **Verify No New Issues**: Check that no new SonarCloud diagnostics appear
22+
2. **Test Functionality**: Ensure changes work correctly
23+
3. **Document Changes**: Update comments and documentation as needed
24+
25+
## SonarCloud Quality Gates
26+
27+
- **Critical/Blocker Issues**: Must be fixed immediately
28+
- **Major Issues**: Should be fixed when touching the code
29+
- **Minor Issues**: Fix opportunistically
30+
31+
## Project-Specific Patterns
32+
33+
### Web3/Ethereum Code
34+
- Always handle async operations properly
35+
- Use proper error handling for contract calls
36+
- Follow BigNumber handling patterns established in the codebase
37+
38+
### React Components
39+
- Use hooks appropriately and follow React best practices
40+
- Maintain consistent prop types and state management
41+
- Follow established component structure patterns
42+
43+
### Testing
44+
- Run existing tests after changes: `npm test`
45+
- Ensure no regressions in functionality
46+
- Add tests for new features when appropriate
47+
48+
## Commands to Run
49+
50+
```bash
51+
# Start development server
52+
npm start
53+
54+
# Run tests
55+
npm test
56+
57+
# Build for production
58+
npm run build
59+
60+
# Check for issues (if available)
61+
npm run lint
62+
```
63+
64+
## Quality Metrics
65+
66+
- Maintain or improve SonarCloud quality rating
67+
- Keep code coverage stable or increasing
68+
- Ensure no security issues are introduced
69+
- Follow established code style and patterns
70+
71+
## Kleros Arbitration Standards (ERC-792 & ERC-1497)
72+
73+
[... previous content remains unchanged ...]
74+
75+
## Memories and Learning Notes
76+
77+
### Interface Compatibility and Dispute Handling
78+
- Some arbitrables we load only implement IEvidence and IArbitrable, some implement IDisputeResolver in addition.
79+
- Crowdfunded appeal and evidence submission functionalities are only guaranteed to work if the arbitrable implements IDisputeResolver.
80+
- Other view functionality should work just fine.
81+
- There might be bad disputes, such as those that are badly configured and do not follow the standard.
82+
- We don't have to figure out how to display them perfectly, but we must make sure they don't crash the application altogether.
83+
- When a bad dispute is encountered, the application should fail gracefully.
84+
85+
[... rest of the previous content remains unchanged ...]

docs/ai-agent-sonarcloud-workflow.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# AI Agent SonarCloud Workflow
2+
3+
## Overview
4+
5+
This document outlines the workflow for AI agents working with this codebase to ensure compliance with SonarCloud quality standards using the existing SonarQube extension.
6+
7+
## Prerequisites
8+
9+
- SonarQube extension is installed and configured in your IDE
10+
- Extension is connected to the SonarCloud project
11+
- Real-time analysis is enabled
12+
13+
## Workflow Steps
14+
15+
### 1. Before Making Any Changes
16+
17+
#### Check Current State
18+
```bash
19+
# Run quality check
20+
./scripts/check-quality.sh
21+
22+
# Check specific file
23+
./scripts/pre-change-check.sh src/path/to/file.js
24+
```
25+
26+
#### Review IDE Diagnostics
27+
- Open the file in your IDE
28+
- Check the Problems panel for SonarCloud issues
29+
- Look for SonarLint annotations in the code
30+
- Note any existing issues that should be fixed
31+
32+
### 2. During Development
33+
34+
#### Follow SonarCloud Patterns
35+
- **Code Style**: Match existing code patterns
36+
- **Error Handling**: Use try/catch for async operations
37+
- **Security**: Avoid eval(), innerHTML, document.write
38+
- **Complexity**: Keep functions small and focused
39+
- **Performance**: Avoid unnecessary computations
40+
41+
#### Common SonarCloud Rules to Follow
42+
43+
**JavaScript/React Specific:**
44+
- Use `const` and `let` instead of `var`
45+
- Prefer arrow functions for callbacks
46+
- Use proper error handling for async operations
47+
- Avoid console.log in production code
48+
- Use meaningful variable names
49+
- Keep functions under 50 lines when possible
50+
51+
**React Component Patterns:**
52+
- Use hooks appropriately
53+
- Avoid direct state mutations
54+
- Use proper prop types
55+
- Handle component lifecycle correctly
56+
57+
**Web3/Ethereum Patterns:**
58+
- Handle BigNumber operations carefully
59+
- Use proper error handling for contract calls
60+
- Validate addresses and parameters
61+
- Use safe arithmetic operations
62+
63+
### 3. After Making Changes
64+
65+
#### Verify Quality
66+
```bash
67+
# Quick check for common issues
68+
./scripts/check-quality.sh
69+
70+
# Check modified file specifically
71+
./scripts/pre-change-check.sh src/path/to/modified/file.js
72+
```
73+
74+
#### IDE Verification
75+
- Check Problems panel for new issues
76+
- Ensure no new SonarCloud warnings appear
77+
- Verify existing issues are fixed (if touched)
78+
79+
### 4. Quality Gates
80+
81+
#### Must Fix (Blocker/Critical)
82+
- Security vulnerabilities
83+
- Major bugs or logic errors
84+
- Critical performance issues
85+
86+
#### Should Fix (Major)
87+
- Code smells in modified files
88+
- Maintainability issues
89+
- Performance improvements
90+
91+
#### Can Fix (Minor)
92+
- Style inconsistencies
93+
- Documentation improvements
94+
- Minor optimizations
95+
96+
## Common SonarCloud Issues and Solutions
97+
98+
### 1. Complexity Issues
99+
```javascript
100+
// ❌ Too complex
101+
function processData(data) {
102+
if (data && data.length > 0) {
103+
for (let i = 0; i < data.length; i++) {
104+
if (data[i].status === 'active') {
105+
// lots of nested logic...
106+
}
107+
}
108+
}
109+
}
110+
111+
// ✅ Simplified
112+
function processData(data) {
113+
if (!data?.length) return;
114+
115+
const activeItems = data.filter(item => item.status === 'active');
116+
return activeItems.map(processActiveItem);
117+
}
118+
119+
function processActiveItem(item) {
120+
// focused logic
121+
}
122+
```
123+
124+
### 2. Async/Await Error Handling
125+
```javascript
126+
// ❌ No error handling
127+
async function fetchData() {
128+
const response = await fetch('/api/data');
129+
return response.json();
130+
}
131+
132+
// ✅ Proper error handling
133+
async function fetchData() {
134+
try {
135+
const response = await fetch('/api/data');
136+
if (!response.ok) {
137+
throw new Error(`HTTP error! status: ${response.status}`);
138+
}
139+
return await response.json();
140+
} catch (error) {
141+
console.error('Error fetching data:', error);
142+
throw error;
143+
}
144+
}
145+
```
146+
147+
### 3. React Component Issues
148+
```javascript
149+
// ❌ Direct state mutation
150+
this.state.items.push(newItem);
151+
152+
// ✅ Proper state update
153+
this.setState(prevState => ({
154+
items: [...prevState.items, newItem]
155+
}));
156+
```
157+
158+
### 4. Web3 Patterns
159+
```javascript
160+
// ❌ No validation
161+
function transfer(address, amount) {
162+
contract.transfer(address, amount);
163+
}
164+
165+
// ✅ Proper validation
166+
function transfer(address, amount) {
167+
if (!ethers.utils.isAddress(address)) {
168+
throw new Error('Invalid address');
169+
}
170+
if (amount <= 0) {
171+
throw new Error('Amount must be positive');
172+
}
173+
return contract.transfer(address, amount);
174+
}
175+
```
176+
177+
## AI Agent Best Practices
178+
179+
### 1. Proactive Quality Checking
180+
- Always check file quality before modifications
181+
- Use IDE diagnostics as primary source of truth
182+
- Run scripts to understand current state
183+
184+
### 2. Incremental Improvements
185+
- Fix existing issues when touching files
186+
- Don't introduce new quality issues
187+
- Maintain or improve overall quality score
188+
189+
### 3. Documentation
190+
- Update comments when changing logic
191+
- Document complex business rules
192+
- Explain Web3/blockchain specific patterns
193+
194+
### 4. Testing
195+
- Run existing tests after changes
196+
- Ensure no regressions
197+
- Add tests for new functionality
198+
199+
## Troubleshooting
200+
201+
### SonarQube Extension Issues
202+
- Restart VS Code if analysis stops working
203+
- Check extension status in VS Code
204+
- Verify connection to SonarCloud project
205+
206+
### Common Problems
207+
- **No diagnostics appearing**: Check extension configuration
208+
- **Too many false positives**: Review SonarCloud project settings
209+
- **Performance issues**: Consider excluding large files from analysis
210+
211+
## Resources
212+
213+
- [SonarCloud Documentation](https://docs.sonarcloud.io/)
214+
- [SonarLint VS Code Extension](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode)
215+
- [Project CLAUDE.md](../CLAUDE.md) - AI agent guidelines
216+
- [Quality Check Script](../scripts/check-quality.sh)
217+
218+
## Summary
219+
220+
This workflow ensures that AI agents can effectively use the existing SonarQube extension to maintain code quality without requiring additional tools. The key is to leverage the real-time feedback from the IDE and follow established patterns in the codebase.

0 commit comments

Comments
 (0)