android-detekt-expert
Skill11 starsChanged 8 months agoMITView on GitHub
Use when performing logic-based static analysis, detecting code smells, or configuring Detekt for Android.
In this repository40 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- android-accessibilitySkill
- android-adaptive-layoutsSkill
- android-adb-terminalSkill
- android-background-executionSkill
- android-bluetooth-bleSkill
- android-build-verificationSkill
- android-camerax-mlkitSkill
- android-ci-cd-expertSkill
- android-clean-architectureSkill
- android-code-review-expertSkill
- android-coroutines-expertSkill
- android-custom-drawing-canvasSkill
- android-design-system-m3Skill
- android-design-to-codeSkill
- android-enterprise-securitySkill
- android-gemini-nanoSkill
- android-google-workspace-expertSkill
- android-gradle-expertSkill
- android-hardware-testingSkill
- android-jetpack-composeSkill
- android-kmp-compose-uiSkill
- android-kmp-platform-channelsSkill
- android-kmp-sharedSkill
- android-ktlint-formattingSkill
- android-lint-and-qualitySkill
- android-local-stt-ttsSkill
- android-location-mapsSkill
- android-macrobenchmarkSkill
- android-media3-exoplayerSkill
- android-media-and-image-expertSkill
- android-motion-animationsSkill
- android-navigation-expertSkill
- android-offline-firstSkill
- android-performance-auditSkill
- android-rag-localSkill
- android-screenshot-testingSkill
- android-security-hardenedSkill
- android-unit-testingSkill
- android-wear-os-composeSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
OptionalUnit: Don't return Unit explicitly.
- Distinctive: line 37
UnusedPrivateMember: Delete unused variables and functions.
- Distinctive: line 38
RedundantVisibilityModifier: Keep it clean if defaults are sufficient.
- Distinctive: line 41
EqualsWithHashCode: Always override both together.
- Distinctive: line 42
UnreachableCode: Remove code that can't be executed.
- Very specific: line 43
UnsafeCallOnNullableType: Avoid using !! operator.
- Distinctive: line 63
Use a custom configuration file to override default thresholds:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Android Detekt Logic Analysis 🧐🔍
Advanced strategies for detecting hidden logic errors, structural flaws, and code debt in Kotlin Android applications.
⚡ When to Use
- Code Smell Hunting: Identifying long functions, deeply nested loops, or excessive cognitive complexity.
- Architectural Guardrails: Enforcing rules like "No
viewModelScope.launchoutside of ViewModels". - Naming Enforcement: Ensuring all interfaces end with
Interface(if that's the team policy). - Refactoring Strategy: Identifying the most "complex" files that need simplification first.
- CI/CD Quality Gate: Failing a build based on logic violations.
🏗️ Core Categories
1. Complexity
- TooManyFunctions: Aim for < 11 functions per class.
- LongMethod: Aim for < 20 lines per function.
- NestedBlockDepth: Aim for < 4 levels of nesting.
2. Formatting (Logic-Based)
- OptionalUnit: Don't return
Unitexplicitly. - UnusedPrivateMember: Delete unused variables and functions.
- RedundantVisibilityModifier: Keep it clean if defaults are sufficient.
3. Potential Bugs
- EqualsWithHashCode: Always override both together.
- UnreachableCode: Remove code that can't be executed.
- UnsafeCallOnNullableType: Avoid using
!!operator.
4. Style & Naming
- ForbiddenMethodCall: Block usage of certain libraries (e.g.,
java.util.Datein favor ofjava.timeorkotlinx-datetime). - ForbiddenImport: Prevent importing internal or deprecated classes.
🛠️ Essential Commands
Check Logic Errors
./gradlew detektAuto-Correct (Basic)
./gradlew detekt --auto-correct📜 Configuration (detekt.yml)
Use a custom configuration file to override default thresholds:
complexity:
TooManyFunctions:
active: true
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
thresholdInObjects: 11
LongMethod:
active: true
threshold: 20🚀 Performance & Tips
- Custom Rules: Implement
Rulesubclass to enforce project-specific requirements. - Baseline Files: Use
detekt-baseline.xmlfor large existing projects to prioritize fixing new issues. - IDE Integration: Install the "Detekt" plugin in Android Studio/IntelliJ.
🧪 Verification Checklist
- No Complex Functions: Logic is broken down into small, testable units.
- No Dead Code: All private members are used or deleted.
- Stable APIs: All public APIs follow consistent naming and documentation rules.
- No Deprecated Usage: Modern APIs are used exclusively.
🔗 Related Resources
- Official Detekt Documentation
- Code Review Expert
- Kotlin Lint & Quality
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

