dart-run-static-analysis
Configure project linter rules, configure `analysis_options.yaml`, enforce strict static type checking, and manage fine-grained file or line-level diagnostic suppressions.
What this skill does
## Contents
- [Analysis Configuration](#analysis-configuration)
- [Diagnostic Suppression Rules](#diagnostic-suppression-rules)
- [Workflow: Running Static Analysis](#workflow-running-static-analysis)
- [Workflow: Applying Automated Code Fixes](#workflow-applying-automated-code-fixes)
- [Examples](#examples)
## Analysis Configuration
Enforce strict formatting, stylistic cleanliness, and code sanity by configuring `analysis_options.yaml` in the root of your Dart package:
- **Inheriting Lints**: Inherit a baseline recommended rule set using the `include` directive. Prefer `package:lints/recommended.yaml` for pure Dart packages or `package:flutter_lints/flutter.yaml` for Flutter applications.
- **Strict Type Checking**: Explicitly declare strict static types under the `analyzer: language:` configuration to eliminate unsafe dynamic types:
```yaml
analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
```
- **Linter Rules Customization**: Customize specific rules under `linter: rules:`. Use a map key structure (`rule_name: true/false`) to explicitly activate or deactivate rules when overriding an inherited configuration.
- **Auto-Formatting Options**: Declare formatter parameters under the `formatter:` node (e.g. configuring `page_width: 80`).
## Diagnostic Suppression Rules
When an analyzer warning or style lint yields a false positive or hits generated files, suppress the warning explicitly using one of these strategies:
- **Exclusion Filters**: Exclude entire files or directory trees (such as JSON generated models or internationalization files) from analysis under the `analyzer: exclude:` list using standard glob patterns:
```yaml
analyzer:
exclude:
- "lib/generated/**"
- "**/*.g.dart"
```
- **File-Level Suppressions**: Add `// ignore_for_file: diagnostic_name` on a dedicated line at the absolute top of the Dart file to disable specific rules across the entire file context.
- **Line-Level Suppressions**: Add `// ignore: diagnostic_name` on the line directly preceding the target statement, or appended at the end of the matching line.
- **Pubspec Suppressions**: Suppress package dependency warnings within the `pubspec.yaml` by injecting comments (e.g. `# ignore: sort_pub_dependencies`).
## Workflow: Running Static Analysis
Follow this checklist to perform static code auditing:
- [ ] **Establish analysis config**: Ensure `analysis_options.yaml` exists at the project root.
- [ ] **Run analysis**: Run the analyzer from the terminal:
```bash
dart analyze .
```
- [ ] **Escalate infos to fatal**: In CI/CD pipelines, ensure informational lints fail the build by appending the fatal flag:
```bash
dart analyze . --fatal-infos
```
- [ ] **Triage diagnostics**: Review warnings, correcting type hierarchies or unused variables, or applying suppressions where appropriate.
## Workflow: Applying Automated Code Fixes
Follow this checklist to apply mechanical quick-fixes automatically:
- [ ] **Verify lints**: Confirm that the target linter rules are enabled in `analysis_options.yaml`.
- [ ] **Dry run check**: Run a dry run to inspect proposed mechanical modifications:
```bash
dart fix --dry-run
```
- [ ] **Apply fixes**: Apply the quick-fixes directly across the workspace:
```bash
dart fix --apply
```
- [ ] **Format code**: Format the modified code files:
```bash
dart format .
```
- [ ] **Re-run analysis**: Confirm that `dart analyze` reports clean results.
## Examples
### Comprehensive `analysis_options.yaml` Template
```yaml
include: package:lints/recommended.yaml
analyzer:
exclude:
- "lib/generated/**"
- "**/*.g.dart"
- "**/*.freezed.dart"
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
todo: ignore
missing_required_param: error
missing_return: error
linter:
rules:
always_declare_return_types: true
avoid_empty_else: true
prefer_const_constructors: true
sort_pub_dependencies: false
formatter:
page_width: 100
trailing_commas: preserve
```
### Inline Suppression Techniques
```dart
// 1. Suppress all instances of unused variables inside this specific file
// ignore_for_file: unused_local_variable
void calculateMetrics() {
// 2. Suppress a single line using a preceding comment ignore
// ignore: invalid_assignment
int x = 'not_an_int';
final unusedString = 'value'; // File-level ignore handles this
// 3. Suppress at the end of the line
final double pi = 3.14; // ignore: constant_identifier_names
}
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.