Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following are required to use this functionality:

  • Python 3.10-3.12
  • A version control system
  • Your secret LLM provider API key

...

  1. Create a virtual environment:
    Code Block
    python -m venv venv
  2. Enter the virtual environment:
    Code Block
    source venv/bin/activate
  3. 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:

OptionRequiredCLI ArgumentEnvironment VariableDefault ValueDescription
LLM API KeyYesN/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 fileYes--data DATA_FILE_PATHN/A-Path to the Jtest .data.json file. It must match the project used for the baseline analysis report.
Baseline ReportYes--report XML_REPORT_PATHREPORT=<XML_REPORT_PATH>-Path to the Jtest XML report containing violations to be fixed.
Tool HomeNo--tool-home JTEST_HOMETOOL_HOME=<JTEST_HOME>Jtest directoryPath to the Jtest installation directory. By default, it is set to the "../.." directory where the script is located.
Fix LimitNo--fix-limit COUNTFIX_LIMIT=<COUNT>0 (no limit)Maximum number of violation fix attempts per run.
Max AttemptsNo--max-attempts MAX_ATTEMPTSN/A3Maximum retry attempts per violation before stopping.
Model NameNoN/AMODEL_NAME=MODELgpt-4o-miniAI 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 NameNoN/AWEAK_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 CommandNo--verification-command COMMANDN/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 ControlNo--allow-no-source-controlN/ADisabledBypass source control warnings. Use with caution - changes will be made without version control and cannot be reverted.
HelpNo-h or --helpN/AN/ADisplay help information for the JtestAutoFix.py script.

Configuring the Environment

...

  1. Set your API key:
    Code Block
    SET OPENAI_API_KEY=your_secret_open_ai_key
  2. 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

  1. Set your API key:
    Code Block
    export OPENAI_API_KEY=your_secret_open_ai_key
  2. 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"

...

  1. 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
  2. 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 .cliAutoFix folder to track fix attempts and outcomes in *.history.yaml files.

Preserve history: To avoid re-attempting the same violations:

  • Preserve the .cliAutoFix folder and its *.history.yaml files between runs.
  • Alternatively, ensure all attempted violations are either fixed or suppressed before the next run.

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.

...