languagetool-org/languagetool · error · IllegalArgumentException
Applying suggestions makes no sense for profiling
Error message
Applying suggestions makes no sense for profiling
What it means
parseOptions rejects -p/--profile together with -a/--apply-suggestions. Profiling measures rule evaluation times on the input text; automatically rewriting the text with applied suggestions would change the workload and the output, so the combination throws IllegalArgumentException.
Source
Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:164
}
if (options.isListUnknown()) {
throw new IllegalArgumentException("You cannot list unknown words in JSON output format");
}
} else if (args[i].equals("-a") || args[i].equals("--apply")) {
options.setApplySuggestions(true);
if (options.isTaggerOnly()) {
throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
}
if (options.isJsonFormat()) {
throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
}
} else if (args[i].equals("-p") || args[i].equals("--profile")) {
options.setProfile(true);
if (options.isJsonFormat()) {
throw new IllegalArgumentException("JSON output format makes no sense for profiling");
}
if (options.isApplySuggestions()) {
throw new IllegalArgumentException("Applying suggestions makes no sense for profiling");
}
if (options.isTaggerOnly()) {
throw new IllegalArgumentException("Tagging makes no sense for profiling");
}
} else if (args[i].equals("--xmlfilter")) {
options.setXmlFiltering(true);
} else if (i == args.length - 1) {
options.setFilename(args[i]);
} else {
throw new UnknownParameterException("Unknown parameter: " + args[i]);
}
}
return options;
}
void printUsage() {
printUsage(System.out);
}View on GitHub (pinned to 2e990059ce)
Solutions
- Remove -a/--apply-suggestions when profiling
- Profile first to find slow rules, then run a separate -a pass to apply fixes
- Keep profiling flags in a dedicated script that never sets -a
Example fix
// before languagetool -l en -p -a file.txt // after languagetool -l en -p file.txt # profile languagetool -l en -a file.txt # apply suggestions
Defensive patterns
Strategy: validation
Validate before calling
if (hasFlag(args, "-p", "--profile") && hasFlag(args, "-a", "--apply-suggestions")) {
throw new IllegalArgumentException("--profile cannot be combined with --apply-suggestions");
} Type guard
static boolean hasFlag(String[] args, String... names) {
for (String a : args) for (String n : names) if (a.equals(n)) return true;
return false;
} Try / catch
try {
options = CommandLineParser.parseOptions(args);
} catch (IllegalArgumentException e) {
System.err.println(e.getMessage());
System.exit(2);
} Prevention
- Profile measurement runs separately from text-rewriting runs
- Use separate scripts for benchmarking and correction tasks
- Review accumulated flags before adding -p
When it happens
Trigger: Command line contains both --profile (or -p) and --apply-suggestions (or -a), e.g. `languagetool -p -a file.txt`; the check runs in the profile branch when options.isApplySuggestions() is true.
Common situations: Benchmarking a run while leaving an auto-correct flag enabled from a previous command; building a wrapper that always passes -a and occasionally adds -p for diagnostics.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- JSON output format makes no sense for profiling
- Tagging makes no sense for profiling
- You cannot list unknown words in JSON output format
- Profiling mode cannot be used with input from STDIN
- Unknown parameter: <arg>
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/f7ecfd0a3a7d3b18.
Report an issue: GitHub.