Skip to content

Latest commit

 

History

History
768 lines (581 loc) · 14.4 KB

File metadata and controls

768 lines (581 loc) · 14.4 KB

CodeGuard Troubleshooting Guide

This guide helps you diagnose and resolve common issues with CodeGuard.

Table of Contents

Extension Not Activating

Symptom

CodeGuard doesn't appear to be running. No diagnostics appear, status bar is missing.

Possible Causes & Solutions

1. Extension Not Installed

Check: Extensions view (Ctrl+Shift+X)

Solution: Install CodeGuard from the marketplace

2. Extension Disabled

Check: Extensions view → CodeGuard → Enabled

Solution: Click "Enable" button

3. Unsupported File Type

Check: File extension and language mode

Supported: .js, .ts, .py, .java
Solution: Open a supported file type

4. Extension Crashed

Check: Output panel (View → Output → CodeGuard)

Solution: 
1. Check for error messages
2. Reload window: Ctrl+Shift+P → "Developer: Reload Window"
3. If persists, reinstall extension

5. Activation Event Not Triggered

Check: package.json activation events

Solution:
1. Open a supported file (.js, .ts, .py, .java)
2. Or manually trigger: Ctrl+Shift+P → "CodeGuard: Analyze Current File"

Verification Steps

  1. Check extension is installed:

    • Open Extensions view (Ctrl+Shift+X)
    • Search for "CodeGuard"
    • Verify it shows "Installed"
  2. Check extension is enabled:

    • In Extensions view, ensure CodeGuard is not disabled
    • Check both workspace and globally
  3. Check Output panel:

    • View → Output
    • Select "CodeGuard" from dropdown
    • Look for activation messages or errors
  4. Check file language:

    • Bottom-right corner of VSCode shows language mode
    • Should be JavaScript, TypeScript, Python, or Java

Analysis Issues

Symptom

Analysis doesn't run or diagnostics don't appear.

Issue: Analysis Not Triggering

Possible Causes:

  1. CodeGuard disabled in settings
  2. Debounce delay too long
  3. File too large (timeout)
  4. Analyzer crashed

Solutions:

// Check settings
{
  "codeguard.enabled": true,  // Must be true
  "codeguard.debounceMs": 500  // Try reducing if too slow
}

Manual trigger:

  • Ctrl+Shift+P → "CodeGuard: Analyze Current File"
  • Or keyboard shortcut: Ctrl+Shift+G

Issue: Diagnostics Not Appearing

Check:

  1. Problems panel (Ctrl+Shift+M) - are issues listed?
  2. Output panel - any error messages?
  3. Specific analyzers enabled?

Solutions:

// Ensure analyzers are enabled
{
  "codeguard.analyzers.security.enabled": true,
  "codeguard.analyzers.performance.enabled": true,
  "codeguard.analyzers.secrets.enabled": true,
  "codeguard.analyzers.codeSmells.enabled": true
}

Issue: Analysis Timeout

Symptom: Large files don't complete analysis

Solution:

{
  "codeguard.maxAnalysisTimeMs": 10000  // Increase timeout
}

Or enable incremental analysis (automatic for files >5000 lines).

Issue: Specific Analyzer Not Working

Check which analyzers ran:

  • Output panel shows which analyzers executed
  • Check for analyzer-specific errors

Solution:

// Disable problematic analyzer temporarily
{
  "codeguard.analyzers.security.enabled": false
}

Then report the issue on GitHub with:

  • File content (if shareable)
  • Error messages from Output panel
  • CodeGuard version

Performance Problems

Symptom

Analysis is slow, VSCode feels sluggish, high CPU/memory usage.

Issue: Slow Analysis

Causes:

  • Large files
  • Cache disabled
  • Too many analyzers enabled
  • Debounce too short

Solutions:

{
  // Increase debounce to reduce frequency
  "codeguard.debounceMs": 1000,
  
  // Enable caching
  "codeguard.cache.enabled": true,
  
  // Disable unused analyzers
  "codeguard.analyzers.codeSmells.enabled": false
}

For large files:

  • Incremental analysis activates automatically at 5000 lines
  • Consider splitting large files

Issue: High CPU Usage

Check:

  • Task Manager / Activity Monitor
  • VSCode's "Show Running Extensions"

Solutions:

  1. Increase debounce:

    {
      "codeguard.debounceMs": 1000
    }
  2. Disable analyzers:

    {
      "codeguard.analyzers.performance.enabled": false
    }
  3. Limit analysis scope:

    • Close unused files
    • Use .codeguardignore to exclude files

Issue: High Memory Usage

Check: Task Manager / Activity Monitor

Solutions:

{
  // Reduce cache size
  "codeguard.cache.maxMemoryMB": 25,
  "codeguard.cache.maxDiskMB": 250,
  
  // Or disable caching
  "codeguard.cache.enabled": false
}

