Skip to content

About

SonarQube plugin for Wolfram Mathematica - Code duplication detection and static analysis

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

SonarQube Plugin for Wolfram Mathematica

License: AGPL v3 Quality Gate Status Coverage Bugs Vulnerabilities

A Tier 1 SonarQube plugin providing comprehensive code quality analysis for Wolfram Mathematica with 559 rules, comparable to Java and Python support.


πŸš€ Quick Start

# 1. Install the plugin
cp wolfralyze-*.jar $SONARQUBE_HOME/extensions/plugins/
# Restart SonarQube

# 2. Configure your project
cat > sonar-project.properties << EOF
sonar.projectKey=my-mathematica-project
sonar.sources=.
sonar.inclusions=**/*.m,**/*.wl,**/*.wls
EOF

# 3. Run analysis
sonar-scanner

View results at http://localhost:9000

πŸ“– Full Documentation: https://github.com/bceverly/wolfralyze/wiki


πŸ“Š Test Coverage Integration

The plugin includes native test coverage support with automatic line-by-line coverage tracking in SonarQube.

Quick Start with Coverage

(* 1. Load the coverage utility *)
Get["CoverageUtils.wl"]

(* 2. Run your tests with coverage tracking *)
(* ... your test execution code ... *)

(* 3. Export coverage data *)
CoverageUtils`ExportCoverageJSON[coverageData, "coverage/coverage.json"]
# 4. Run SonarQube scan (coverage is imported automatically)
sonar-scanner

Features

  • βœ… Automatic JSON Export - Converts Wolfram Association structures to clean JSON
  • βœ… Data Validation - Validates coverage data structure before export
  • βœ… Line-by-Line Coverage - Includes hit counts for every line of code
  • βœ… Native SonarQube Integration - Coverage appears directly in SonarQube UI
  • βœ… Efficient Format - Optimized for large codebases
  • βœ… AGPLv3 Licensed - Free to use in your projects

Complete Working Example

See the Wolfralyze Test Project for a complete working example including:

  • βœ… Test runner with coverage tracking (RunTests.wl)
  • βœ… Sample Mathematica code with intentional issues
  • βœ… Unit tests using VerificationTest
  • βœ… SonarQube project configuration
  • βœ… Makefile for easy automation
  • βœ… Full documentation and examples

πŸ“– Coverage Documentation: See the Test Coverage Guide on the wiki for detailed instructions.


✨ Features

Comprehensive Rule Coverage (559 Rules)

Category Rules Description
Security Vulnerabilities 30 SQL injection, XSS, command injection, hardcoded credentials
Security Hotspots 25 Weak cryptography, authentication issues, certificate validation
Bugs 200 Null safety, resource leaks, type mismatches, infinite loops
Code Smells 304 Performance, complexity, readability, coding standards, best practices

Advanced Analysis

  • βœ… Taint Analysis - Track untrusted data through your code
  • βœ… Symbol Table - Cross-file analysis with full symbol resolution
  • βœ… Type Inference - Understand variable types through patterns
  • βœ… Data Flow - Track values, nulls, and resources
  • βœ… Control Flow - Detect unreachable code and infinite loops
  • βœ… Quick Fixes - 53 automated code corrections
  • βœ… Custom Rules - 3 templates for project-specific patterns

OWASP Top 10 Coverage

Covers 9 of 10 OWASP Top 10 2021 categories including injection, broken authentication, XSS, and more.


πŸ“š Documentation

Complete documentation available on the Wiki:

Getting Started

Understanding Results

Help & Best Practices

For Developers


🎯 Why Use This Plugin?

Security

  • Detect vulnerabilities before they reach production
  • OWASP Top 10 coverage with real Mathematica examples
  • Taint analysis tracks untrusted data flows
  • Hardcoded secret detection prevents credential leaks

Performance

  • 1000Γ— speedups by detecting AppendTo in loops
  • Compilation opportunities - Find code that should use Compile[]
  • Pattern optimization - Avoid catastrophic backtracking
  • Memory leak detection - Prevent growing definition chains

Quality

  • 200 bug rules catch runtime errors before they happen
  • 304 code smell rules improve maintainability and coding standards
  • Complexity metrics highlight code that needs refactoring
  • Duplicate detection finds copy-paste code

Productivity

  • 53 Quick Fixes - One-click automated corrections
  • IDE integration - Real-time feedback via SonarLint
  • CI/CD ready - Works with GitHub Actions, GitLab, Jenkins
  • Custom rules - Define project-specific patterns

πŸ“Š Tier 1 Language Support

This plugin provides best-in-class Mathematica support, comparable to major languages:

Feature Java Python Mathematica
Rules 733 410 559 βœ…
AST Parser βœ… βœ… βœ…
Symbol Table βœ… βœ… βœ…
Type System βœ… βœ… βœ…
Data Flow βœ… βœ… βœ…
Control Flow βœ… βœ… βœ…
Taint Analysis βœ… βœ… βœ…
Test Coverage βœ… βœ… βœ…
Quick Fixes βœ… βœ… βœ…
Custom Rules βœ… βœ… βœ…

πŸ—οΈ Building from Source

# Clone the repository
git clone git@github.com:bceverly/wolfralyze.git
cd wolfralyze

# Build
gradle clean build

# JAR file created at:
# build/libs/wolfralyze-*.jar

# SBOM (Software Bill of Materials) created at:
# build/reports/wolfralyze-*-sbom.json

Requirements

  • Java 11+
  • Gradle 8.0+
  • SonarQube 9.9+ (LTS) or 10.x

Software Bill of Materials (SBOM)

Each release includes a CycloneDX SBOM (Software Bill of Materials) for transparency and security compliance:

  • Format: CycloneDX 1.5 (JSON)
  • What it contains: Complete dependency inventory with versions, licenses, and component metadata
  • Why it matters: Enables supply chain security auditing, vulnerability tracking, and compliance verification
  • Generated by: CycloneDX Gradle Plugin
  • Verification: Each release includes SHA256 checksums for both JAR and SBOM files

For more details, see the SBOM Documentation.


🀝 Contributing

Contributions are welcome! Please see:

Adding New Rules

  1. Define rule in *RulesDefinition.java
  2. Implement detector in *Detector.java
  3. Add tests
  4. Update documentation
  5. Submit pull request

See Architecture for details.


πŸ“ License

AGPL-3.0 License - See LICENSE for details.


πŸ“ž Support


πŸ“ˆ Statistics

  • Total Rules: 559
  • Lines of Code: 50,000+
  • Test Coverage: Comprehensive detector tests
  • Performance: Optimized for 12,000+ file codebases
  • Documentation: 293 KB complete wiki
  • Status: Tier 1 - Production Ready

Latest Version: 0.9.7+ Status: βœ… Tier 1 Achieved (November 2025)

View Full Documentation β†’

About

SonarQube plugin for Wolfram Mathematica - Code duplication detection and static analysis

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages