Repository navigation
FAQ
- General Questions
- Installation Questions
- Configuration Questions
- Rule Questions
- File Format Questions
- Performance Questions
- Security Questions
- Integration Questions
- Custom Rules Questions
- Cost and Licensing Questions
The SonarQube Mathematica Plugin is a comprehensive static analysis tool for Wolfram Mathematica code. It provides:
- 529 code quality rules covering bugs, vulnerabilities, code smells, and security hotspots
- Code duplication detection using SonarQube's CPD engine
- Complexity metrics (cyclomatic and cognitive complexity)
- Quick Fixes for common issues via SonarLint integration
- Symbol table analysis for cross-file variable tracking
- Performance analysis optimized for large codebases
The plugin integrates seamlessly with SonarQube's web interface and provides real-time feedback in your IDE through SonarLint.
The plugin complements Wolfram's tools by providing:
Unique Features:
- Continuous integration - Automated scanning in your CI/CD pipeline
- Historical tracking - Track code quality metrics over time
- Team collaboration - Centralized code quality dashboard
- Security scanning - OWASP Top 10 vulnerability detection
- Code duplication detection - Find copy-paste code across projects
- IDE integration - Real-time feedback while coding via SonarLint
Wolfram Workbench provides syntax checking and debugging, while this plugin focuses on code quality, security, and maintainability analysis. They work together - use Workbench for development and this plugin for continuous quality monitoring.
Minimum version: SonarQube 9.9 or higher
Recommended versions:
- SonarQube 10.x (LTS) - Best compatibility and performance
- SonarQube Community Edition - Fully supported (free)
- SonarQube Developer Edition - All features work
- SonarQube Enterprise Edition - All features work
The plugin is tested against SonarQube 10.7 and later versions.
The plugin analyzes:
- Wolfram Language (.wl files)
- Mathematica packages (.m files)
- Wolfram Language Scripts (.wls files)
- Notebook cells (.nb files) - Coming soon
Currently, the plugin focuses on pure Wolfram Language code. Support for notebooks is planned for a future release.
No, this is a community-developed plugin not affiliated with Wolfram Research. It is open-source (AGPL-3.0 license) and maintained by the community. However, it follows Wolfram Language best practices and coding standards.
For Individual Developers:
- Catch bugs before they reach production
- Learn Wolfram Language best practices
- Get automated code fixes via Quick Fixes
- Improve code readability and maintainability
For Teams:
- Enforce consistent coding standards
- Track technical debt over time
- Security vulnerability scanning
- Code review automation
- Identify code duplication
For Organizations:
- Compliance reporting (OWASP, CWE)
- Quality gates for release management
- Historical quality metrics
- CI/CD integration
Option 1: Marketplace (Recommended)
- Login to SonarQube as administrator
- Go to Administration → Marketplace → All
- Search for "Mathematica"
- Click Install
- Restart SonarQube
Option 2: Manual Installation
- Download the latest
.jarfrom GitHub Releases - Copy to
$SONARQUBE_HOME/extensions/plugins/ - Remove any old versions (important!)
- Restart SonarQube
- Verify in Administration → Marketplace → Installed
Option 3: Build from Source
git clone https://github.com/bceverly/wolfralyze.git
cd wolfralyze
./gradlew build
cp build/libs/wolfralyze-*.jar $SONARQUBE_HOME/extensions/plugins/
# Restart SonarQubeCommon causes:
-
Old plugin version still present
- Solution: Delete ALL
wolfralyze-*.jarfiles fromextensions/plugins/ - Then copy only the latest version
- Restart SonarQube
- Solution: Delete ALL
-
SonarQube not restarted
- Solution: Always restart SonarQube after plugin installation
- Check logs:
tail -f $SONARQUBE_HOME/logs/sonar.log
-
Plugin file permissions
- Solution: Ensure the
.jarfile is readable by SonarQube user chmod 644 wolfralyze-*.jar
- Solution: Ensure the
-
Java version mismatch
- Solution: Plugin requires Java 11+
- Check:
java -version
-
Plugin deployment location
- Solution: Verify correct directory:
$SONARQUBE_HOME/extensions/plugins/ - NOT
extensions/downloads/(wrong location)
- Solution: Verify correct directory:
No, SonarCloud does not support custom plugins. You must use a self-hosted SonarQube instance (Community, Developer, or Enterprise Edition).
Safe upgrade process:
-
Stop SonarQube
$SONARQUBE_HOME/bin/[platform]/sonar.sh stop -
Remove old version
rm $SONARQUBE_HOME/extensions/plugins/wolfralyze-*.jar
-
Install new version
cp wolfralyze-NEW-VERSION.jar $SONARQUBE_HOME/extensions/plugins/ -
Start SonarQube
$SONARQUBE_HOME/bin/[platform]/sonar.sh start -
Verify installation
- Check Administration → Marketplace → Installed
- Look for correct version number
Important: Always remove old versions first to avoid duplicate plugin errors.
Create a sonar-project.properties file in your project root:
# Project identification
sonar.projectKey=my-mathematica-project
sonar.projectName=My Mathematica Project
sonar.projectVersion=1.0
# Source code location
sonar.sources=src
# File extensions to analyze
sonar.mathematica.file.suffixes=.m,.wl,.wls
# Encoding
sonar.sourceEncoding=UTF-8
# Exclude generated or third-party code
sonar.exclusions=**/external/**,**/generated/**
# SonarQube server URL
sonar.host.url=http://localhost:9000Then run the scanner:
sonar-scannerDefault file extensions:
-
.m- Mathematica package files -
.wl- Wolfram Language source files -
.wls- Wolfram Language script files
Configuration:
# Change file extensions (optional)
sonar.mathematica.file.suffixes=.m,.wl,.wls,.mtNote: Notebook files (.nb) are not yet supported but planned for future releases.
Exclude by pattern:
# Exclude specific directories
sonar.exclusions=**/tests/**,**/examples/**,**/external/**
# Exclude specific files
sonar.exclusions=**/generated/*.wl,**/temp/*.m
# Multiple patterns (comma-separated)
sonar.exclusions=**/tests/**,**/docs/**,**/build/**Exclude from duplication detection only:
sonar.cpd.exclusions=**/generated/**Exclude from coverage:
sonar.coverage.exclusions=**/tests/**Yes, through the SonarQube web interface:
- Go to Quality Profiles
- Select your Mathematica profile (or create a custom one)
- Search for the rule you want to modify
- Click Activate/Deactivate or Change Severity
Available severities:
- Blocker - Must be fixed immediately
- Critical - Should be fixed quickly
- Major - Should be fixed (default for most bugs)
- Minor - Nice to fix
- Info - Informational only
You can also configure rules via JSON/XML files for automated deployment.
- Go to Quality Profiles
- Click Create
- Name: "My Mathematica Profile"
- Language: Mathematica
- Parent: "Sonar way" (optional, inherits rules)
- Click Create
Then customize:
- Activate/Deactivate specific rules
- Change severity levels
- Set rule parameters (if available)
- Export profile as XML for version control
Set as default:
- Click Set as Default to apply to all new projects
- Or set per-project in Project Settings → Quality Profiles
Memory settings (in sonar.properties):
# Increase heap size for large codebases
sonar.ce.javaOpts=-Xmx4096m -Xms1024m
# Increase metaspace for many rules
sonar.ce.javaOpts=-XX:MaxMetaspaceSize=512mScanner settings (in sonar-project.properties):
# Skip unchanged files (default: enabled)
sonar.scm.disabled=false
# Duplication detection (adjust for performance)
sonar.cpd.mathematica.minimumTokens=250
sonar.cpd.mathematica.minimumLines=25Large codebase optimizations:
- Use incremental analysis (analyze only changed files)
- Exclude test files and examples if not needed
- Consider splitting very large monorepos into multiple projects
Total: 529 rules (as of version 1.0.0)
Breakdown by category:
- 76 Code Smell rules (maintainability)
- 45 Bug rules (reliability)
- 21 Vulnerability rules (security)
- 7 Security Hotspot rules (security review areas)
- Plus: Complexity metrics, duplication detection, and symbol table analysis
This exceeds the rule count of Scala (450 rules) and approaches Java's coverage (733 rules), placing it at Tier 1 language support level.
Yes! Three ways:
1. Via Quality Profile (Recommended)
- Go to Quality Profiles → Your Profile → Rules
- Search for the rule
- Click Deactivate or change severity
- Changes apply to all projects using this profile
2. Via Project Settings
- Project → Administration → Quality Profiles
- Select a different profile or create project-specific one
3. Via Inline Comments (File-level)
(* NOSONAR - Disable all rules for next line *)
DangerousFunction[];
(* sonar.issue.ignore.multicriteria - More granular control *)Disable specific rule by key:
# In sonar-project.properties
sonar.issue.ignore.multicriteria=e1
sonar.issue.ignore.multicriteria.e1.ruleKey=mathematica:HardcodedCredentials
sonar.issue.ignore.multicriteria.e1.resourceKey=**/config/*.wlBug Detection (Reliability):
- Division by zero
- Null pointer dereferences
- Infinite recursion
- Array index out of bounds
- Type mismatches
- Uninitialized variables
- Unreachable code
Security Vulnerabilities:
- SQL injection risks
- Command injection
- Path traversal
- Hardcoded credentials
- Weak cryptography
- XML External Entity (XXE) attacks
- Insecure deserialization
Security Hotspots (Review Areas):
- File upload validation
- External API usage
- Cryptographic key generation
- Network connections
- Authentication mechanisms
Code Smells (Maintainability):
- Complex functions (high cyclomatic complexity)
- Long functions
- Duplicated code
- Magic numbers
- Nested conditionals
- Poor naming conventions
- Commented-out code
Mathematica-Specific Issues:
- Inefficient pattern matching
- Improper use of Hold attributes
- Performance issues (unpacked arrays, etc.)
- Symbol shadowing
- Package dependency cycles
Yes! The plugin includes 20+ rules for Mathematica-specific idioms:
Pattern Matching:
- Inefficient pattern usage
- Overly complex patterns
- Pattern optimization opportunities
Evaluation Control:
- Improper use of Hold/HoldAll/HoldFirst
- Missing attribute declarations
- Evaluation leaks
Performance:
- Unpacked array operations
- Compilation opportunities
- Listable function usage
Symbols and Scoping:
- Symbol shadowing (e.g., redefining
List) - Improper use of Module/Block/With
- Global symbol pollution
Example detected issues:
(* BAD: Inefficient pattern *)
f[x_] := If[x > 0, x, -x] (* Use Abs instead *)
(* BAD: Missing Hold attribute *)
SetAttributes[myFunc, {}] (* Should be HoldAll *)
(* BAD: Symbol shadowing *)
List = 5; (* Shadowing built-in symbol! *)Yes! Two ways:
1. In SonarQube UI:
- Go to Rules → Search for rule name
- Click on rule → See Description tab
- "Noncompliant Code Example" shows bad code
- "Compliant Solution" shows fixed code
2. In the documentation:
- Check
docs/rules/directory in the plugin repository - Each rule has markdown documentation with examples
Example rule documentation:
## Rule: HardcodedCredentials
**Severity:** Critical
**Type:** Vulnerability
### Noncompliant Code:
password = "admin123" (* Hardcoded! *)
### Compliant Solution:
password = Environment["APP_PASSWORD"]Yes! 53 rules support automated Quick Fixes via SonarLint:
Quick Fix examples:
- Replace
If[x > 0, x, -x]→Abs[x] - Remove commented-out code
- Simplify Boolean expressions
- Fix incorrect pattern syntax
- Remove unused variables
How to use:
- Install SonarLint in your IDE (IntelliJ, VS Code, Eclipse)
- Connect to your SonarQube server (Connected Mode)
- Open a Mathematica file with issues
- Click "Quick Fix" button in the issue tooltip
- Code is automatically corrected!
Supported IDEs:
- IntelliJ IDEA (with SonarLint plugin)
- Visual Studio Code (with SonarLint extension)
- Eclipse (with SonarLint plugin)
- Visual Studio (with SonarLint extension)
The plugin uses SonarQube's CPD (Copy-Paste Detector) engine with Mathematica-specific tokenization:
How it works:
- Tokenizes Mathematica code (function names, operators, literals)
- Normalizes tokens (ignores whitespace, comments, variable names)
- Compares token sequences across all files
- Reports duplicated blocks above threshold
Default thresholds:
- Minimum tokens: 250 tokens
- Minimum lines: 25 lines
Configuration:
# Adjust sensitivity
sonar.cpd.mathematica.minimumTokens=100 # More sensitive
sonar.cpd.mathematica.minimumLines=10
# Or less sensitive (for large codebases)
sonar.cpd.mathematica.minimumTokens=500
sonar.cpd.mathematica.minimumLines=50View duplications:
- Overview → Click Duplications %
- Measures → Duplications → Density
Not yet, but planned. Current status:
Supported formats:
-
.wl- Wolfram Language source files ✅ -
.m- Package files ✅ -
.wls- Script files ✅
Not yet supported:
-
.nb- Notebook files (coming in future release) -
.mx- Compiled files (not planned) -
.cdf- CDF documents (not planned)
Workaround for notebooks:
- Export notebook cells to
.wlfiles:Export["code.wl", NotebookRead[...]] - Analyze the exported code
Roadmap:
- Version 2.0 will support extracting and analyzing code cells from
.nbfiles
Yes! Package files are fully supported. The plugin correctly handles:
Package structure:
-
BeginPackage["MyPackage"]` declarations - Context management
- Public/private symbol detection
- Package dependencies
Example package:
BeginPackage["MyPackage`"]
(* Public symbols *)
PublicFunction::usage = "Does something";
Begin["`Private`"]
(* Private implementation *)
PublicFunction[x_] := privateHelper[x]
privateHelper[x_] := x^2
End[]
EndPackage[]Analysis features:
- Detects unused exports
- Finds package dependency cycles
- Checks public symbol documentation
- Cross-file symbol resolution
Fully supported! Script files are analyzed just like regular .wl files.
Script features:
- Shebang line is recognized and ignored:
#!/usr/bin/env wolframscript - Command-line argument handling is understood
- Script-specific patterns are detected
Example script:
#!/usr/bin/env wolframscript
(* SonarQube analyzes this file *)
result = Total[Range[100]]
Print[result]Best practices detected:
- Proper error handling
- Command-line argument validation
- Exit code usage
The plugin provides cross-file analysis via the Symbol Table:
Features:
-
Package dependency tracking
- Detects circular dependencies
- Finds unused package imports
-
Cross-file symbol resolution
- Tracks variables across files
- Detects undefined symbols in other packages
-
Unused export detection
- Finds public functions that are never called
- Identifies dead code across packages
-
Architecture violations
- Enforces layering rules
- Detects dependency rule violations
Example:
(* File: Math.wl *)
BeginPackage["Math`"]
Unused::usage = "Never called" (* ← Detected! *)
End[]
(* File: Main.wl *)
<< Math`
(* Unused function not called anywhere *)The plugin will report "Unused public symbol: Math`Unused".
Yes, but you probably shouldn't. Best practice:
Exclude generated code:
sonar.exclusions=**/generated/**,**/auto/**Reasons to exclude:
- Generated code often violates style rules
- Can't be fixed manually (will be regenerated)
- Clutters quality reports
- Slows down analysis
When to include:
- If you want to verify generator quality
- If generated code is committed and maintained
- For security scanning (vulnerabilities matter even in generated code)
Compromise:
# Exclude from duplication and code smells
sonar.cpd.exclusions=**/generated/**
sonar.issue.ignore.multicriteria=e1
sonar.issue.ignore.multicriteria.e1.ruleKey=mathematica:*
sonar.issue.ignore.multicriteria.e1.resourceKey=**/generated/**
# But keep security scanning activeVery fast! Performance characteristics:
Small projects (< 100 files):
- Analysis time: 1-3 minutes
- Dominated by SonarQube overhead
Medium projects (100-500 files):
- Analysis time: 3-8 minutes
- Plugin contributes ~50% of time
Large projects (500-1000 files):
- Analysis time: 8-15 minutes
- Optimized single-pass O(n) analysis
Performance breakdown (654 files, ~8.5 minutes):
- Plugin rules: 79 seconds (15%)
- Metrics: 26 seconds (5%)
- Duplication: 153 seconds (30%)
- SonarQube core: 250+ seconds (50%)
Key optimization: 99.75% improvement from O(400n) → O(n) single-pass analysis using UnifiedRuleVisitor pattern.
Common causes:
1. Large individual files
- Symptom: One file takes several minutes
- Cause: Symbol table analysis is O(n²) for complex files
- Solution: Split large files into smaller modules
2. Many small files
- Symptom: Scan takes long but individual files are fast
- Cause: SonarQube startup overhead per file
- Solution: This is normal, no action needed
3. SCM (Git) blame
- Symptom: "SCM Publisher" step is slow
- Cause: Git blame for every line (not plugin-related)
-
Solution:
sonar.scm.disabled=true(loses author info)
4. Duplication detection
- Symptom: CPD step is slow
- Cause: Comparing all files for duplications
- Solution: Increase thresholds or exclude files
5. Network latency
- Symptom: "Publishing issues" is slow
- Cause: Slow connection to SonarQube server
- Solution: Run scanner on same machine or improve network
6. Memory pressure
- Symptom: GC pauses, OutOfMemoryError
-
Solution: Increase heap size:
sonar.ce.javaOpts=-Xmx4096m -Xms1024m
Yes, automatically! SonarQube supports incremental analysis:
How it works:
- First scan: Analyzes all files
- Subsequent scans: Only analyzes changed files
- Unchanged files are skipped automatically
Requirements:
- SonarQube 9.9+ (Developer/Enterprise Edition)
- SCM integration enabled (Git, SVN, etc.)
-
sonar.scm.disabled=false(default)
Performance improvement:
- First scan: 1000 files = 120 seconds
- Incremental: 50 changed files = 6 seconds (20x faster!)
Configuration:
# Enable incremental analysis (default)
sonar.scm.disabled=false
# For pull requests (Developer Edition+)
sonar.pullrequest.key=PR-123
sonar.pullrequest.branch=feature/my-feature
sonar.pullrequest.base=mainYes! Tested on codebases up to 12,000+ files:
Largest tested:
- Files: 12,000+ Mathematica files
- Lines of code: 500,000+ LOC
- Analysis time: ~2 hours (initial scan)
- Incremental scans: 5-10 minutes
Optimizations for large codebases:
- Use incremental analysis (Developer/Enterprise Edition)
-
Exclude unnecessary files:
sonar.exclusions=**/tests/**,**/examples/** -
Increase memory:
sonar.ce.javaOpts=-Xmx8192m -Xms2048m - Split monorepos into multiple SonarQube projects
- Run analysis during off-hours (initial scan)
Architecture: The plugin uses O(n) single-pass analysis, so it scales linearly with codebase size.
OWASP Top 10 2021 coverage (9 of 10 categories):
A01: Broken Access Control
- Hardcoded credentials
- Missing authentication checks
A02: Cryptographic Failures
- Weak cryptography algorithms
- Hardcoded encryption keys
- Insecure random number generation
A03: Injection
- SQL injection via SQLExecute
- Command injection via RunProcess
- Path traversal via File operations
- XML External Entity (XXE) attacks
A04: Insecure Design
- Missing input validation
- Insufficient error handling
A05: Security Misconfiguration
- Overly permissive file permissions
- Debug code in production
A06: Vulnerable and Outdated Components
- Use of deprecated functions
- Insecure API usage
A07: Identification and Authentication Failures
- Weak password validation
- Session management issues
A08: Software and Data Integrity Failures
- Insecure deserialization
- Missing integrity checks
A09: Security Logging and Monitoring Failures
- Missing audit logs
- Error message information disclosure
A10: Server-Side Request Forgery (SSRF)
- (Not currently covered - planned for future release)
Yes! Multiple detection methods:
Pattern-based detection:
(* DETECTED: Hardcoded password *)
password = "admin123"
dbPassword = "secret"
(* DETECTED: API keys *)
apiKey = "sk_live_1234567890abcdef"
accessToken = "ghp_xxxxxxxxxxxxxxxxxxxx"
(* DETECTED: Connection strings *)
conn = SQLConnection["jdbc:mysql://localhost/db?user=admin&password=secret"]Safe alternatives:
(* GOOD: Environment variables *)
password = Environment["DB_PASSWORD"]
(* GOOD: Configuration files (outside repo) *)
config = Import["config.json"];
password = config["database"]["password"]
(* GOOD: Secrets management *)
password = CloudGet["mysecret/password"]Rule: mathematica:HardcodedCredentials (Severity: Critical)
Yes! The plugin supports:
OWASP Top 10 compliance:
- All vulnerability rules are tagged with OWASP categories
- Security Hotspots highlight review areas
- Generate compliance reports via SonarQube
CWE (Common Weakness Enumeration) mapping:
- Each vulnerability maps to CWE IDs
- Useful for CVE reporting
- Required by some compliance frameworks
PCI-DSS:
- Detects hardcoded credentials (requirement 6.5.3)
- SQL injection prevention (requirement 6.5.1)
- Proper error handling (requirement 6.5.5)
Generate compliance reports:
- Go to project → More → Security Reports
- Select OWASP Top 10 or CWE Top 25
- Export as PDF or CSV
Quality Gates for compliance:
# Fail builds if security issues found
sonar.qualitygate.wait=true
sonar.qualitygate.timeout=300Then configure Quality Gate:
- Vulnerabilities: 0 allowed (fail if any found)
- Security Hotspots: 100% reviewed
- Security Rating: A (no vulnerabilities)
No, they're different:
Vulnerabilities:
- Definite security issues that should be fixed
- Example: SQL injection, hardcoded credentials
- Severity: Blocker/Critical/Major
- Action: Fix immediately
- Location: Issues tab → Filter: Type=Vulnerability
Security Hotspots:
- Code that requires security review (may or may not be vulnerable)
- Example: File upload functionality, external API calls
- Severity: (Not rated - requires review)
- Action: Review and mark as "Safe" or "Fixed"
- Location: Security Hotspots tab (separate tab)
Example:
(* VULNERABILITY: SQL Injection *)
SQLExecute[conn, "SELECT * FROM users WHERE id = " <> id]
(* ↑ Definite issue - concatenating user input *)
(* SECURITY HOTSPOT: File Upload *)
Import[uploadedFile]
(* ↑ Requires review - may be safe if properly validated *)Workflow:
- Fix all Vulnerabilities immediately
- Review all Security Hotspots
- Mark as "Safe" (with justification) or "Fixed"
- Track review progress in Security Hotspots tab
Yes! Via SonarLint integration:
Supported IDEs:
- IntelliJ IDEA (all editions)
- Visual Studio Code
- Eclipse
- Visual Studio (Windows)
Setup (IntelliJ IDEA example):
-
Install SonarLint plugin:
- Preferences → Plugins → Marketplace
- Search "SonarLint"
- Install and restart
-
Connect to SonarQube (Connected Mode):
- Preferences → Tools → SonarLint → Settings
- Click "+" to add connection
- Enter SonarQube URL:
http://localhost:9000 - Generate token in SonarQube: User → My Account → Security → Generate Token
- Paste token in SonarLint
-
Bind project:
- Right-click project → SonarLint → Bind to SonarQube/SonarCloud
- Select your SonarQube server
- Choose project
- Click "Bind"
-
Use Quick Fixes:
- Open a Mathematica file
- See issues highlighted in editor
- Click "Quick Fix" button (lightbulb icon)
- Code is automatically corrected!
Benefits:
- Real-time feedback while coding
- No need to run full scan
- Quick Fix integration (53 rules)
- Consistent rules with SonarQube server
GitHub Actions example:
name: SonarQube Analysis
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Full history for better analysis
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube Quality Gate
uses: sonarsource/sonarqube-quality-gate-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}GitLab CI example:
sonarqube-check:
image: sonarsource/sonar-scanner-cli:latest
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
script:
- sonar-scanner
-Dsonar.projectKey=$CI_PROJECT_NAME
-Dsonar.sources=.
-Dsonar.host.url=$SONAR_HOST_URL
-Dsonar.login=$SONAR_TOKEN
only:
- main
- merge_requestsJenkins example:
pipeline {
agent any
stages {
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh 'sonar-scanner'
}
}
}
stage('Quality Gate') {
steps {
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
}
}
}Azure Pipelines example:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: SonarQubePrepare@5
inputs:
SonarQube: 'SonarQube Connection'
scannerMode: 'CLI'
configMode: 'file'
- task: SonarQubeAnalyze@5
- task: SonarQubePublish@5
inputs:
pollingTimeoutSec: '300'Not directly, but complementary:
Wolfram Workbench:
- Real-time syntax checking
- Debugging
- Auto-completion
- Refactoring tools
SonarQube Mathematica Plugin:
- Code quality analysis
- Security scanning
- Historical metrics
- Team collaboration
Recommended workflow:
-
Develop in Workbench:
- Write code with syntax checking
- Use debugger
- Run unit tests
-
Commit to Git:
- Push changes
-
CI/CD runs SonarQube:
- Automated quality scan
- Security analysis
- Quality gate check
-
Review in SonarQube UI:
- Check issues
- Track technical debt
- View trends
-
Fix issues in Workbench:
- Use SonarLint for real-time feedback (if IDE supported)
- Or manually fix based on SonarQube report
Yes! Example Docker setup:
docker-compose.yml:
version: '3'
services:
sonarqube:
image: sonarqube:10-community
ports:
- "9000:9000"
environment:
- SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_logs:/opt/sonarqube/logs
# Mount plugin
- ./wolfralyze.jar:/opt/sonarqube/extensions/plugins/wolfralyze.jar
volumes:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:Start SonarQube:
docker-compose up -dRun scanner (from project directory):
docker run --rm \
--network="host" \
-v "$(pwd):/usr/src" \
sonarsource/sonar-scanner-cli \
-Dsonar.projectKey=my-project \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.login=YOUR_TOKENInstall plugin in running container:
docker cp wolfralyze.jar sonarqube:/opt/sonarqube/extensions/plugins/
docker restart sonarqubeYes! Three approaches:
1. Rule Templates (Easy)
- Use existing rule templates in SonarQube
- Configure parameters via UI
- No coding required
2. External Rules (Medium)
- Write rules in external tool
- Import findings via Generic Issue Import format
- Requires external tool development
3. Plugin Extension (Advanced)
- Fork the plugin repository
- Add custom rules in Java
- Rebuild and deploy plugin
Rule Template example:
- Go to Rules → Search "template"
- Find a rule template (e.g., "Custom pattern detector")
- Click Create
- Configure parameters:
- Name: "Detect Legacy API"
-
Pattern:
OldFunction\[ - Message: "Use NewFunction instead"
- Activate in Quality Profile
Contribution process:
-
Propose rule:
- Open GitHub Issue with rule proposal
- Include: Name, description, examples, rationale
- Wait for community feedback
-
Implement rule:
- Fork repository:
github.com/bceverly/wolfralyze - Create branch:
git checkout -b feature/my-rule - Add rule in
UnifiedRuleVisitor.java(for O(n) rules) - Add rule definition in
MathematicaRulesDefinition.java - Add tests in
src/test/java/
- Fork repository:
-
Test rule:
- Run unit tests:
./gradlew test - Build plugin:
./gradlew build - Test on real codebase
- Run unit tests:
-
Submit PR:
- Push branch:
git push origin feature/my-rule - Create Pull Request on GitHub
- Respond to code review feedback
- Push branch:
-
Documentation:
- Add rule documentation in
docs/rules/ - Include examples (noncompliant and compliant)
- Update changelog
- Add rule documentation in
Example rule implementation:
// In UnifiedRuleVisitor.java
private void checkMyCustomRule(FunctionCallNode node) {
if (node.getFunctionName().equals("DeprecatedFunc")) {
reportIssue(
node.getStartLine(),
"MyCustomRule",
"Avoid using DeprecatedFunc; use NewFunc instead."
);
}
}Yes! Via Generic Issue Import format:
1. Generate JSON file:
{
"issues": [
{
"engineId": "myanalyzer",
"ruleId": "MY-001",
"severity": "MAJOR",
"type": "BUG",
"primaryLocation": {
"message": "Issue description",
"filePath": "src/MyFile.wl",
"textRange": {
"startLine": 10,
"endLine": 10,
"startColumn": 1,
"endColumn": 20
}
}
}
]
}2. Import into SonarQube:
# In sonar-project.properties
sonar.externalIssuesReportPaths=issues.json3. Run scanner:
sonar-scannerIssues appear in:
- Issues tab → Filter: Rules → External
- Labeled with source: "myanalyzer:MY-001"
Use cases:
- Import findings from Wolfram Workbench
- Custom static analysis tools
- Third-party scanners
Yes! The plugin is 100% free and open-source:
- License: AGPL-3.0 (GNU General Public License v3.0)
- Cost: $0 (free forever)
- Source code: Available on GitHub
- Commercial use: Allowed
- Modification: Allowed
- Distribution: Allowed (with same AGPL-3.0 license)
SonarQube editions:
- Community Edition: Free (unlimited projects)
- Developer Edition: Paid (additional features)
- Enterprise Edition: Paid (advanced features)
Plugin works with all editions, including the free Community Edition.
Community Edition (Free):
- ✅ All 529 rules
- ✅ Code quality analysis
- ✅ Security scanning
- ✅ Duplication detection
- ✅ Complexity metrics
- ✅ Quality gates
- ❌ Branch analysis (main branch only)
- ❌ Pull request analysis
- ❌ Portfolio management
Developer Edition (Paid):
- ✅ Everything in Community
- ✅ Branch analysis (analyze feature branches)
- ✅ Pull request analysis (PR decoration)
- ✅ Incremental analysis (20x faster)
- ✅ Taint analysis (advanced security)
- ✅ 8 languages supported
Enterprise Edition (Paid):
- ✅ Everything in Developer
- ✅ Portfolio management (aggregate metrics)
- ✅ Advanced security features
- ✅ More languages
- ✅ Enterprise support
Recommendation:
- Individuals/small teams: Community Edition (free)
- Teams using Git branches/PRs: Developer Edition
- Large organizations: Enterprise Edition
Yes! The AGPL-3.0 license allows commercial use with conditions:
You CAN:
- ✅ Use in commercial projects
- ✅ Analyze proprietary code
- ✅ Use in corporate environments
- ✅ Charge customers for services using the plugin
You MUST:
⚠️ Keep AGPL-3.0 license if redistributing⚠️ Provide source code if distributing modified plugin⚠️ Include license and copyright notices
You DON'T need to:
- ✅ Open-source your analyzed code (code being analyzed is separate)
- ✅ Pay licensing fees
- ✅ Get permission (it's open-source!)
Clarification:
- Analyzing commercial code: No restrictions (just like using GCC to compile proprietary software)
- Modifying and distributing plugin: Must share modifications under AGPL-3.0
Community-maintained:
- Primary maintainer: Brian Ceverly (GitHub: @bceverly)
- Contributors: Community contributions welcome
- Organization: Not affiliated with Wolfram Research
- Support: Community forums, GitHub Issues
- Updates: Regular releases on GitHub
Contributing:
- Report bugs: GitHub Issues
- Suggest features: GitHub Discussions
- Submit code: Pull Requests
- Documentation: Wiki contributions
Commercial support:
- Not officially available
- Community support via GitHub
- Consider Enterprise SonarQube for general SonarQube support
Planned features (Version 2.0):
-
Notebook support (.nb files)
- Extract and analyze code cells
- Ignore text/markdown cells
- Handle notebook-specific constructs
-
Enhanced type inference
- Better nullable analysis
- Type propagation through functions
- Generic type support
-
More Quick Fixes
- Expand from 53 to 100+ fixes
- Complex refactorings
- Multi-line fixes
-
Performance analysis
- Detect compilation opportunities
- Memory usage analysis
- Benchmark recommendations
-
Test coverage integration
- Parse VerificationTest results
- Import coverage XML
- Coverage-based rules
Long-term (Version 3.0+):
- AI-powered issue detection
- Custom rule DSL (no Java required)
- Cloud-based analysis
- Integration with Wolfram Cloud
See full roadmap: ROADMAP.md in repository
Community support (Free):
-
GitHub Issues: Report bugs, request features
- URL:
github.com/bceverly/wolfralyze/issues - Response time: 1-5 business days
- URL:
-
GitHub Discussions: Ask questions, share ideas
- URL:
github.com/bceverly/wolfralyze/discussions - Community-driven
- URL:
-
Documentation:
-
README.md- User guide -
ARCHITECTURE.md- Technical details -
FAQ.md- This document -
Troubleshooting.md- Common issues
-
-
SonarQube Community Forum:
- URL:
community.sonarsource.com - Tag:
mathematica
- URL:
Professional support (Paid):
- Contact SonarSource for Enterprise support (covers SonarQube, not plugin-specific)
- Consider hiring consultants for custom development
Response expectations:
- Bug reports: 1-2 weeks for fix
- Feature requests: Evaluated quarterly
- Security issues: 24-48 hours (email maintainer)
Yes! Contributions welcome:
Ways to contribute:
-
Code contributions:
- New rules
- Bug fixes
- Performance improvements
- Test coverage
-
Documentation:
- Improve README
- Add examples
- Translate docs
- Write tutorials
-
Testing:
- Test on large codebases
- Report bugs
- Verify fixes
-
Community:
- Answer questions in Discussions
- Share use cases
- Write blog posts
Getting started:
- Read
CONTRIBUTING.md(coming soon) - Check "good first issue" labels on GitHub
- Fork repository
- Make changes
- Submit Pull Request
Recognition:
- Contributors listed in CHANGELOG
- Credit in release notes
- GitHub contributor badge
Thank you for using the SonarQube Mathematica Plugin!