sf-code-analyzer-quality

Configure and run Salesforce Code Analyzer v5 static analysis gates for Apex, LWC, and metadata.

2|Updated Sep 12, 2026
One-click install
npx skills add https://github.com/grzmol/vibe-force --skill sf-code-analyzer-quality-grzmol
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sf-code-analyzer-quality
Source: https://github.com/grzmol/vibe-force/tree/main/skills/sf-code-analyzer-quality
Command: npx skills add https://github.com/grzmol/vibe-force --skill sf-code-analyzer-quality-grzmol

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Salesforce teams struggle to enforce consistent static analysis across Apex, LWC, Flows, and metadata: Code Analyzer v5 has seven engines, a complex rule selector grammar, and a severity taxonomy that is easy to misconfigure, leading to noisy reports, silently disabled security rules, or gates that block all delivery on legacy codebases. ## Core Features & Use Cases - Engine and CLI mastery: Covers sf code-analyzer run/rules/config with --workspace, --target, --rule-selector, --severity-threshold, and output formats (JSON, HTML, SARIF) across the pmd, eslint, regex, retire-js, flow, cpd, and sfge engines. - Configuration and custom rules: Provides the code-analyzer.yml schema, severity and tag overrides, custom PMD XPath rulesets, regex convention rules, ESLint flat config with @salesforce/eslint-config-lwc, and Prettier with prettier-plugin-apex. - Gate policy and legacy adoption: Defines the 1-5 severity taxonomy, suppression markers with caps and reasons, and baseline-plus-ratchet strategies for introducing the gate to legacy code without stopping delivery. - Use Case: A vf-check analyzer run fails on a pull request; use this Skill to triage the violation, decide fix versus suppression, write a scoped suppression with max_suppressed_violations and a ticket reference, and verify the gate exits 0. ## Quick Start Ask the assistant to configure Salesforce Code Analyzer for the project and run the recommended ruleset with a severity threshold of 3 against the changed files.

Frequently Asked Questions about sf-code-analyzer-quality

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Salesforce Code Analyzer on only changed files?▼

Pass the changed files as `--target` while keeping the full project as `--workspace`, for example `sf code-analyzer run --workspace . --target force-app/main/default/classes --rule-selector Recommended`. Graph Engine needs the whole workspace to build its call graph even when targeting a subset.

How do I suppress a Code Analyzer violation in Apex or JavaScript?▼

Add an in-source marker like `// code-analyzer-suppress-next-line eslint:no-console -- reason` for line-scoped suppression, or a config entry under `suppressions` with a `rule_selector`, `max_suppressed_violations` cap, and `reason`. Prefer line-scoped markers over a bare `code-analyzer-suppress`, which suppresses to end of file.

What is the difference between --workspace and --target in sf code-analyzer run?▼

`--workspace` defines the analysis context (default `.`), while `--target` narrows which files produce violations. Engines like Salesforce Graph Engine compile the entire workspace to build a call graph, so omitting `--workspace` on targeted runs causes missed or misreported paths.

Does Salesforce Code Analyzer require Java or Python?▼

The pmd, cpd, and sfge engines require JDK 11 or later, and the flow engine requires Python 3.10 or later. The eslint, retire-js, and regex engines need only Node. In lean CI images, disable unavailable engines in `code-analyzer.yml` rather than tolerating engine errors.

How do I introduce static analysis to a legacy Salesforce codebase without blocking delivery?▼

Measure the full inventory first, then gate only new and changed files, and record remaining debt as capped config suppressions with a ticket reference. Ratchet `max_suppressed_violations` down each iteration until the count reaches zero and the suppression block is deleted.

Why does the eslint rule selector flood my report with violations?▼

Using `--rule-selector eslint` selects every ESLint rule, not just the recommended set. Append `:Recommended` (for example `eslint:Recommended`) to stay inside the recommended rules and keep the PR gate fast and stable.