If memory usage exceeds 200MB:

  • CodeGuard automatically disables caching
  • Check Output panel for warnings
  • Consider restarting VSCode

Issue: VSCode Freezing

Cause: Analysis blocking main thread (bug)

Immediate solution:

  1. Disable CodeGuard temporarily
  2. Reload window
  3. Report bug on GitHub

Workaround:

{
  "codeguard.enabled": false
}

AI Features Not Working

Symptom

"Fix with AI" doesn't work or produces errors.

Issue: AI Not Enabled

Check:

{
  "codeguard.ai.enabled": true,  // Must be true
  "codeguard.ai.provider": "ollama"  // Must not be "none"
}

Issue: Ollama Not Running

For local AI (Ollama):

  1. Check Ollama is installed:

    ollama --version
  2. Check Ollama is running:

    ollama list
  3. Pull a model:

    ollama pull codellama
  4. Configure CodeGuard:

    {
      "codeguard.ai.enabled": true,
      "codeguard.ai.provider": "ollama",
      "codeguard.ai.model": "codellama"
    }

Issue: OpenAI/Claude API Errors

Check API key:

{
  "codeguard.ai.apiKey": "sk-..."  // Must be valid
}

Common errors:

  1. Invalid API key:

  2. Rate limit exceeded:

    • Wait for rate limit to reset
    • CodeGuard automatically retries with backoff
  3. Network error:

    • Check internet connection
    • Check firewall settings
    • Try different network
  4. Model not available:

    {
      "codeguard.ai.model": "gpt-4"  // Verify model exists
    }

Issue: AI Timeout

Symptom: "Fix with AI" times out

Solution:

{
  "codeguard.ai.timeout": 5000  // Increase timeout (ms)
}

Issue: Poor AI Suggestions

Causes:

  • Model not suitable for code
  • Insufficient context
  • Complex issue

Solutions:

  1. Try different model:

    {
      "codeguard.ai.model": "gpt-4"  // More capable
    }
  2. Adjust temperature:

    {
      "codeguard.ai.temperature": 0.1  // More deterministic
    }
  3. Use rule-based fixes:

    • Disable AI temporarily
    • CodeGuard falls back to rule-based fixes

Cache Issues

Symptom

Cache not working, stale results, or cache errors.

Issue: Cache Not Working

Check:

{
  "codeguard.cache.enabled": true  // Must be true
}

Verify cache is working:

  • Output panel shows "cache hit" messages
  • Second analysis of same file should be instant

Issue: Stale Results

Symptom: Old diagnostics persist after fixing code

Solution:

  1. Clear cache:

    • Ctrl+Shift+P → "CodeGuard: Clear Cache"
  2. Reload window:

    • Ctrl+Shift+P → "Developer: Reload Window"
  3. Disable cache temporarily:

    {
      "codeguard.cache.enabled": false
    }

Issue: Cache Corruption

Symptom: Errors about cache, inconsistent results

Solution:

  1. Delete cache directory:

    • Windows: %APPDATA%\Code\User\globalStorage\codeguard\cache
    • Mac: ~/Library/Application Support/Code/User/globalStorage/codeguard/cache
    • Linux: ~/.config/Code/User/globalStorage/codeguard/cache
  2. Reload VSCode

Issue: Cache Taking Too Much Space

Check disk usage:

  • Default: 500MB max
  • Location: See above

Solution:

{
  "codeguard.cache.maxDiskMB": 250  // Reduce limit
}

Or clear cache periodically:

  • Ctrl+Shift+P → "CodeGuard: Clear Cache"

Configuration Problems

Symptom

Settings not taking effect, configuration errors.

Issue: Settings Not Applied

Check configuration priority:

  1. .codeguardrc.json (highest priority)
  2. Workspace settings
  3. User settings
  4. Default settings

Solution:

  • Check all configuration sources
  • Remove conflicting settings
  • Reload window after changes

Issue: Invalid Configuration

Symptom: Error messages about configuration

Check:

  • JSON syntax in .codeguardrc.json
  • Valid values for enum settings
  • Correct types (number vs string)

Example valid configuration:

{
  "version": "1.0",
  "enabled": true,
  "debounceMs": 500,
  "analyzers": {
    "security": {
      "enabled": true,
      "severity": {
        "sql-injection": "error"
      }
    }
  }
}

Issue: Configuration Not Found

Symptom: .codeguardrc.json ignored

Check:

  • File is in workspace root
  • File name is exactly .codeguardrc.json
  • JSON is valid (use JSON validator)

Verify:

# In workspace root
ls -la .codeguardrc.json

Memory Issues

Symptom

High memory usage, out of memory errors.

Issue: Memory Leak

Symptoms:

  • Memory usage grows over time
  • VSCode becomes slow
  • Eventually crashes

