projectlombok/lombok · error

Legal values for 'emptyLines' are 'scan', 'indent', or…

Error message

Legal values for 'emptyLines' are 'scan', 'indent', or 'blank'.

What it means

FormatPreferences validates the `emptyLines` format option. Only three values are accepted: 'scan' (default, mimic input), 'indent' (fill blank lines with indentation), and 'blank' (fully empty lines). Any other non-null value throws IllegalArgumentException during `setFormatPreferences`.

Solutions

  1. Set emptyLines to one of: 'scan', 'indent', or 'blank'
  2. Remove the emptyLines key entirely to use the default 'scan' behavior
  3. Check spelling/case — matching is case-insensitive, so 'INDENT' is fine but 'indents' is not

Example fix

// before
Map<String,String> opts = new HashMap<>();
opts.put("emptylines", "preserve");
// after
opts.put("emptylines", "indent"); // or "scan" / "blank"
Defensive patterns

Strategy: validation

Validate before calling

String v = opts.get("emptyLines");
if (v != null && !(v.equalsIgnoreCase("scan") || v.equalsIgnoreCase("indent") || v.equalsIgnoreCase("blank")))
    throw new IllegalArgumentException("emptyLines must be scan|indent|blank");

Try / catch

try { delombok.setFormatPreferences(opts); } catch (IllegalArgumentException e) { /* fix option value from message */ throw e; }

Prevention

When it happens

Trigger: Passing a format option `emptyLines=<something>` other than scan/indent/blank (case-insensitive), e.g. via CLI `--format emptyLines:tabs`, an Ant `<format name="emptyLines" value="...">`, or a Map entry in `setFormatPreferences`.

Common situations: Typos like `emptyline`, `empty-lines:keep`, or copying values from other options such as `indent`; passing an empty-string value instead of omitting the key.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07). Data as JSON: /api/errors/7656c4658cf03679. Report an issue: GitHub.

Appendix: source

Thrown at src/delombok/lombok/delombok/FormatPreferences.java:78

		if (preferences == null) preferences = Collections.emptyMap();
		
		String indent_ = preferences.get("indent");
		if (indent_ != null && !"scan".equalsIgnoreCase(indent_)) {
			try {
				int id = Integer.parseInt(indent_);
				if (id > 0 && id < 32) {
					char[] c = new char[id];
					Arrays.fill(c, ' ');
					indent_ = new String(c);
				}
			} catch (NumberFormatException ignore) {}
			indent = indent_.replace("\\t", "\t").replace("tab", "\t");
		}
		String empties_ = preferences.get("emptyLines".toLowerCase());
		if ("indent".equalsIgnoreCase(empties_)) filledEmpties = true;
		else if ("blank".equalsIgnoreCase(empties_)) filledEmpties = false;
		else if (empties_ != null && !"scan".equalsIgnoreCase(empties_)) {
			throw new IllegalArgumentException("Legal values for 'emptyLines' are 'scan', 'indent', or 'blank'.");
		}
		
		this.indent = indent;
		this.filledEmpties = filledEmpties;
		
		this.generateFinalParams = unrollBoolean(preferences, "finalParams", "generate", "skip", true);
		this.generateConstructorProperties = unrollBoolean(preferences, "constructorProperties", "generate", "skip", true);
		this.generateSuppressWarnings = unrollBoolean(preferences, "suppressWarnings", "generate", "skip", true);
		this.generateGenerated = unrollBoolean(preferences, "generated", "generate", "skip", true);
		this.danceAroundIdeChecks = unrollBoolean(preferences, "danceAroundIdeChecks", "generate", "skip", true);
		this.generateDelombokComment = unrollBoolean(preferences, "generateDelombokComment", "generate", "skip", true);
		this.javaLangAsFqn = unrollBoolean(preferences, "javaLangAsFQN", "generate", "skip", true);
	}
	
	private static boolean unrollBoolean(Map<String, String> preferences, String name, String trueStr, String falseStr, boolean defaultVal) {
		String v_ = preferences.get(name.toLowerCase());
		if (v_ == null) return defaultVal;
		if (trueStr.equalsIgnoreCase(v_)) return true;

View on GitHub (pinned to 6d6a3e9fec)