Repository navigation
Troubleshooting
This guide covers common issues when using the SonarQube Mathematica Plugin and their solutions.
- Performance Issues
- Installation Issues
- Configuration Issues
- Analysis Issues
- Memory Issues
- Authentication Issues
- File Detection Issues
- Rule and Issue Issues
- Integration Issues
- Quality Gate Issues
Symptoms:
- Individual files take 30+ seconds to analyze
- Scanner appears to hang on specific files
- CPU usage spikes to 100% for extended periods
- Log shows: "Analyzing file X... (still running after 60s)"
Causes:
- Regex backtracking (in older versions) - Exponential complexity on complex patterns
- Symbol table analysis - O(n²) complexity on files with many variables
- Complex nested structures - Deep nesting causes recursive analysis
Solutions:
1. Check plugin version:
# In SonarQube UI: Administration → Marketplace → Installed
# Should be version 1.0.0 or higherVersion 1.0.0+ uses O(n) UnifiedRuleVisitor pattern (99.75% faster than older regex-based versions).
2. Exclude problematic files if they're generated/legacy:
# In sonar-project.properties
sonar.exclusions=**/generated/**,**/legacy/LargeFile.wl3. Split large files into smaller modules:
(* Instead of one 10,000-line file: *)
(* File: Monolithic.wl - 10,000 lines *)
(* Split into: *)
(* File: Module1.wl - 2,000 lines *)
(* File: Module2.wl - 2,000 lines *)
(* etc. *)4. Disable symbol table analysis for specific files (if needed):
# Trade accuracy for speed on specific files
# (Not directly configurable - use exclusions)
sonar.exclusions=**/ProblematicFile.wlExpected Performance:
- Small files (<500 lines): <1 second each
- Medium files (500-2000 lines): 1-5 seconds each
- Large files (2000-5000 lines): 5-30 seconds each
- Very large files (5000+ lines): 30-90 seconds each (mostly symbol table)
Prevention:
- Keep files under 2000 lines when possible
- Use modular design
- Regularly update plugin (performance improvements in each release)
Symptoms:
ERROR: Error during SonarQube Scanner execution
ERROR: Issue saver thread did not finish in time (timeout: 600s)
ERROR: Analysis failed due to timeout
Causes:
- Too many issues being reported (100,000+)
- Slow network connection to SonarQube server
- SonarQube server is overloaded
- Database performance issues
Solutions:
1. Increase timeout:
# In sonar-project.properties
sonar.ws.timeout=9002. Reduce issues by fixing code or disabling noisy rules:
# Disable less important rules temporarily
sonar.issue.ignore.multicriteria=e1,e2
sonar.issue.ignore.multicriteria.e1.ruleKey=mathematica:MagicNumber
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*3. Run analysis on same machine as SonarQube:
# Eliminates network latency
sonar-scanner -Dsonar.host.url=http://localhost:90004. Check SonarQube server health:
# Check compute engine logs
tail -f $SONARQUBE_HOME/logs/ce.log
# Look for slow database queries
# Consider database tuning if repeated5. Break large projects into smaller modules:
# Analyze subprojects separately
# Project 1:
sonar.projectKey=myproject-core
sonar.sources=src/core
# Project 2:
sonar.projectKey=myproject-utils
sonar.sources=src/utilsExpected Behavior:
- <10,000 issues: Should complete in <60 seconds
- 10,000-50,000 issues: 60-300 seconds
-
50,000 issues: Consider fixing code quality first!
Prevention:
- Fix high-severity issues first
- Use quality gates to prevent issue accumulation
- Regular incremental scans (not just big-bang analysis)
Symptoms:
- Total scan time exceeds reasonable duration
- All files seem slower, not just specific ones
- Previous scans were faster
Causes:
- SCM (Git) blame taking too long
- Duplication detection on too many files
- Memory pressure causing garbage collection pauses
- Network latency
- SonarQube server performance degradation
Solutions:
1. Identify bottleneck - check logs:
# Look at sensor execution times in log
tail -f $SONARQUBE_HOME/logs/ce.log | grep "sensor"
# Example output:
# MathematicaRulesSensor: 79s (15%)
# MathematicaMetricsSensor: 26s (5%)
# MathematicaCpdTokenizer: 153s (30%)
# SCM Publisher: 200s (39%) ← Bottleneck!2. If SCM Publisher is slow:
# Disable SCM blame (loses author info but much faster)
sonar.scm.disabled=true3. If duplication detection is slow:
# Increase thresholds (less sensitive = faster)
sonar.cpd.mathematica.minimumTokens=500
sonar.cpd.mathematica.minimumLines=50
# Or exclude files from duplication detection
sonar.cpd.exclusions=**/tests/**,**/examples/**4. If memory is the issue:
# In $SONARQUBE_HOME/conf/sonar.properties
sonar.ce.javaOpts=-Xmx4096m -Xms1024m -XX:MaxMetaspaceSize=512m5. Run scanner closer to SonarQube server:
# SSH into SonarQube server and run locally
ssh sonarqube-server
cd /path/to/project
sonar-scanner6. Use incremental analysis (Developer/Enterprise Edition):
# Only analyzes changed files (20x faster!)
# Requires SCM integration
sonar.scm.disabled=falsePerformance Benchmarks (654 files):
| Component | Expected Time | % of Total |
|---|---|---|
| Plugin rules | 79s | 15% |
| Plugin metrics | 26s | 5% |
| Plugin CPD | 153s | 30% |
| SCM Publisher | 200s | 39% |
| Issue saving | 30s | 6% |
| Other | 24s | 5% |
| Total | ~8-9 minutes | 100% |
Prevention:
- Regular incremental scans (not full scans)
- Keep Git history clean (affects SCM blame)
- Monitor SonarQube server resources
- Upgrade to latest plugin version (performance improvements)
Symptoms:
- Plugin doesn't appear in Administration → Marketplace → Installed
- No Mathematica language option in project settings
- SonarQube starts without errors but plugin missing
Causes:
- Multiple plugin versions in plugins directory (duplicate plugin error)
- Plugin file permissions incorrect
- Plugin not in correct directory
- SonarQube not restarted after installation
- Incompatible SonarQube version
Solutions:
1. Check for duplicate plugins:
ls -la $SONARQUBE_HOME/extensions/plugins/ | grep mathematica
# If you see multiple versions:
# wolfralyze-0.9.0.jar
# wolfralyze-1.0.0.jar
# ↑ This causes conflicts!
# Remove ALL versions:
rm $SONARQUBE_HOME/extensions/plugins/wolfralyze-*.jar
# Install only the latest:
cp wolfralyze-1.0.0.jar $SONARQUBE_HOME/extensions/plugins/2. Check file permissions:
# Plugin must be readable by SonarQube user
chmod 644 $SONARQUBE_HOME/extensions/plugins/wolfralyze-*.jar
# Check ownership
chown sonarqube:sonarqube $SONARQUBE_HOME/extensions/plugins/wolfralyze-*.jar3. Verify correct directory:
# Correct: extensions/plugins/
$SONARQUBE_HOME/extensions/plugins/wolfralyze-1.0.0.jar
# Wrong: extensions/downloads/ (not loaded from here)
$SONARQUBE_HOME/extensions/downloads/wolfralyze-1.0.0.jar4. Properly restart SonarQube:
# Stop SonarQube
$SONARQUBE_HOME/bin/macosx-universal-64/sonar.sh stop
# (or linux-x86-64/sonar.sh on Linux)
# Wait 10 seconds for full shutdown
sleep 10
# Start SonarQube
$SONARQUBE_HOME/bin/macosx-universal-64/sonar.sh start
# Check logs for plugin loading
tail -f $SONARQUBE_HOME/logs/sonar.log | grep -i mathematica
# Should see: "Deploy plugin Mathematica / 1.0.0 / ..."5. Check SonarQube version compatibility:
# Plugin requires SonarQube 9.9+
# Check your version:
curl http://localhost:9000/api/system/status | jq .version
# If version is too old, upgrade SonarQube first6. Check logs for errors:
# Main log
tail -100 $SONARQUBE_HOME/logs/sonar.log
# Web log
tail -100 $SONARQUBE_HOME/logs/web.log
# Look for errors like:
# - "Duplicate plugin key: mathematica"
# - "Plugin requires API version X but found Y"
# - "ClassNotFoundException" or "NoClassDefFoundError"Prevention:
- Always remove old plugin versions before installing new ones
- Use
make installcommand if building from source (handles cleanup) - Verify installation in UI before running scans
Symptoms:
ERROR Plugin mathematica [mathematica] requires plugin API 10.7,
but SonarQube provides 9.5
Cause: Plugin is too new for your SonarQube version, or vice versa.
Solution:
1. Check compatibility matrix:
| Plugin Version | Min SonarQube Version | Recommended SonarQube |
|---|---|---|
| 1.0.0+ | 9.9 | 10.7+ |
| 0.9.x | 9.9 | 10.0+ |
2. Upgrade SonarQube (recommended):
# Backup current installation
cp -r $SONARQUBE_HOME $SONARQUBE_HOME.backup
# Download newer SonarQube
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.7.0.96327.zip
# Follow upgrade guide
# (See SonarQube documentation)3. Or downgrade plugin (not recommended):
# Download older plugin version from GitHub releases
# that matches your SonarQube versionPrevention:
- Keep SonarQube updated to latest LTS
- Check compatibility before upgrading
Symptoms:
- Plugin shows in Marketplace → Installed
- Mathematica language appears in settings
- But: Rules page shows 0 Mathematica rules
- Or: Quality Profile has no rules activated
Causes:
- Quality Profile not activated
- Rules repository not loaded
- Browser cache showing stale data
- Database corruption
Solutions:
1. Activate Quality Profile:
1. Go to Quality Profiles
2. Look for "Sonar way (Mathematica)" profile
3. Click "Set as Default"
4. Or create project-specific profile binding
2. Check rules are loaded:
1. Go to Rules
2. Filter: Language = Mathematica
3. Should see 529 rules
4. If zero rules, check logs for errors
3. Clear browser cache:
- Hard refresh: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac)
- Or clear browser cache completely
- Re-login to SonarQube
4. Restart SonarQube:
$SONARQUBE_HOME/bin/[platform]/sonar.sh restart5. Check logs for rule loading errors:
grep -i "mathematica" $SONARQUBE_HOME/logs/web.log
grep -i "rule" $SONARQUBE_HOME/logs/web.log | grep -i error6. Re-analyze a project to trigger rule loading:
cd /path/to/project
sonar-scannerPrevention:
- Always verify rules are visible after installation
- Use default Quality Profile initially
- Don't modify profiles until verified working
Symptoms:
INFO: 0 files indexed
INFO: 0 source files to be analyzed
INFO: Analysis complete
Causes:
- Incorrect
sonar.sourcespath - No files with correct extensions
- Files excluded by patterns
- Scanner run from wrong directory
Solutions:
1. Verify sonar.sources path:
# In sonar-project.properties
# Relative to project root (where sonar-project.properties is)
sonar.sources=src
# Or absolute path
sonar.sources=/Users/bceverly/dev/myproject/src
# Multiple directories (comma-separated)
sonar.sources=src,lib,tests2. Check file extensions:
# List files that should be analyzed
find . -name "*.wl" -o -name "*.m" -o -name "*.wls"
# If no files found, check your extensions
# or configure custom extensions:sonar.mathematica.file.suffixes=.m,.wl,.wls,.mt3. Check for overly broad exclusions:
# This excludes everything!
sonar.exclusions=**/*
# Fix: Be specific
sonar.exclusions=**/tests/**,**/examples/**4. Run scanner from project root:
# Wrong: Running from subdirectory
cd src
sonar-scanner # Won't find sonar-project.properties!
# Right: Run from project root
cd /path/to/project
sonar-scanner5. Use verbose mode to debug:
sonar-scanner -X # Debug output
# Look for "Indexing files..." section
# Should show which files are found/excluded6. Verify files exist and are readable:
ls -la src/*.wl
# Check file permissions (should be readable)Prevention:
- Keep
sonar-project.propertiesin project root - Use relative paths in configuration
- Test with verbose mode first
- Keep exclusion patterns specific
Symptoms:
- Mathematica files analyzed as different language (e.g., JavaScript)
- Or: "Unknown language" warning
- Plugin rules not applied
Causes:
- File extension not configured for Mathematica
- Multiple plugins claiming same extension
- File association not set in project settings
Solutions:
1. Configure file suffixes explicitly:
# In sonar-project.properties
sonar.mathematica.file.suffixes=.m,.wl,.wls2. Check for plugin conflicts:
Administration → Marketplace → Installed
# Look for other plugins that might claim .m or .wl
# Example: Objective-C plugin also uses .m
# If conflict exists:
# Option A: Uninstall conflicting plugin
# Option B: Override language per-file pattern
sonar.lang.patterns.mathematica=**/*.wl,**/*.wls
3. Set language explicitly for specific patterns:
# Force .m files to Mathematica (not Objective-C)
sonar.lang.patterns.mathematica=**/*.m4. Check project language settings:
Project → Administration → General Settings → Languages
# Verify Mathematica is available
5. Verify plugin is enabled:
Administration → Marketplace → Installed
# Mathematica plugin should be in list and active (green)
Prevention:
- Use unique extensions (.wl instead of .m when possible)
- Configure explicit language patterns
- Don't mix incompatible plugins
Symptoms:
- Set exclusions but files still analyzed
- Changed file suffixes but not recognized
- Quality Profile changes not reflected
Causes:
- Configuration file not found
- Properties syntax error
- Cached configuration
- Settings overridden at project level
Solutions:
1. Verify configuration file location:
# Must be in directory where sonar-scanner is run
ls -la sonar-project.properties
# Or specify explicitly:
sonar-scanner -Dproject.settings=path/to/sonar-project.properties2. Check syntax:
# Wrong: Extra spaces around =
sonar.sources = src
# Right: No spaces around =
sonar.sources=src
# Wrong: Quotes around value (not needed)
sonar.sources="src"
# Right: No quotes
sonar.sources=src3. Clear scanner cache:
rm -rf .scannerwork
sonar-scanner4. Check for project-level overrides:
Project → Administration → Settings
# Settings here override sonar-project.properties
# Clear any unwanted overrides
5. Use command-line properties (highest priority):
# Override any configuration
sonar-scanner -Dsonar.exclusions="**/tests/**"6. Validate configuration:
# Run with debug output
sonar-scanner -X 2>&1 | grep -i "property"
# Shows all properties and their sourcesPriority order (highest to lowest):
- Command-line arguments (-D flags)
- Project settings in SonarQube UI
- sonar-project.properties file
- Default values
Prevention:
- Keep configuration in version control
- Document any UI-based settings
- Use verbose mode when debugging
Symptoms:
- Scan completes successfully
- 0 issues reported
- Code clearly has quality problems
Causes:
- Quality Profile has no rules activated
- Rules are activated but severity too low
- Files excluded from analysis
- Rules not matching code patterns
- Plugin version too old
Solutions:
1. Check Quality Profile:
Quality Profiles → Your Profile → Rules
# Filter: Language = Mathematica
# Should see many rules with "Active" status
# If 0 active rules, activate default profile:
# Option A: Set "Sonar way" as default
Quality Profiles → Sonar way (Mathematica) → Set as Default
# Option B: Activate rules manually
Your Profile → Activate More → Select rules → Bulk Activate
2. Check Quality Gate severity threshold:
Quality Gates → Your Gate
# If conditions require "Blocker" only, but issues are "Major":
# Issues are found but not flagged by Quality Gate
# View all issues regardless:
Project → Issues → Clear all filters
3. Verify files are analyzed:
Project → Code
# Should see list of analyzed files
# If empty, check configuration (sonar.sources)
4. Check exclusions:
# In sonar-project.properties
# Make sure you're not excluding everything:
sonar.exclusions=**/tests/** # OK
sonar.exclusions=**/* # BAD - excludes all files!5. Run on known-bad example:
(* Create test file: bad-code.wl *)
password = "hardcoded123"; (* Should trigger vulnerability rule *)
x = 1/0; (* Should trigger division by zero *)
y = If[x > 0, x, -x]; (* Should suggest Abs *)# Analyze test file
sonar-scanner -Dsonar.sources=bad-code.wl
# Should report 3+ issues6. Check plugin version:
# In SonarQube UI: Administration → Marketplace → Installed
# Should be 1.0.0 or later
# If older, upgrade:# Download latest from GitHub
# Install and restart SonarQube7. Check logs for rule execution:
tail -f $SONARQUBE_HOME/logs/ce.log | grep -i "rule"
# Should see: "Executing Mathematica rules..."Prevention:
- Always use default Quality Profile initially
- Test with known-bad code first
- Keep plugin updated
Symptoms:
- Hundreds of issues reported
- Many issues are false positives
- Code is actually correct but flagged
Causes:
- Rules too strict for your codebase
- Rules misunderstanding Mathematica idioms
- Generated or third-party code analyzed
- Context-specific patterns not recognized
Solutions:
1. Review and adjust Quality Profile:
Quality Profiles → Your Profile
# For each noisy rule:
# - Deactivate if not useful
# - Change severity (Major → Minor)
# - Or keep but mark as "Won't Fix" in issues
2. Mark false positives:
Issues → Select issue → "..." menu → Change Status
# Options:
# - "False Positive" - Rule is wrong
# - "Won't Fix" - Issue exists but intentional
# - Add comment explaining why
3. Exclude generated/third-party code:
sonar.exclusions=**/generated/**,**/external/**,**/vendor/**4. Configure rule parameters (if available):
Rules → Search for rule → Parameters tab
# Example: Complexity threshold
# Default: 10
# Adjust: 20 (less strict)
5. Use inline suppressions:
(* NOSONAR - Suppress next line *)
ComplexFunction[...]; (* Not flagged *)
(* Or suppress specific rule: *)
(* sonar.issue.ignore: RuleKey *)6. Report bugs:
If rule is genuinely wrong:
# GitHub Issues: github.com/bceverly/wolfralyze/issues
# Include:
# - Code sample
# - Why it's a false positive
# - Expected behavior
7. Create custom Quality Profile:
Quality Profiles → Create
# Start with "Sonar way"
# Customize for your project
# Deactivate problematic rules
Prevention:
- Start with fewer rules, add gradually
- Review rules before enabling
- Use project-specific profiles for legacy code
Symptoms:
- Duplication detected in unrelated code
- Or: Obvious duplication not detected
- Duplication percentage seems wrong
Causes:
- Threshold too sensitive (or not sensitive enough)
- Tokenization not handling Mathematica patterns correctly
- Comments included in duplication
- Generated code causing false duplications
Solutions:
1. Adjust duplication thresholds:
# More strict (detect smaller duplications)
sonar.cpd.mathematica.minimumTokens=100
sonar.cpd.mathematica.minimumLines=10
# Less strict (fewer false positives)
sonar.cpd.mathematica.minimumTokens=500
sonar.cpd.mathematica.minimumLines=502. Exclude files from duplication detection:
# Exclude tests (often similar)
sonar.cpd.exclusions=**/tests/**
# Exclude generated code
sonar.cpd.exclusions=**/generated/**,**/auto/**3. Review specific duplication blocks:
Project → Overview → Click "Duplications %"
# Or: Measures → Duplications → Duplications
# Review each block to confirm it's real duplication
4. Understand tokenization:
(* These are considered duplicates (tokens match): *)
f[x_] := x^2 + 2*x + 1
g[y_] := y^2 + 2*y + 1
(* Variable names are ignored in tokenization *)
(* Only operators and structure matter *)5. Exclude boilerplate:
(* If you have package boilerplate: *)
BeginPackage[...];
Begin[...];
End[];
EndPackage[];
(* This appears in every file - exclude pattern: *)# Not directly possible to exclude patterns
# But exclude small duplications:
sonar.cpd.mathematica.minimumLines=50Prevention:
- Tune thresholds for your codebase
- Exclude test and generated code
- Refactor genuine duplications
Symptoms:
ERROR: java.lang.OutOfMemoryError: Java heap space
ERROR: Analysis failed
Causes:
- Heap size too small for codebase
- Memory leak in analysis
- Very large files
- Too many issues in memory
Solutions:
1. Increase scanner heap:
# Linux/Mac
export SONAR_SCANNER_OPTS="-Xmx4096m"
sonar-scanner
# Windows
set SONAR_SCANNER_OPTS=-Xmx4096m
sonar-scanner2. Increase SonarQube Compute Engine heap:
# In $SONARQUBE_HOME/conf/sonar.properties
sonar.ce.javaOpts=-Xmx4096m -Xms1024m3. Restart SonarQube after changing heap:
$SONARQUBE_HOME/bin/[platform]/sonar.sh restart4. Analyze in smaller batches:
# Instead of analyzing entire project:
# Split into modules and analyze separately
# Module 1:
sonar-scanner -Dsonar.sources=src/module1 \
-Dsonar.projectKey=myproject-module1
# Module 2:
sonar-scanner -Dsonar.sources=src/module2 \
-Dsonar.projectKey=myproject-module25. Exclude large or generated files:
sonar.exclusions=**/generated/**,**/LargeFile.wl6. Check for memory leaks:
# Monitor memory during scan
# If memory keeps growing, may be leak
top -p $(pgrep -f sonar-scanner)
# Report to plugin maintainer if consistentRecommended heap sizes:
| Codebase Size | Scanner Heap | Compute Engine Heap |
|---|---|---|
| Small (<100 files) | 1GB | 2GB |
| Medium (100-500 files) | 2GB | 4GB |
| Large (500-2000 files) | 4GB | 6GB |
| Very Large (2000+ files) | 8GB | 8GB+ |
Prevention:
- Set adequate heap size from the start
- Monitor memory usage
- Keep files reasonably sized
Symptoms:
ERROR: java.lang.OutOfMemoryError: Metaspace
ERROR: Could not load class org.sonar...
Causes:
- Too many plugins loaded
- Metaspace size too small
- Plugin class loader leak
Solutions:
1. Increase metaspace:
# In $SONARQUBE_HOME/conf/sonar.properties
sonar.ce.javaOpts=-Xmx4096m -Xms1024m -XX:MaxMetaspaceSize=512m
# For scanner:
export SONAR_SCANNER_OPTS="-Xmx2048m -XX:MaxMetaspaceSize=512m"2. Restart SonarQube:
$SONARQUBE_HOME/bin/[platform]/sonar.sh restart3. Remove unnecessary plugins:
# List installed plugins
ls $SONARQUBE_HOME/extensions/plugins/
# Remove unused plugins
rm $SONARQUBE_HOME/extensions/plugins/unused-plugin-*.jar
# Restart4. Check for duplicate plugin JARs:
ls $SONARQUBE_HOME/extensions/plugins/ | sort
# Remove any duplicatesExpected metaspace:
- Default: 256MB (often too small)
- Recommended: 512MB (for multiple plugins)
- Large installation: 1GB
Prevention:
- Set adequate metaspace from start
- Remove unused plugins
- Ensure no duplicate plugin versions
Symptoms:
- Analysis is slow
- Logs show frequent GC:
[GC pause (G1 Evacuation Pause) 1024M->512M, 0.5s] - CPU usage spikes periodically
Causes:
- Heap size barely sufficient
- Too many short-lived objects
- Memory churn
Solutions:
1. Increase heap AND initial size:
# Give GC more room to work
export SONAR_SCANNER_OPTS="-Xmx4096m -Xms2048m"2. Use G1 garbage collector (modern):
export SONAR_SCANNER_OPTS="-Xmx4096m -Xms2048m -XX:+UseG1GC"3. Tune GC (advanced):
export SONAR_SCANNER_OPTS="-Xmx4096m -Xms2048m -XX:+UseG1GC \
-XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=45"4. Monitor GC behavior:
# Add GC logging
export SONAR_SCANNER_OPTS="-Xmx4096m -Xlog:gc*:file=gc.log"
sonar-scanner
# Review gc.log for patternsPrevention:
- Set initial heap size (-Xms) to at least 50% of max heap (-Xmx)
- Use modern GC (G1 for Java 11+)
- Ensure adequate total memory (heap + metaspace + OS)
Symptoms:
ERROR: Error during SonarQube Scanner execution
ERROR: Not authorized. Please check the user token or the credentials
ERROR: 401 Unauthorized
Causes:
- Missing or incorrect token
- Token expired or revoked
- Incorrect username/password
- Wrong SonarQube URL
- Network/proxy issues
Solutions:
1. Generate new token:
1. Login to SonarQube
2. User menu → My Account → Security
3. Generate Token:
- Name: "CI Scanner"
- Type: User Token
- Expiration: 90 days (or never)
4. Copy token immediately (shown only once!)
2. Use token in scanner:
# Method 1: Command line
sonar-scanner -Dsonar.login=YOUR_TOKEN_HERE
# Method 2: sonar-project.properties
sonar.login=YOUR_TOKEN_HERE
# Method 3: Environment variable (more secure)
export SONAR_TOKEN=YOUR_TOKEN_HERE
sonar-scanner3. If using username/password (legacy):
sonar-scanner \
-Dsonar.login=admin \
-Dsonar.password=admin123
# Not recommended - use tokens instead!4. Verify SonarQube URL:
# Test connection
curl http://localhost:9000/api/system/status
# If using HTTPS:
curl https://sonarqube.company.com/api/system/status
# Update in configuration:
sonar.host.url=http://localhost:90005. Check proxy settings:
# If behind proxy:
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080
export NO_PROXY=localhost,127.0.0.1
sonar-scanner6. Test token validity:
# Using curl
curl -u YOUR_TOKEN: http://localhost:9000/api/authentication/validate
# Should return: {"valid":true}
# If false, token is invalid or expiredPrevention:
- Use tokens, not passwords
- Set long expiration (1 year) or no expiration
- Store tokens securely (environment variables, secrets management)
- Document token renewal process
Symptoms:
ERROR: You're not authorized to run analysis
ERROR: 403 Forbidden
ERROR: Insufficient privileges
Causes:
- User doesn't have "Execute Analysis" permission
- Project permissions not set correctly
- Using wrong user account
- Global permission issue
Solutions:
1. Grant analysis permission (global):
As administrator:
1. Administration → Security → Global Permissions
2. Find "Execute Analysis" permission
3. Grant to appropriate group (e.g., "sonar-users")
4. Or grant directly to user
2. Grant project-specific permission:
As project administrator:
1. Project → Administration → Permissions
2. Find "Execute Analysis" permission
3. Grant to user or group
3. Check user is in correct group:
Administration → Security → Users
# Find your user
# Check groups membership
# Add to "sonar-users" or analysis group if needed
4. Use admin token temporarily (to debug):
# Generate token from admin account
# Run scan with admin token
# If works: Permission issue confirmed
# If fails: Different issue
5. Verify authentication:
# Check who you're authenticated as
curl -u YOUR_TOKEN: http://localhost:9000/api/authentication/validateRequired permissions for analysis:
- Execute Analysis (minimum)
- Browse (to see project)
Prevention:
- Set up service account for CI/CD with correct permissions
- Use group-based permissions (not individual users)
- Document permission requirements
Symptoms:
- Files exist with
.wl,.m, or.wlsextensions - Scanner runs successfully
- But specific files not analyzed (missing from file list)
Causes:
- Files excluded by exclusion patterns
- Files in directories not specified in
sonar.sources - Files unreadable (permissions)
- Symbolic links not followed
- Files ignored by SCM (.gitignore)
Solutions:
1. Check exclusion patterns:
# Review sonar-project.properties
sonar.exclusions=**/tests/** # Are your files in tests/?
# Temporarily disable exclusions to debug:
# sonar.exclusions=2. Verify file is in source path:
# If file is in: src/subdir/file.wl
# Ensure sonar.sources includes it:
sonar.sources=src
# Not:
sonar.sources=src/otherdir # Wrong!3. Check file permissions:
ls -la path/to/file.wl
# Should be readable: -rw-r--r--
# If not:
chmod 644 path/to/file.wl4. Follow symbolic links:
# SonarQube doesn't follow symlinks by default
# Options:
# A. Copy files instead of symlinking
# B. Use real path in sonar.sources5. Check .gitignore:
# If file is gitignored, SonarQube may skip it
# Check: .gitignore, .sonarignore
# Override:
# Remove from .gitignore or add to sonar.sources explicitly6. Use verbose mode to debug:
sonar-scanner -X 2>&1 | grep "file.wl"
# Should show why file was included/excluded7. Verify file encoding:
file -I path/to/file.wl
# Should be: text/plain; charset=utf-8
# Binary files are skippedPrevention:
- Keep source structure simple
- Avoid symlinks
- Use inclusive sonar.sources patterns
Symptoms:
-
.mx(compiled) files being analyzed - Data files (
.json,.csv) treated as code - Analysis errors on binary files
Causes:
- File extensions overlap
- Missing exclusion patterns
- File type misdetection
Solutions:
1. Exclude binary and data files:
sonar.exclusions=**/*.mx,**/*.json,**/*.csv,**/*.dat2. Be explicit about source files:
# Instead of analyzing entire directory:
sonar.sources=.
# Be specific:
sonar.sources=src
sonar.inclusions=**/*.wl,**/*.m,**/*.wls3. Separate data from code:
project/
src/ ← Code (analyze this)
data/ ← Data (exclude this)
build/ ← Generated (exclude this)
sonar.sources=src
sonar.exclusions=data/**,build/**4. Check file extensions:
# Ensure only source extensions:
sonar.mathematica.file.suffixes=.m,.wl,.wls
# Not: .mx, .dat, etc.Prevention:
- Keep code and data separate
- Explicit inclusion patterns
- Document exclusions in configuration
Symptoms:
- Rule is activated in Quality Profile
- Code clearly violates rule
- But no issue reported
Causes:
- Rule pattern doesn't match your code style
- Rule has bugs or limitations
- Code context prevents detection
- Rule parameters need adjustment
Solutions:
1. Verify rule is active:
Quality Profiles → Your Profile → Search for rule
# Status should be "Active"
# If inactive: Click "Activate"
2. Review rule description and examples:
Rules → Search for rule → Click rule name
# Read "Description" tab
# Check "Noncompliant Code Example"
# Compare with your code
3. Test with exact example from docs:
(* Copy noncompliant example from rule docs *)
(* Create test file: test-rule.wl *)
(* Analyze: sonar-scanner -Dsonar.sources=test-rule.wl *)
(* Check if issue is reported *)4. Check rule parameters:
Quality Profiles → Your Profile → Search rule → Parameters tab
# Example: Complexity threshold
# May need adjustment for your code
5. Report bug if rule is wrong:
GitHub Issues: github.com/bceverly/wolfralyze/issues
# Title: "Rule XYZ not detecting ..."
# Include:
# - Code sample
# - Expected behavior
# - Actual behavior
# - Plugin version
6. Check logs for rule execution:
tail -f $SONARQUBE_HOME/logs/ce.log | grep -i "rule"
# Verify rule is running7. Verify project language:
Project → Administration → General Settings
# Ensure language is "Mathematica"
Prevention:
- Test new rules with known examples
- Report bugs to maintainer
- Use multiple complementary rules
Symptoms:
- Click on issue
- "..." menu doesn't show "Mark as False Positive"
- Or: Option is grayed out
Causes:
- Insufficient permissions
- Issue already resolved
- Quality Gate locked issue status
- Browser extension interfering
Solutions:
1. Check permissions:
Project → Administration → Permissions
# User needs: "Administer Issues" or "Browse" + "Issue" permissions
2. Verify issue is "Open":
# Can only change status if issue is:
# - Open (can change)
# - Reopened (can change)
# - Closed (cannot change - reopen first)
# - Resolved (cannot change - reopen first)
3. Use issue workflow:
Issue → "..." menu → Change Status
# Options:
# - Confirm (mark as legitimate issue)
# - Resolve as Fixed (code was fixed)
# - Resolve as False Positive
# - Resolve as Won't Fix
4. Try different browser:
# Some browser extensions interfere
# Try:
# - Incognito/private mode
# - Different browser
# - Disable ad blockers
5. Check Quality Gate:
# Some organizations lock issues via Quality Gate
# Contact SonarQube admin
Prevention:
- Ensure users have correct permissions
- Document issue workflow for team
Symptoms:
- SonarLint plugin installed
- Can't connect to SonarQube server
- Error: "Unable to connect" or timeout
Causes:
- Wrong server URL
- Network/firewall blocking connection
- Certificate issues (HTTPS)
- Token authentication not configured
- SonarQube server not running
Solutions:
1. Verify SonarQube URL:
# Test in browser first
http://localhost:9000
# Or
https://sonarqube.company.com
# Should see SonarQube login page
2. Configure SonarLint connection:
# IntelliJ IDEA:
Preferences → Tools → SonarLint → Settings
# Add connection:
# - Server URL: http://localhost:9000
# - Authentication: Token
# - Generate token in SonarQube: User → My Account → Security
# - Paste token in SonarLint
3. Check network connectivity:
# From machine running IDE:
curl http://localhost:9000/api/system/status
# Should return JSON with status: "UP"
# If fails: Network/firewall issue4. Handle HTTPS certificate issues:
# If using self-signed certificate:
# Option A: Add certificate to Java trust store
keytool -import -trustcacerts -file sonarqube.crt \
-alias sonarqube -keystore $JAVA_HOME/lib/security/cacerts
# Option B: Disable certificate validation (not recommended)
# In SonarLint settings: Check "Disable certificate validation"
5. Check proxy settings:
# If behind corporate proxy:
IDE → Preferences → Appearance & Behavior → System Settings → HTTP Proxy
# Configure proxy settings
# SonarLint uses IDE proxy settings
6. Update SonarLint version:
# Ensure SonarLint 7.0+ for Connected Mode
Preferences → Plugins → Installed → SonarLint → Check for updates
7. Check SonarQube server status:
# Verify server is running
curl http://localhost:9000/api/system/status
# Or check logs:
tail -f $SONARQUBE_HOME/logs/sonar.logPrevention:
- Document connection setup for team
- Use tokens, not passwords
- Test connection before developing
Symptoms:
- SonarLint connected to SonarQube
- Issues appear in IDE
- But no "Quick Fix" button
Causes:
- SonarLint version too old (<7.0)
- Plugin doesn't support Quick Fixes for that rule
- Connected Mode not enabled
- IDE plugin not updated
Solutions:
1. Update SonarLint:
Preferences → Plugins → Marketplace
# Search "SonarLint"
# Update to 7.0+
# Restart IDE
2. Enable Connected Mode:
# IntelliJ IDEA:
Preferences → Tools → SonarLint → Settings
# Ensure connection is active
# Bind project to SonarQube project
3. Check which rules support Quick Fixes:
# In SonarQube:
Rules → Filter: Language = Mathematica
# Look for rules with "Quick Fix Available" tag
# Currently: 53 rules support Quick Fixes
4. Verify project binding:
# Right-click project → SonarLint → Bind to SonarQube
# Select your server
# Choose project
# Click "Bind"
5. Update project analysis:
# In SonarLint tool window:
# Click "Update Binding" or "Sync with SonarQube"
6. Check IDE compatibility:
# Quick Fixes supported in:
# - IntelliJ IDEA 2020.3+
# - Visual Studio Code (with SonarLint extension)
# - Eclipse 2021+
# - Visual Studio 2019+
Prevention:
- Keep SonarLint updated
- Enable auto-updates for plugins
- Use Connected Mode from start
Symptoms:
- Quality Gate status: "Failed"
- Build fails in CI/CD
- Not clear which condition failed
Causes:
- Multiple conditions, unclear which failed
- Thresholds too strict
- New issues introduced
- Coverage/duplication thresholds not met
Solutions:
1. Check Quality Gate details in UI:
Project → Overview → Quality Gate section
# Shows failed conditions in red:
# Example: "Bugs: 5 (threshold: 0)"
2. View specific failed conditions:
Project → Overview → Click "Failed" status
# Shows detailed breakdown:
# - Condition name
# - Actual value
# - Threshold value
# - Difference
3. Check scanner logs:
# If running in CI/CD:
# Look for quality gate check output:
sonar-scanner
# ...
# QUALITY GATE STATUS: FAILED
# Conditions:
# - Bugs: 5 > 0 (FAILED)
# - Vulnerabilities: 0 ≤ 0 (PASSED)4. Adjust Quality Gate conditions:
Quality Gates → Your Gate → Conditions
# Review each condition:
# - On Overall Code / New Code
# - Metric (Bugs, Vulnerabilities, etc.)
# - Operator (≤, ≥, =)
# - Threshold value
# Adjust if too strict:
# Example: Bugs ≤ 0 → Bugs ≤ 5 (allow 5 bugs)
5. Focus on "New Code" conditions:
# Best practice: Fail only on new issues
# Not: "Overall Code" → "Bugs ≤ 0"
# But: "New Code" → "New Bugs ≤ 0"
# This allows fixing legacy issues gradually
6. Use "Leak Period" wisely:
Project → Administration → General Settings → New Code
# Options:
# - Previous version (recommended)
# - Number of days (e.g., 30 days)
# - Specific analysis
# - Reference branch
Default Quality Gate conditions:
-
On New Code:
- Bugs ≤ 0
- Vulnerabilities ≤ 0
- Security Hotspots Reviewed = 100%
- Code Coverage ≥ 80% (if coverage enabled)
- Duplications ≤ 3%
Prevention:
- Set realistic thresholds
- Focus on new code quality
- Review Quality Gate regularly
Symptoms:
- Code has obvious quality issues
- But Quality Gate shows "Passed"
- No failures in CI/CD
Causes:
- Quality Gate has no conditions
- Conditions too lenient
- Wrong Quality Gate assigned to project
- Conditions apply to wrong metric period
Solutions:
1. Check Quality Gate has conditions:
Quality Gates → Your Gate
# Should have multiple conditions
# If zero conditions: All projects pass!
2. Verify correct Quality Gate assigned:
Project → Administration → Quality Gate
# Should be: "Sonar way" or your custom gate
# Not: "None" or empty
3. Review condition thresholds:
Quality Gates → Your Gate → Conditions
# Example too-lenient conditions:
# - Bugs ≤ 1000 (way too high!)
# - Code Smells ≤ 10000 (way too high!)
# Recommended:
# - Bugs ≤ 0 (on new code)
# - Vulnerabilities ≤ 0 (on new code)
# - Coverage ≥ 80% (on new code)
4. Check "On New Code" vs "On Overall Code":
# If conditions are on "Overall Code":
# Legacy issues may be grandfathered in
# Change to "On New Code" to focus on new issues
5. Add missing conditions:
Quality Gates → Your Gate → Add Condition
# Recommended conditions:
# - Security Rating: A (on Overall Code)
# - Reliability Rating: A (on Overall Code)
# - Maintainability Rating: A (on New Code)
# - Coverage: ≥ 80% (on New Code)
# - Duplications: ≤ 3% (on New Code)
6. Set as default for all projects:
Quality Gates → Your Gate → Set as Default
# Ensures all new projects use strict gate
Prevention:
- Start with "Sonar way" Quality Gate (recommended)
- Review and tighten conditions quarterly
- Monitor Quality Gate pass/fail rates
This troubleshooting guide covers the most common issues when using the SonarQube Mathematica Plugin. For issues not covered here:
-
Check documentation:
- README.md - General usage
- FAQ.md - Frequently asked questions
- ARCHITECTURE.md - Technical details
-
Search existing issues:
- GitHub Issues: github.com/bceverly/wolfralyze/issues
-
Ask the community:
- GitHub Discussions: github.com/bceverly/wolfralyze/discussions
- SonarQube Community: community.sonarsource.com (tag: mathematica)
-
Report bugs:
- GitHub Issues with:
- Plugin version
- SonarQube version
- Steps to reproduce
- Expected vs actual behavior
- Log excerpts (if applicable)
- GitHub Issues with:
-
Contribute fixes:
- Pull requests welcome!
- See CONTRIBUTING.md (coming soon)
Emergency contacts:
- Security issues: Email maintainer directly (see README)
- Critical bugs: GitHub Issues with "critical" label
Keep plugin updated:
# Check for updates:
# Administration → Marketplace → Updates Available
# Or: GitHub ReleasesVersion compatibility:
- Plugin 1.0.0+ requires SonarQube 9.9+
- SonarLint 7.0+ required for Quick Fixes
- Java 11+ required for all components
Thank you for using the SonarQube Mathematica Plugin!