Immediate solution:

  1. Reload window: Ctrl+Shift+P → "Developer: Reload Window"
  2. Reduce cache size (see above)

Report bug:

  • Include memory profile
  • Steps to reproduce
  • VSCode version and OS

Issue: Memory Limit Exceeded

Symptom: Warning about memory usage >200MB

Solutions:

{
  // Reduce cache
  "codeguard.cache.maxMemoryMB": 25,
  
  // Or disable cache
  "codeguard.cache.enabled": false,
  
  // Disable unused analyzers
  "codeguard.analyzers.codeSmells.enabled": false
}

False Positives

Symptom

CodeGuard flags code that is actually safe.

Issue: Too Many False Positives

Solutions:

  1. Ignore specific issue:

    • Hover over diagnostic
    • Click "Ignore this issue"
    • Adds to .codeguardignore
  2. Adjust severity:

    {
      "analyzers": {
        "security": {
          "severity": {
            "sql-injection": "warning"  // Downgrade from error
          }
        }
      }
    }
  3. Disable specific rule:

    {
      "analyzers": {
        "security": {
          "customRules": {
            "sql-injection": false
          }
        }
      }
    }
  4. Report false positive:

    • Open issue on GitHub
    • Include code sample
    • Explain why it's a false positive

Issue: Ignoring Not Working

Check .codeguardignore file:

{
  "version": "1.0",
  "rules": [
    {
      "ruleId": "sql-injection",
      "filePattern": "src/legacy/**",
      "reason": "Legacy code"
    }
  ]
}

Verify:

  • File is in workspace root
  • JSON is valid
  • Rule ID matches diagnostic code
  • File pattern matches file path

Diagnostic Tools

Enable Debug Logging

{
  "codeguard.logLevel": "debug"
}

Then check Output panel (View → Output → CodeGuard).

Check Extension Status

  1. Running Extensions:

    • Ctrl+Shift+P → "Developer: Show Running Extensions"
    • Find CodeGuard
    • Check activation time and status
  2. Extension Host Log:

    • Help → Toggle Developer Tools
    • Console tab
    • Filter for "CodeGuard"

Profile Performance

  1. Profile Extension:

    • Developer: Show Running Extensions
    • Click "Profile" next to CodeGuard
    • Perform actions
    • Stop profiling
    • Analyze results
  2. CPU Profile:

    • Help → Toggle Developer Tools
    • Performance tab
    • Record profile
    • Analyze hot paths

Memory Profiling

  1. Heap Snapshot:

    • Help → Toggle Developer Tools
    • Memory tab
    • Take heap snapshot
    • Analyze memory usage
  2. Memory Timeline:

    • Memory tab
    • Record allocation timeline
    • Identify memory leaks

Network Monitoring

Check AI API calls:

  • Help → Toggle Developer Tools
  • Network tab
  • Filter for API domains
  • Verify requests/responses

Getting Help

Before Asking for Help

Collect this information:

  1. CodeGuard version:

    • Extensions view → CodeGuard → Version
  2. VSCode version:

    • Help → About
  3. Operating system:

    • Windows, Mac, Linux + version
  4. Error messages:

    • Output panel (View → Output → CodeGuard)
    • Developer Tools console
  5. Configuration:

    • Settings (sanitize API keys!)
    • .codeguardrc.json content
  6. Steps to reproduce:

    • Detailed steps
    • Sample code (if shareable)

Where to Get Help

  1. Documentation:

    • README.md
    • CONTRIBUTING.md
    • GitHub Wiki
  2. GitHub Issues:

    • Search existing issues
    • Open new issue with template
  3. GitHub Discussions:

    • Ask questions
    • Share ideas
    • Get community help
  4. Discord:

    • Real-time chat
    • Community support
  5. GitHub Support:

Reporting Bugs

Use the bug report template:

**Describe the bug**
A clear description of what the bug is.

**To Reproduce**
Steps to reproduce:
1. Open file '...'
2. Type '...'
3. See error

**Expected behavior**
What you expected to happen.

**Actual behavior**
What actually happened.

**Screenshots**
If applicable, add screenshots.

**Environment**
- CodeGuard version: [e.g., 0.1.0]
- VSCode version: [e.g., 1.85.0]
- OS: [e.g., Windows 11]

**Logs**
Paste relevant logs from Output panel.

**Configuration**
Paste relevant settings (sanitize secrets!).

Emergency Workarounds

If CodeGuard is completely broken:

  1. Disable extension:

    • Extensions view → CodeGuard → Disable
  2. Uninstall and reinstall:

    • Extensions view → CodeGuard → Uninstall
    • Restart VSCode
    • Reinstall from marketplace
  3. Reset all settings:

    {
      "codeguard.enabled": false
    }
    • Delete .codeguardrc.json
    • Clear cache directory
    • Reload window
    • Re-enable with default settings

Still having issues? Open an issue on GitHub with the information above.