What are the parameter count and line length limits in EK9?
← Code Quality · Ref: Q700
EK9 enforces both parameter count limits and line length limits to maintain readable, maintainable code.
PARAMETER COUNT (E11020)
Functions and methods with excessive parameters trigger E11020. The compiler scores parameters by complexity, with Booleans and similar types counting more heavily.
LINE LENGTH (E11040)
Lines exceeding 120 characters trigger E11040. This ensures code is readable without horizontal scrolling.
CORRECT PATTERNS
1. Group related parameters into a record or class
2. Use builder or configuration patterns
3. Split long expressions across multiple lines
4. Extract intermediate values into named variables
PARAMETER GROUPING
Instead of many individual parameters:
// Bad: 7 parameters createOrder(name, addr, city, zip, item, qty, price) // Good: grouped into meaningful types createOrder(customer as Customer, orderItem as OrderItem)
LINE SPLITTING
Use string interpolation and intermediate variables to keep lines short.
See Q316 for complexity metrics. See Q696 for complexity limits. See Q694 for named arguments.
Example
defines module qa.codequality.parametercountlimits defines record <?- Group related data into a record. This reduces parameter count in function signatures. -?> ShippingAddress streetAddress as String? cityName as String? postalCode as String? default private ShippingAddress() ShippingAddress() -> streetAddress as String cityName as String postalCode as String this.streetAddress :=? streetAddress this.cityName :=? cityName this.postalCode :=? postalCode default operator $ default operator ? defines function <?- Correct: 2 parameters instead of 6. Related data grouped into records. -?> formatShipping() as pure -> customerName as String shippingAddress as ShippingAddress <- label as String: customerName if shippingAddress? label: `${customerName}: ${shippingAddress}` <?- Correct: 3 parameters, within limits. Each parameter serves a distinct purpose. -?> calculateDiscount() as pure -> originalPrice as Float discountRate as Float minimumPrice as Float <- finalPrice as Float: originalPrice discountedPrice <- originalPrice * (1.0 - discountRate) if discountedPrice >= minimumPrice finalPrice: discountedPrice defines program ParameterCountLimitsDemo() stdout <- Stdout() addr <- ShippingAddress("123 Main St", "Springfield", "62701") label <- formatShipping("Alice", addr) stdout.println(label) price <- calculateDiscount(100.0, 0.2, 10.0) stdout.println(`Final price: ${price}`)
Common mistakes
E50060 — String has no toUpperCase() method in EK9. Use upperCase() instead. See ek9 -h E50060 for details.
Incorrect:
label <- formatShipping("Alice", addr).toUpperCase()
Correct:
label <- formatShipping("Alice", addr)
E50060 — Float has no toString() method; use the '$' prefix operator or '${...}' interpolation to convert to String. See ek9 -h E50060 for details.
Incorrect:
stdout.println(price.toString())
Correct:
stdout.println(`Final price: ${price}`)
Other ways to ask this
- What is E11020 too many parameters?
- What is E11040 line too long?
- How many parameters can a function have?
- What is the maximum line length in EK9?
Coming from another language?
Java: no parameter count enforcement (only static analysis). Python: no enforcement. C++: no enforcement. Rust: Clippy warns about parameter count. Go: no enforcement. EK9: compile error for excessive parameters and line length.
Keywords: limit, E11020, readable, E11040, length, line, count, metric, clean-code, quality, parameter