What code quality checks does the EK9 compiler perform?
← Code Quality · Ref: Q311
The EK9 compiler performs over 30 distinct code quality checks, each with a specific error code. These are grouped into families.
COMPLEXITY (E11010-E11012, E11020-E11021)
E11010: Cyclomatic complexity exceeds threshold (default 45).
E11011: Nesting depth exceeds threshold (default 6 levels).
E11012: Statement count exceeds threshold.
E11020: Combined complexity product exceeds threshold.
E11021: Cognitive complexity exceeds threshold (default 35).
COHESION AND COUPLING (E11014-E11017)
E11014: Lack of Cohesion (LCOM4) exceeds threshold.
E11015: Efferent coupling (Ce) exceeds threshold.
E11016: Module-level coupling exceeds threshold.
E11017: Module-level cohesion below threshold.
INHERITANCE (E11019)
E11019: Inheritance depth exceeds threshold (class/trait 4, function 3, record 2).
RESPONSIBILITY (E11022-E11025)
E11022: Class should be a component (too many injected dependencies).
E11023: God class detected (too many methods and fields).
E11024: Missing delegation (class implements trait without 'by' delegation).
E11025: Hybrid aggregate (mixes data and behaviour excessively).
NAMING (E11030-E11032)
E11030: Type name does not follow conventions.
E11031: Non-descriptive variable name (temp, data, obj, etc.).
E11032: Variable name shadows operator keyword.
INJECTION (E11040)
E11040: Component has too many injection fields.
DISCARDED RETURNS (E11050-E11055)
E11050: Computational operator result discarded.
E11051: Pure function return value discarded.
E11052: Result or Optional return value not checked.
E11055: Constructor result discarded (always wrong).
CODE SMELLS (E11053-E11054, E11061-E11062, E11068)
E11053: Data clump detected (extract a record).
E11054: Law of Demeter violation (train wreck).
E11061: Named argument required at call site.
E11062: Named argument position mismatch.
E11068: String concatenation should use interpolation.
MAGIC LITERALS (E11064-E11067)
E11064: Magic literal in comparison.
E11065: Repeated literal (3+ per file or 4+ per module).
E11066: Constant not in dedicated constant block.
E11067: Constant naming convention violation.
SELF-OPERATIONS (E08080-E08081)
E08080: Self-assignment is pointless.
E08081: Self-comparison always produces a constant result.
FLOW CONDITIONS (E08082-E08089)
E08082: Constant comparison (both operands are literals).
E08083: Constant arithmetic (both operands are literals).
E08084: Redundant boolean comparison (comparing boolean with true/false).
E08085: Logical tautology (expression always true or always false).
E08086: Condition always true (flow-sensitive dead code).
E08087: Condition always false (flow-sensitive dead code).
E08088: Redundant isSet check (variable known to be set).
E08089: Never-set isSet check (variable known to be unset).
UNUSED (E08091, E11018)
E08091: Unused parameter detected.
E11018: Unused closure capture.
EMPTY CHECKS (E08092-E08093)
E08092: Redundant empty check (collection known to be non-empty).
E08093: Never-empty check (collection known to be empty).
See Q312 for complexity detail. See Q313 for code smells. See Q314 for cohesion and coupling. See Q315 for inheritance depth. See Q316 for discarded returns. See Q317 for magic literals. See Q318 for self-operations. See Q319 for unused parameters. See Q290 for naming rules. See Q557 for dead code detection. See Q558 for tautological conditions. See Q559 for redundant isSet. See Q247 for reading error messages. See Q248 for error code lookup.
Example
defines module qa.codequality.catalog defines function <?- Demonstrates a function that passes all quality checks. Every check in the catalog has been satisfied for this to compile. -?> gradeScore() as pure -> score as Integer <- grade as String: "F" excellentThreshold <- 90 goodThreshold <- 70 passThreshold <- 50 if score >= excellentThreshold grade: "A" else if score >= goodThreshold grade: "B" else if score >= passThreshold grade: "C" defines program QualityChecksCatalogDemo() stdout <- Stdout() testScore <- 85 result <- gradeScore(testScore) stdout.println(`Score ${testScore} earns grade: ${result}`)
Common mistakes
E50001 — Renaming the variable means later references to 'testScore' become unresolved, triggering E50001. See ek9 -h E50001 for details.
Incorrect:
testScoreXYZ <- 85
Correct:
testScore <- 85
E50001 — Renaming the variable means later references to 'result' become unresolved, triggering E50001. See ek9 -h E50001 for details.
Incorrect:
resultXYZ <- gradeScore(testScore)
Correct:
result <- gradeScore(testScore)
Other ways to ask this
- What are all the EK9 quality error codes?
- What does EK9 check for code quality?
- List all EK9 code quality rules
Coming from another language?
Java: SonarQube has 600+ rules but all optional. PMD has 300+ rules but all configurable. EK9: 30+ mandatory rules, zero configuration, cannot be disabled. Rust: clippy has 500+ lints but most are allow-by-default. Go: go vet checks a small subset, staticcheck adds more but all optional. Python: pylint has 200+ checks but all configurable. EK9 is the only language where ALL quality checks are mandatory compiler errors.
Keywords: codes, E11050, error, E11064, E11010, E11030, checks, E11014, metric, clean-code, E11019, compile, rules, catalog, E08080, quality