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.

scripts/validate-config.sh

View on GitHub
#!/bin/bash
# validate-config.sh
# Validates a code-analyzer.yml configuration file.
# Usage: bash <skill_dir>/scripts/validate-config.sh [config-file]
#
# If no config file is specified, looks for code-analyzer.yml in current directory.
#
# Exit codes:
#   0 = Config is valid
#   1 = Config has errors

set -euo pipefail

CONFIG_FILE="${1:-code-analyzer.yml}"

echo "Validating: ${CONFIG_FILE}"
echo ""

# Check file exists
if [ ! -f "$CONFIG_FILE" ]; then
    echo "ERROR: Config file not found: ${CONFIG_FILE}"
    echo ""
    echo "Expected locations:"
    echo "  - ./code-analyzer.yml"
    echo "  - ./code-analyzer.yaml"
    echo ""
    echo "Generate one with: sf code-analyzer config --output-file code-analyzer.yml"
    exit 1
fi

# Check file is not empty
if [ ! -s "$CONFIG_FILE" ]; then
    echo "ERROR: Config file is empty: ${CONFIG_FILE}"
    exit 1
fi

# Basic YAML syntax check (if python3 available)
if command -v python3 &> /dev/null; then
    echo "Checking YAML syntax..."
    if python3 - "$CONFIG_FILE" 2>&1 <<'PYEOF'; then
import yaml, sys
config_file = sys.argv[1]
try:
    with open(config_file, 'r') as f:
        config = yaml.safe_load(f)
    if config is None:
        print('WARNING: Config file is empty or contains only comments')
        sys.exit(0)
    if not isinstance(config, dict):
        print('ERROR: Config must be a YAML mapping (dictionary)')
        sys.exit(1)
    print('YAML syntax: OK')
except yaml.YAMLError as e:
    print('ERROR: Invalid YAML syntax')
    print(f'  {e}')
    sys.exit(1)
PYEOF
        echo ""
    else
        echo ""
        echo "Fix YAML syntax errors before proceeding."
        exit 1
    fi
else
    echo "WARNING: python3 not found — skipping YAML syntax validation (install python3 for full checks)"
fi

# Validate known field names
echo "Checking known fields..."
VALID_TOP_LEVEL="config_root log_folder log_level rules engines ignores suppressions"

if command -v python3 &> /dev/null; then
    python3 - "$CONFIG_FILE" "$VALID_TOP_LEVEL" 2>&1 <<'PYEOF'
import yaml, sys

config_file = sys.argv[1]
valid_top_level = sys.argv[2]

with open(config_file, 'r') as f:
    config = yaml.safe_load(f)

if config is None:
    sys.exit(0)

valid_fields = set(valid_top_level.split())
unknown = set(config.keys()) - valid_fields
if unknown:
    print(f'WARNING: Unknown top-level fields: {sorted(unknown)}')
    print('  Valid fields: config_root, log_folder, log_level, rules, engines, ignores, suppressions')
else:
    print('Known fields: OK')

# Check engines section
if 'engines' in config and config['engines']:
    valid_engines = {'pmd', 'cpd', 'eslint', 'regex', 'retire-js', 'flow', 'sfge', 'apexguru'}
    configured_engines = set(config['engines'].keys())
    unknown_engines = configured_engines - valid_engines
    if unknown_engines:
        print(f'WARNING: Unknown engine names: {sorted(unknown_engines)}')
        print(f'  Valid engines: {sorted(valid_engines)}')
    else:
        print(f'Engines configured: {sorted(configured_engines)}')

# Check ignores section
if 'ignores' in config and config['ignores']:
    if 'files' not in config['ignores']:
        print('WARNING: ignores section should contain a "files" list')
    elif not isinstance(config['ignores']['files'], list):
        print('ERROR: ignores.files must be a list of glob patterns')
        sys.exit(1)
    else:
        print(f'Ignore patterns: {len(config["ignores"]["files"])} patterns configured')

# Check rules section
if 'rules' in config and config['rules']:
    for engine, rules in config['rules'].items():
        if rules and isinstance(rules, dict):
            for rule_name, overrides in rules.items():
                if overrides and isinstance(overrides, dict):
                    if 'severity' in overrides:
                        sev = overrides['severity']
                        valid_sevs = [1, 2, 3, 4, 5, 'Critical', 'High', 'Moderate', 'Low', 'Info']
                        if sev not in valid_sevs:
                            print(f'WARNING: rules.{engine}.{rule_name}.severity = {sev} (expected 1-5 or Critical/High/Moderate/Low/Info)')

print('')
PYEOF
fi

# Run sf code-analyzer config validation (if sf CLI available)
echo ""
echo "Running Code Analyzer validation..."
if command -v sf &> /dev/null; then
    if sf plugins --core 2>&1 | grep -qi "code-analyzer"; then
        if sf code-analyzer config --config-file "$CONFIG_FILE" > /dev/null 2>&1; then
            echo "Code Analyzer validation: PASSED"
            echo ""
            echo "Configuration is valid and ready to use."
            exit 0
        else
            echo "Code Analyzer validation: FAILED"
            echo ""
            echo "Running with verbose output:"
            sf code-analyzer config --config-file "$CONFIG_FILE" 2>&1 || true
            exit 1
        fi
    else
        echo "SKIP: Code Analyzer plugin not installed (cannot run full validation)"
        echo "Install: sf plugins install @salesforce/plugin-code-analyzer"
    fi
else
    echo "SKIP: sf CLI not available (cannot run full validation)"
fi

echo ""
echo "Basic validation passed. Install Code Analyzer for full validation."
exit 0
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: 197kUpdated 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