Skip to content

forcedotcom/sf-skills / plugins/builder/salesforce-code-quality/skills/dx-code-analyzer-configure

dx-code-analyzer-configure

Flagged

Set up, configure, and troubleshoot Salesforce Code Analyzer for any project. Handles installation, prerequisite checks, diagnosing broken setups, creating and editing code-analyzer.yml overrides, engine-specific settings, ignore patterns, severity overrides, and CI/CD pipeline setup. TRIGGER when: user says 'set up code analyzer', 'configure code analyzer', 'install code analyzer', 'code analyzer not working', 'fix my setup', 'scan failing', 'check my setup', 'enable/disable engine', 'exclude files', 'change severity', 'set up GitHub Actions', 'set up CI/CD', 'add to pipeline', 'pipeline fail', 'update my workflow', 'quality gate', 'fail on violations', 'scan changed files only', 'add SARIF', 'code-analyzer.yml', 'ESLint config', 'increase SFGE memory', or reports errors running Code Analyzer. DO NOT TRIGGER when: user wants to run a scan (use dx-code-analyzer-run), fix violations, explain rules, create custom rules (use dx-code-analyzer-custom-rule-create), or suppress violations.

references/config-schema.md

View on GitHub
# Code Analyzer Configuration Schema

Full reference for the `code-analyzer.yml` configuration file.

## Top-Level Fields

```yaml
# code-analyzer.yml

# Root directory for resolving relative paths in the config
config_root: .

# Directory where Code Analyzer writes log files
log_folder: /tmp

# Log verbosity: 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Fine
log_level: 3

# File patterns to exclude from analysis
ignores:
  files: []

# Rule severity, tag, and disable overrides
rules: {}

# Engine-specific configuration
engines: {}

# Bulk suppression rules
suppressions:
  disable_suppressions: false
```

## Ignores Section

```yaml
ignores:
  files:
    - "**/node_modules/**"      # npm dependencies
    - "**/.sfdx/**"             # Salesforce DX internal
    - "**/.sf/**"               # Salesforce CLI internal
    - "**/test/**"              # Test directories
    - "**/*.test.js"            # Test files
    - "**/*.min.js"             # Minified files
    - "**/staticresources/**"   # Static resources (often vendor)
```

**Pattern syntax:** Glob patterns using `*` (any filename chars), `**` (any path segment), `?` (single char).

## Rules Section

Override severity, tags, or disable rules per engine:

```yaml
rules:
  <engine_name>:
    <rule_name>:
      severity: <1-5 or "Critical"|"High"|"Moderate"|"Low"|"Info">
      tags: ["Tag1", "Tag2"]    # Override rule tags
      disabled: true|false       # Disable/enable rule
```

### Severity Values

| Number | Name | Meaning |
|--------|------|---------|
| 1 | Critical | Security vulnerabilities, must fix before release |
| 2 | High | Significant issues, should fix |
| 3 | Moderate | Recommended improvements |
| 4 | Low | Minor suggestions |
| 5 | Info | Informational, no action required |

### Example Rule Overrides

```yaml
rules:
  pmd:
    ApexCRUDViolation:
      severity: 1               # Promote to Critical
    AvoidGlobalModifier:
      disabled: true            # Disable entirely
    ApexDoc:
      severity: 5              # Demote to Info
      tags: ["Documentation"]
  eslint:
    no-console:
      severity: 4              # Demote to Low
    no-unused-vars:
      severity: 2              # Promote to High
```

## Engines Section

### PMD Engine

```yaml
engines:
  pmd:
    disable_engine: false
    java_command: "java"                    # Path to Java executable
    custom_rulesets:                        # Additional ruleset XML files
      - "./config/custom-pmd-rules.xml"
    java_classpath_entries:                 # JARs for custom Java rules
      - "./lib/my-custom-rules.jar"
    file_extensions:                        # Override scanned file types
      apex: [".cls", ".trigger"]
      visualforce: [".page", ".component"]
```

### ESLint Engine

