|
| 1 | +# JetBrains Auto-Approval Compliance |
| 2 | + |
| 3 | +This document describes the linting setup to ensure compliance with JetBrains auto-approval requirements for Toolbox plugins. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +JetBrains has enabled auto-approval for this plugin, which requires following specific guidelines to maintain the approval status. This repository includes automated checks to ensure compliance. |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +Based on communication with JetBrains team, the following requirements must be met: |
| 12 | + |
| 13 | +### ✅ Allowed |
| 14 | +- **Coroutines**: Use `coroutineScope.launch` for concurrent operations |
| 15 | +- **Library-managed threads**: Libraries like OkHttp with their own thread pools are acceptable |
| 16 | +- **Some experimental coroutines APIs**: `kotlinx.coroutines.selects.select` and `kotlinx.coroutines.selects.onTimeout` are acceptable |
| 17 | +- **Proper cleanup**: Ensure resources are released in `CoderRemoteProvider#close()` method |
| 18 | + |
| 19 | +### ❌ Forbidden |
| 20 | +- **Kotlin experimental APIs**: Core Kotlin experimental APIs (not coroutines-specific ones) |
| 21 | +- **Java runtime hooks**: No lambdas, handlers, or class handles to Java runtime hooks |
| 22 | +- **Manual thread creation**: Avoid `Thread()`, `Executors.new*()`, `ThreadPoolExecutor`, etc. |
| 23 | +- **Bundled libraries**: Don't bundle libraries already provided by Toolbox |
| 24 | +- **Ill-intentioned actions**: No malicious or harmful code |
| 25 | + |
| 26 | +## Linting Setup |
| 27 | + |
| 28 | +### JetBrains Compliance with Detekt |
| 29 | + |
| 30 | +The primary compliance checking is done using Detekt with custom configuration in `detekt.yml`: |
| 31 | + |
| 32 | +```bash |
| 33 | +./gradlew detekt |
| 34 | +``` |
| 35 | + |
| 36 | +This configuration includes JetBrains-specific rules that check for: |
| 37 | +- **ForbiddenAnnotation**: Detects forbidden experimental API usage |
| 38 | +- **ForbiddenMethodCall**: Detects Java runtime hooks and manual thread creation |
| 39 | +- **ForbiddenImport**: Detects potentially bundled libraries |
| 40 | +- **Standard code quality rules**: Complexity, naming, performance, etc. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +## CI/CD Integration |
| 45 | + |
| 46 | +The GitHub Actions workflow `.github/workflows/jetbrains-compliance.yml` runs compliance checks on every PR and push. |
| 47 | + |
| 48 | +## Running Locally |
| 49 | + |
| 50 | +```bash |
| 51 | +# Run JetBrains compliance and code quality check |
| 52 | +./gradlew detekt |
| 53 | + |
| 54 | +# View HTML report |
| 55 | +open build/reports/detekt/detekt.html |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +## Understanding Results |
| 61 | + |
| 62 | +### Compliance Check Results |
| 63 | + |
| 64 | +- **✅ No critical violations**: Code complies with JetBrains requirements |
| 65 | +- **❌ Critical violations**: Must be fixed before auto-approval |
| 66 | +- **⚠️ Warnings**: Should be reviewed but may be acceptable |
| 67 | + |
| 68 | +### Common Warnings |
| 69 | + |
| 70 | +1. **Manual thread creation**: If you see warnings about thread creation: |
| 71 | + - Prefer coroutines: `coroutineScope.launch { ... }` |
| 72 | + - If using libraries with threads, ensure cleanup in `close()` |
| 73 | + |
| 74 | +2. **Library imports**: If you see warnings about library imports: |
| 75 | + - Verify the library isn't bundled in the final plugin |
| 76 | + - Check that Toolbox doesn't already provide the library |
| 77 | + |
| 78 | +3. **GlobalScope usage**: If you see warnings about `GlobalScope`: |
| 79 | + - Use the coroutine scope provided by Toolbox instead |
| 80 | + |
| 81 | +## Resources |
| 82 | + |
| 83 | +- [JetBrains Toolbox Plugin Development](https://plugins.jetbrains.com/docs/toolbox/) |
| 84 | +- [Detekt Documentation](https://detekt.dev/) |
| 85 | +- [Kotlin Coroutines Guide](https://kotlinlang.org/docs/coroutines-guide.html) |
0 commit comments