DSF Linter Tool
DSF Linter - Complete Documentation
A comprehensive linting tool for DSF (Data Sharing Framework) process plugins. Validates BPMN processes, FHIR resources, and plugin configurations from JAR files.
Table of Contents
Overview
The DSF Linter is a static analysis tool designed to validate DSF process plugins before deployment. It performs comprehensive checks on:
- BPMN Process Definitions: Validates Camunda BPMN 2.0 models, task implementations, event configurations, and FHIR resource references
- FHIR Resources: Validates ActivityDefinition, Task, StructureDefinition, ValueSet, CodeSystem, and Questionnaire resources
- Plugin Configuration: Verifies ServiceLoader registrations, resource references, and plugin structure
Key Features
- β Validates BPMN processes against DSF conventions
- β Validates FHIR resources against DSF profiles and HL7 specifications
- β Detects unreferenced (leftover) resources
- β Generates detailed HTML and JSON reports
- β Supports local and remote JAR file input
- β Multi-plugin project support
- β CI/CD integration ready
- β Comprehensive error reporting with severity levels
- β Extensible architecture for custom validation rules
What is DSF?
The Data Sharing Framework (DSF) is a framework for implementing interoperable healthcare data sharing processes. DSF process plugins contain:
- BPMN Processes: Business process definitions using Camunda BPMN 2.0
- FHIR Resources: Healthcare data resources conforming to HL7 FHIR specifications
- Plugin Classes: Java classes implementing the DSF ProcessPlugin interface
Quick Start
Build the Project
# Full build with tests
mvn clean package
# Skip tests for faster build
mvn clean package -DskipTests
# Verbose output
mvn clean package -XBasic Usage
# Lint a local JAR file
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path your-plugin.jar --html
# Lint a remote JAR file
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path https://github.com/datasharingframework/dsf-process-ping-pong/releases/download/v2.0.0.1/dsf-process-ping-pong-2.0.0.1.jar --html
# View report at: /tmp/dsf-linter-report-<name>/dsf-linter-report/index.htmlInstallation
Requirements
- Java: 17 or higher
- Maven: 3.6 or higher
- Operating System: Windows, Linux, or macOS
Building from Source
# Clone the repository
git clone <repository-url>
cd dsf-linter
# Build the project
mvn clean package
# The executable JAR will be at:
# linter-cli/target/linter-cli-1.0-SNAPSHOT.jarDistribution
The linter is distributed as a single executable JAR file that includes all dependencies. After building, the JAR can be used standalone:
# Copy to a convenient location
cp linter-cli/target/linter-cli-1.0-SNAPSHOT.jar ~/bin/dsf-linter.jar
# Use from anywhere
java -jar ~/bin/dsf-linter.jar --path plugin.jar --htmlUsage
Input Types
The linter accepts only JAR files as input:
| Input Type | Example | Description |
|---|---|---|
| Local JAR | --path C:\path\to\plugin.jar | JAR file in local filesystem |
| Remote JAR | --path https://example.com/plugin.jar | JAR file via HTTP/HTTPS URL |
Important: Maven projects must first be built with mvn clean package before the resulting JAR file can be linted.
Expected JAR Structure
The linter expects the following structure in the JAR file:
plugin.jar
βββ META-INF/
β βββ services/
β βββ dev.dsf.bpe.process.ProcessPlugin (v1)
β βββ dev.dsf.bpe.process.v2.ProcessPlugin (v2)
βββ bpe/
β βββ *.bpmn (BPMN process definitions)
βββ fhir/
βββ ActivityDefinition/
β βββ *.xml or *.json
βββ Task/
β βββ *.xml or *.json
βββ StructureDefinition/
β βββ *.xml or *.json
βββ ValueSet/
β βββ *.xml or *.json
βββ CodeSystem/
β βββ *.xml or *.json
βββ Questionnaire/
βββ *.xml or *.jsonUsage Examples
Basic Linting
# Local JAR file
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path C:\path\to\plugin.jar --html
# Remote JAR file
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path https://github.com/datasharingframework/dsf-process-ping-pong/releases/download/v2.0.0.1/dsf-process-ping-pong-2.0.0.1.jar --htmlAdvanced Configuration
# Multiple report formats with custom path
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path plugin.jar --html --json --report-path ./reports
# Verbose output (colors enabled by default, use --no-color to disable)
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path plugin.jar --html --verbose
# Lint Maven project (two-step process)
# Step 1: Build the project
cd /path/to/project && mvn clean package
# Step 2: Lint the resulting JAR
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path /path/to/project/target/my-plugin-1.0.0.jar --htmlCI/CD Integration
# GitHub Actions / GitLab CI
FORCE_COLOR=1 java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path plugin.jar --html --json --verbose
# Jenkins (fail on errors)
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path plugin.jar --html
# Exit code: 0 = success, 1 = errors
# Don't fail build (gradual adoption)
java -jar linter-cli/target/linter-cli-1.0-SNAPSHOT.jar \
--path plugin.jar --html --no-failCLI Options
| Option | Short | Description | Required |
|---|---|---|---|
--path <input> | -p | Path to JAR file (local or remote URL) | Yes |
--html | Generate HTML report | No | |
--json | Generate JSON report | No | |
--report-path <dir> | -r | Custom report directory (default: <temp-dir>/dsf-linter-report-<name>/dsf-linter-report) | No |
--verbose | -v | Enable verbose logging output | No |
--no-color | Disable colored console output (default: enabled) | No | |
--no-fail | Exit with code 0 even if linter errors are found | No | |
--help | -h | Display help message | No |
--version | Display version information | No |
Environment Variables
| Variable | Effect |
|---|---|
NO_COLOR | Disables colored output |
FORCE_COLOR | Forces colored output (useful in CI) |
TERM=dumb | Disables colored output |
WT_SESSION, ANSICON | Windows color detection |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (no errors, or --no-fail was used) |
| 1 | Failure (errors found, or fatal error occurred) |
Report Generation
Report Structure
Reports are generated in the following structure:
<report-path>/
βββ index.html # Summary report (all plugins)
βββ plugin-name.html # Detailed report for each plugin
βββ plugin-name.json # JSON report (if --json specified)HTML Report
The HTML report provides a comprehensive, human-readable view of all linting results.
Summary Page (index.html)
The summary page includes:
Header:
- DSF Linter version
- Execution timestamp
- Project path
Overall Statistics:
- Total number of plugins
- Total errors
- Total warnings
- Execution time
Plugin Summary Table:
- Plugin name
- API version
- Error count
- Warning count
- Link to detailed report
Leftover Resource Summary:
- Unreferenced BPMN files
- Unreferenced FHIR resources
Plugin Report (plugin-name.html)
Each plugin has a detailed report page containing:
Plugin Metadata:
- Plugin name
- Plugin class name
- API version (v1 or v2)
BPMN Validation Results:
- List of all BPMN files
- Errors and warnings per file
- Detailed error messages with file and line references
FHIR Validation Results:
- List of all FHIR resources by type
- Errors and warnings per resource
- Detailed error messages with element paths
Plugin Configuration Results:
- ServiceLoader registration status
- Resource reference validation results
Leftover Resource Analysis:
- Unreferenced BPMN files
- Unreferenced FHIR resources
Severity Indicators:
- Color-coded severity levels (ERROR, WARNING, INFO, SUCCESS)
- Expandable/collapsible sections
JSON Report
The JSON report provides machine-readable output for CI/CD integration and automated processing.
Structure
{
"version": "2.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"projectPath": "/path/to/plugin.jar",
"executionTimeMs": 2300,
"success": true,
"summary": {
"totalPlugins": 1,
"totalErrors": 0,
"totalWarnings": 1,
"totalLeftoverBpmn": 0,
"totalLeftoverFhir": 0
},
"plugins": {
"plugin-name": {
"name": "plugin-name",
"class": "dev.dsf.bpe.plugin.ExamplePlugin",
"apiVersion": "V1",
"errors": 0,
"warnings": 1,
"bpmnFiles": [
{
"path": "bpe/process.bpmn",
"errors": 0,
"warnings": 1,
"items": [...]
}
],
"fhirResources": {
"ActivityDefinition": [...],
"Task": [...],
"StructureDefinition": [...]
},
"pluginConfig": {
"serviceLoaderRegistered": true,
"items": [...]
}
}
},
"leftoverAnalysis": {
"unreferencedBpmn": [],
"unreferencedFhir": []
}
}Lint Item Structure
Each lint item in the JSON report has the following structure:
{
"severity": "ERROR",
"type": "BpmnServiceTaskNameEmptyLintItem",
"message": "Service task must have a non-empty name",
"file": "bpe/process.bpmn",
"element": "ServiceTask_1",
"line": 42,
"column": 10
}Example Console Output
DSF Linter v2.0.0
=================================================================
Project: /path/to/plugin.jar
Report: /tmp/dsf-linter-report-plugin/dsf-linter-report
=================================================================
Phase 1: Project Setup
β JAR file validated
β Resources extracted
Phase 2: Resource Discovery
β Found 1 plugin(s)
β Plugin: my-process-plugin
- BPMN: 2 files
- FHIR: 15 resources
Phase 3: Linting
β BPMN validation: 0 errors, 1 warning
β FHIR validation: 0 errors, 0 warnings
β Plugin validation: 0 errors
Phase 4: Report Generation
β HTML report generated
Summary
=================================================================
β SUCCESS - No errors found
Plugins: 1
Errors: 0
Warnings: 1
Execution time: 2.3s
=================================================================Architecture
Project Structure
dsf-linter/
βββ linter-core/ # Core linting logic
β βββ src/main/java/dev/dsf/linter/
β β βββ analysis/ # Resource analysis
β β β βββ LeftoverResourceDetector.java
β β βββ bpmn/ # BPMN parsing & validation
β β β βββ BpmnLinter.java
β β β βββ BpmnModelLinter.java
β β β βββ BpmnTaskLinter.java
β β β βββ BpmnEventLinter.java
β β β βββ BpmnGatewayAndFlowLinter.java
β β β βββ BpmnSubProcessLinter.java
β β βββ fhir/ # FHIR parsing & validation
β β β βββ FhirResourceLinter.java
β β β βββ FhirTaskLinter.java
β β β βββ FhirStructureDefinitionLinter.java
β β β βββ FhirValueSetLinter.java
β β β βββ FhirActivityDefinitionLinter.java
β β β βββ FhirCodeSystemLinter.java
β β β βββ FhirQuestionnaireLinter.java
β β βββ service/ # Linting services
β β β βββ BpmnLintingService.java
β β β βββ FhirLintingService.java
β β β βββ PluginLintingService.java
β β β βββ PluginLintingOrchestrator.java
β β βββ output/ # Lint item definitions
β β β βββ item/ # Specific lint items (200+ classes)
β β βββ report/ # Report generation
β β β βββ LintingReportGenerator.java
β β βββ input/ # Input handling & JAR processing
β β β βββ InputResolver.java
β β βββ setup/ # Project setup & building
β β β βββ ProjectSetupHandler.java
β β βββ plugin/ # Plugin definition discovery
β β β βββ PluginDefinitionDiscovery.java
β β βββ classloading/ # Dynamic class loading
β β β βββ ProjectClassLoaderFactory.java
β β β βββ ClassInspector.java
β β βββ logger/ # Logging infrastructure
β β β βββ Logger.java
β β β βββ ConsoleLogger.java
β β β βββ Console.java
β β βββ constants/ # Constants & configuration
β β β βββ DsfApiConstants.java
β β βββ exception/ # Custom exceptions
β β β βββ ResourceLinterException.java
β β β βββ MissingServiceRegistrationException.java
β β βββ util/ # Utilities
β β βββ api/ # API version detection
β β βββ cache/ # Caching utilities
β β βββ converter/ # Format converters
β β βββ linting/ # Linting utilities
β β βββ loader/ # Class/service loading
β β βββ maven/ # Maven utilities
β β βββ resource/ # Resource management
β βββ src/main/resources/
β β βββ logback.xml # Logging configuration
β β βββ logback-verbose.xml # Verbose logging configuration
β β βββ templates/ # HTML report templates
β β βββ logo.svg
β β βββ single_plugin_report.html
β β βββ summary_report.html
β βββ src/test/ # Unit tests
β βββ java/
β βββ resources/ # Test fixtures
βββ linter-cli/ # CLI interface
βββ src/main/java/dev/dsf/linter/
βββ Main.java # CLI entry point
βββ LinterExecutor.java # Execution wrapper
βββ ResultPrinter.java # Result formattingKey Components
| Component | Purpose |
|---|---|
DsfLinter | Main orchestrator coordinating all linting phases |
ProjectSetupHandler | Handles JAR extraction and classloader setup |
ResourceDiscoveryService | Discovers plugins, BPMN files, and FHIR resources |
BpmnLintingService | Orchestrates BPMN validation |
FhirLintingService | Orchestrates FHIR resource validation |
PluginLintingService | Validates plugin configuration and ServiceLoader registration |
PluginLintingOrchestrator | Coordinates per-plugin linting workflow |
LeftoverResourceDetector | Identifies unreferenced resources |
LintingReportGenerator | Generates HTML and JSON reports |
InputResolver | Resolves and downloads remote JAR files |
BpmnModelLinter | Validates BPMN model structure and elements |
FhirResourceLinter | Validates FHIR resources using pluggable linters |
API Reference
Core Classes
DsfLinter
Main orchestrator class for the linting process.
Constructor:
DsfLinter(Config config)Methods:
OverallLinterResult lint() throws IOExceptionUsage:
DsfLinter.Config config = new DsfLinter.Config(
projectPath,
reportPath,
generateHtmlReport,
generateJsonReport,
failOnErrors,
logger
);
DsfLinter linter = new DsfLinter(config);
DsfLinter.OverallLinterResult result = linter.lint();DsfLinter.Config
Configuration record for the linter.
Fields:
Path projectPath: Path to the project rootPath reportPath: Path for report generationboolean generateHtmlReport: Whether to generate HTML reportboolean generateJsonReport: Whether to generate JSON reportboolean failOnErrors: Whether to fail on errorsLogger logger: Logger instance
DsfLinter.OverallLinterResult
Result record containing all linting results.
Fields:
Map<String, PluginLinter> pluginLinter: Results per pluginLeftoverResourceDetector.AnalysisResult leftoverAnalysis: Leftover resource analysisPath masterReportPath: Path to master reportlong executionTimeMs: Execution time in millisecondsboolean success: Whether linting succeeded
Methods:
int getPluginErrors(): Total error count from pluginsint getPluginWarnings(): Total warning count from pluginsint getLeftoverCount(): Count of leftover resourcesint getTotalErrors(): Total errors including leftovers
DsfLinter.PluginLinter
Linting result for a single plugin.
Fields:
String pluginName: Name of the pluginString pluginClass: Fully qualified class nameApiVersion apiVersion: DSF API version (V1 or V2)LintingOutput output: Detailed linting outputPath reportPath: Path to generated report
Linting Services
BpmnLintingService
Service for linting BPMN files.
Constructor:
BpmnLintingService(Logger logger)Methods:
LintingResult lint(
String pluginName,
List<File> bpmnFiles,
List<String> missingRefs,
Map<String, ResourceResolutionResult> outsideRoot,
Map<String, ResourceResolutionResult> fromDependencies,
File pluginResourceRoot
)FhirLintingService
Service for linting FHIR resources.
Constructor:
FhirLintingService(Logger logger)Methods:
LintingResult lint(
String pluginName,
List<File> fhirFiles,
List<String> missingRefs,
Map<String, ResourceResolutionResult> outsideRoot,
Map<String, ResourceResolutionResult> fromDependencies,
File pluginResourceRoot
)PluginLintingService
Service for linting plugin configuration.
Constructor:
PluginLintingService(Logger logger)Methods:
LintingResult lintPlugin(
Path projectPath,
PluginAdapter pluginAdapter,
ApiVersion apiVersion,
List<AbstractLintItem> collectedPluginItems
) throws MissingServiceRegistrationExceptionLint Items
All lint items extend AbstractLintItem and implement specific interfaces.
Base Classes
AbstractLintItem: Base class for all lint itemsBpmnElementLintItem: Base class for BPMN-specific lint itemsFhirElementLintItem: Base class for FHIR-specific lint itemsPluginLintItem: Base class for plugin-specific lint items
Severity Levels
ERROR: Critical issues that must be fixedWARNING: Issues that should be addressedINFO: Informational messagesSUCCESS: Validation passed successfully
Common Lint Item Methods
LinterSeverity getSeverity()
String getMessage()
File getFile()
String getElement()Utility Classes
Logger
Interface for logging functionality.
Methods:
void error(String message)
void error(String message, Throwable throwable)
void warn(String message)
void info(String message)
void debug(String message)InputResolver
Resolves and processes input JAR files.
Methods:
Optional<ResolutionResult> resolve(String inputPath)
String extractInputName(String inputPath, InputType inputType)
void cleanup(ResolutionResult resolution)ResourceDiscoveryService
Discovers plugins and resources.
Methods:
DiscoveryResult discover(ProjectContext context)