```yaml
engines:
  eslint:
    disable_engine: false
    auto_discover_eslint_config: true       # Use project's eslint config files
    eslint_config_file: "./eslint.config.mjs"  # Explicit config file path
    disable_javascript_base_config: false   # Disable built-in JS rules
    disable_typescript_base_config: false   # Disable built-in TS rules
    disable_lwc_base_config: false          # Disable built-in LWC rules
    disable_flow_base_config: false         # Disable built-in Flow rules
```

**Note:** `auto_discover_eslint_config` requires a `--workspace` flag on the run command.

### CPD Engine (Copy-Paste Detector)

```yaml
engines:
  cpd:
    disable_engine: false
    minimum_tokens:                         # Min tokens for duplicate detection
      apex: 100                             # Lower = more sensitive
      html: 100
      javascript: 100
      visualforce: 100
      xml: 100
    skip_duplicate_files: false             # Skip files with identical content
```

### SFGE Engine (Salesforce Graph Engine)

```yaml
engines:
  sfge:
    disable_engine: false
    java_max_heap_size: "4g"               # JVM heap (increase for large projects)
    java_thread_count: 4                    # Parallel threads
    java_thread_timeout: 900000             # Per-thread timeout in ms
```

**Warning:** SFGE is resource-intensive. For projects with 500+ Apex classes, use 4g+ heap. Analysis can take 10-30 minutes.

### ApexGuru Engine

```yaml
engines:
  apexguru:
    disable_engine: false
    target_org: "my-org-alias"             # Authenticated org alias or username
    api_timeout_ms: 300000                  # API timeout in ms (default 5min)
```

**Requires:** Authenticated Salesforce org (`sf org login web`).

### Flow Engine

```yaml
engines:
  flow:
    disable_engine: false
    python_command: "python3"              # Path to Python 3 executable
```

**Requires:** Python 3 installed.

### Regex Engine

```yaml
engines:
  regex:
    disable_engine: false
    custom_rules:
      <RuleName>:
        regex: "/<pattern>/<flags>"         # JavaScript regex syntax
        regex_ignore: "/<pattern>/<flags>"  # Optional: false positive filter
        file_extensions: [".cls", ".trigger"]
        description: "What this rule checks"
        violation_message: "Message shown to developer"
        severity: 3
        tags: ["Recommended", "Security"]
```

### RetireJS Engine

```yaml
engines:
  retire-js:
    disable_engine: false
```

**Note:** RetireJS scans JavaScript dependencies for known CVEs. No additional configuration needed beyond enable/disable.

## Suppressions Section

```yaml
suppressions:
  disable_suppressions: false              # Set true to ignore ALL suppressions

  # Bulk suppressions by file/folder path
  "src/legacy/":
    - rule_selector: "pmd:ApexDoc"
      max_suppressed_violations: 50        # Quota (null = unlimited)
      reason: "Legacy code, documentation not required"

  "src/utils/Logger.cls":
    - rule_selector: "eslint:no-console"
      max_suppressed_violations: 10
      reason: "Logger intentionally uses console"
```

### Inline Suppression Markers

In addition to bulk config suppressions, violations can be suppressed inline:

```java
// Apex: PMD suppression
// NOPMD - reason here
@SuppressWarnings('PMD.ApexCRUDViolation')

// Any engine: universal marker
// code-analyzer-suppress(pmd:ApexCRUDViolation) - reason
// code-analyzer-suppress(eslint:no-console) - reason
```

## Config File Discovery

Code Analyzer automatically looks for configuration in this order:
1. File specified via `--config-file` flag
2. `code-analyzer.yml` in current working directory
3. `code-analyzer.yaml` in current working directory
4. No config (use defaults)

## Validating Configuration

Always validate after making changes:

```bash
# Validate config and show effective settings
sf code-analyzer config --config-file code-analyzer.yml

# Show config for specific rules
sf code-analyzer config --rule-selector pmd:Security

# Show all rule defaults (verbose)
sf code-analyzer config --include-unmodified-rules --rule-selector all
```
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall