...
The following are required to use this functionality:
- Python 3.10-3.12
- A version control system
- Your secret LLM provider API key
...
- Create a virtual environment:
Code Block python -m venv venv
- Enter the virtual environment:
Code Block source venv/bin/activate
- Install required dependencies:
Code Block python -m pip install --upgrade pip pip install -r requirements.txt
Autofix Autofix Configuration Options
The JtestAutoFix.py script can be configured using environment variables or command-line arguments. Command-line arguments take precedence over environment variables when both are specified.
Below is the complete reference for all available configuration options:
| Option | Required | CLI Argument | Environment Variable | Default Value | Description |
|---|---|---|---|---|---|
| LLM API Key | Yes | N/A | %PROVIDER%_API_KEY=<KEY> | - | Your secret LLM provider API key required by Aider. Replace %PROVIDER% with the provider of your choice. Learn more about providers and variables. |
| Data file | Yes | --data DATA_FILE_PATH | N/A | - | Path to the Jtest .data.json file. It must match the project used for the baseline analysis report. |
| Baseline Report | Yes | --report XML_REPORT_PATH | REPORT=<XML_REPORT_PATH> | - | Path to the Jtest XML report containing violations to be fixed. |
| Tool Home | No | --tool-home JTEST_HOME | TOOL_HOME=<JTEST_HOME> | Jtest directory | Path to the Jtest installation directory. By default, it is set to the "../.." directory where the script is located. |
| Fix Limit | No | --fix-limit COUNT | FIX_LIMIT=<COUNT> | 0 (no limit) | Maximum number of violation fix attempts per run. |
| Max Attempts | No | --max-attempts MAX_ATTEMPTS | N/A | 3 | Maximum retry attempts per violation before stopping. |
| Model Name | No | N/A | MODEL_NAME=MODEL | gpt-4o-mini | AI model for fixing violations (e.g., gpt-4, gpt-4o, claude-3-sonnet). Use aider --list-models <fragment> to see the available models. |
| Weak Model Name | No | N/A | WEAK_MODEL_NAME=MODEL | - | Lightweight model for auxiliary tasks, such as commit message generation. When not specified, it defaults to the specified model name (MODEL_NAME). |
| Verification Command | No | --verification-command COMMAND | N/A | - | Command to verify code integrity after each fix (e.g., "mvn compile" or "./gradlew assemble"). Success is determined by exit code (0 = success). |
| No Source Control | No | --allow-no-source-control | N/A | Disabled | Bypass source control warnings. Use with caution - changes will be made without version control and cannot be reverted. |
| Help | No | -h or --help | N/A | N/A | Display help information for the JtestAutoFix.py script. |
Configuring the Environment
...
- Set your API key:
Code Block SET OPENAI_API_KEY=your_secret_open_ai_key
- Execute Autofix with the recommended settings:
| Code Block |
|---|
python JtestAutoFix.py
--report "<PROJECT_PATH>/build/jtest/report.xml"
--max-attempts 3
--data "<PROJECT_PATH>/build/jtest/jtest.data.json"
--tool-home "C:\Program Files\Parasoft\Jtest\2025.2" |
Linux/Unix
- Set your API key:
Code Block export OPENAI_API_KEY=your_secret_open_ai_key
- Execute Autofix with the recommended settings:
Code Block python3 JtestAutoFix.py --report "<PROJECT_PATH>/build/jtest/report.xml" --max-attempts 3 --data "<PROJECT_PATH>/build/jtest/jtest.data.json" --tool-home "/opt/parasoft/jtest/2025.2"
...
- Set the environment variables:
Code Block export OPENAI_API_KEY=your_secret_open_ai_key export MODEL_NAME=gpt-4.1 export WEAK_MODEL_NAME=gpt-4o-mini
- Execute Autofix with build verification:
Code Block python JtestAutoFix.py --report "/home/user/projects/myapp/build/jtest/report.xml" --data "/home/user/projects/myapp/build/jtest/jtest.data.json" --tool-home "/opt/parasoft/jtest/2025.2" --verification-command "./gradlew build" --fix-limit 10 --max-attempts 2
| Note |
|---|
To ensure accurate results and efficient use of the Autofix plugin, follow these best practices: Generate a new baseline after each Autofix session: Code changes made during the autofix process can alter file line numbers and structure, making the violation locations in your original report.xml obsolete. Regenerate your baseline report to ensure it accurately reflects your updated codebase. Fix history tracking: The script creates data files in the Preserve history: To avoid re-attempting the same violations:
|
Reviewing Results
After each successful fix, the Autofix script creates a commit in your repository. Since AI-generated code may contain errors or suboptimal solutions, it is crucial to review all changes carefully.
...