Class SpecializedFileGenerator
java.lang.Object
org.ek9lang.compiler.fuzz.SpecializedFileGenerator
Generates minimal, focused source files targeting specific compiler error codes.
Each generator creates a standalone program designed to trigger 1-3 specific errors
(E01084, E07790, E11010, etc.).
Extracted from
AtnBasedGenerator Cluster 3.-
Constructor Summary
ConstructorsConstructorDescriptionSpecializedFileGenerator(GenerationContext ctx, AtnBasedGenerator generator) -
Method Summary
Modifier and TypeMethodDescription(package private) GenerationResultGenerate a file with a function that has both moderate complexity AND moderate size.(package private) GenerationResultgenerateDeepInheritanceFile(Random random) Generate a file with 4+ level inheritance chains to exercise hierarchy validation.(package private) GenerationResultgenerateDiComponentFile(Random random) Generate a DI application file with abstract and concrete components and injection.(package private) GenerationResultgenerateDiscardedReturnFile(Random random) Generate a file with function calls whose return values are discarded.(package private) GenerationResultGenerate a file with excessive complexity: deeply nested if/switch chains.(package private) GenerationResultgenerateExcessiveParamsFile(Random random) Generate a file with functions having excessive parameters (6+).(package private) GenerationResultgenerateGenericErrorFile(Random random) Generate a file with generic type errors: wrong type param count, constrained generics.(package private) GenerationResultgenerateHighCouplingFile(Random random) Generate a two-file result where a consumer class/function references 9+ user-defined types from a provider module.(package private) GenerationResultgenerateLongLineFile(Random random) Generate a file with lines exceeding 120 characters.(package private) GenerationResultgenerateLowCohesionFile(Random random) Generate a class with many fields each accessed by exactly one method.(package private) GenerationResultgenerateLowModuleCohesionFile(Random random) Generate a single file with 65+ small independent constructs that don't reference each other.(package private) GenerationResultgenerateManyStatementsFile(Random random) Generate a minimal file with 155+ simple statements in a function body.(package private) GenerationResultgenerateModuleCouplingFile(Random random) Generate a file with a class importing many external types from different modules.(package private) GenerationResultgenerateModuleCouplingFile2(Random random) Generate a multi-file result where a consumer module references 11+ external modules.(package private) GenerationResultgenerateNestedCoalescingFile(Random random) Generate a function with deeply nested coalescing operators.(package private) GenerationResultgenerateOperatorMisuseFile(Random random) Generate a minimal source file with ONLY an operator misuse error.(package private) GenerationResultgeneratePurityOverrideFile(Random random) Generate a file with a class hierarchy that has purity contract violations.(package private) GenerationResultgenerateRepeatedLiteralFile(Random random) Generate a minimal file with 4+ identical STRING literals in simple assignments.(package private) GenerationResultgenerateServiceFile(Random random) Generate a service file with various URI paths, HTTP params, and sanitized parameters.(package private) GenerationResultgenerateUnusedCaptureFile(Random random) Generate a function containing a dynamic function that captures a variable but never uses it.
-
Constructor Details
-
SpecializedFileGenerator
SpecializedFileGenerator(GenerationContext ctx, AtnBasedGenerator generator)
-
-
Method Details
-
generateOperatorMisuseFile
Generate a minimal source file with ONLY an operator misuse error. Clean parse context ensures ANTLR produces "extraneous" message for E01084/E01085 detection. Also generates E01086 (method after operator) in a clean class context. -
generateManyStatementsFile
Generate a minimal file with 155+ simple statements in a function body. Simple variable declarations are trivially valid through all phases. Function threshold is 150 NCSS — 155+ declarations reliably trigger E11012. -
generateRepeatedLiteralFile
Generate a minimal file with 4+ identical STRING literals in simple assignments. Only string literals (content >= 3 chars, not in exempt contexts) trigger E11065. Integer/float literals are exempt from duplication tracking. -
generateDiComponentFile
Generate a DI application file with abstract and concrete components and injection. Targets E08140-E08230 (DI validation errors) through various mutation combinations. -
generateServiceFile
Generate a service file with various URI paths, HTTP params, and sanitized parameters. Targets E07790-E07950 (service validation errors). -
generateExcessiveComplexityFile
Generate a file with excessive complexity: deeply nested if/switch chains. Forces 30+ McCabe complexity score in a single method to trigger E11010. -
generateExcessiveParamsFile
Generate a file with functions having excessive parameters (6+). Targets E11020 (too many parameters) and E11062 (missing named arguments). -
generateLongLineFile
Generate a file with lines exceeding 120 characters. Targets E11040 (line too long). -
generateModuleCouplingFile
Generate a file with a class importing many external types from different modules. Targets E11050 (excessive coupling) and E11051 (too many dependencies). -
generateGenericErrorFile
Generate a file with generic type errors: wrong type param count, constrained generics. Targets E06030 (wrong type param count), E06020, E06010, and E06330. -
generatePurityOverrideFile
Generate a file with a class hierarchy that has purity contract violations. Targets E05100-E05190 (override/purity), E08120 (mutation in pure). -
generateDeepInheritanceFile
Generate a file with 4+ level inheritance chains to exercise hierarchy validation. Targets E05020-E05270 (type hierarchy), E11019 (deep inheritance). -
generateCombinedComplexitySizeFile
Generate a file with a function that has both moderate complexity AND moderate size. Each metric individually passes its limit, but the combined product exceeds 0.50. Targets E11020 (combined complexity-size violation).Key insights:
- Each
if X > Yadds 2 to complexity (1 for the if, 1 for the comparison) - Only variable declarations, assignments, and control flow count as NCSS statements (method calls like stdout.println do NOT count)
- Uses a parameter to avoid E08086/E08087 (always-true/false data flow)
Formula: (complexity/45) × (statements/150) > 0.50 Target range: complexity 33-41, statements 104-116.
- Each
-
generateDiscardedReturnFile
Generate a file with function calls whose return values are discarded. Targets E11066 (discarded return value). -
generateUnusedCaptureFile
Generate a function containing a dynamic function that captures a variable but never uses it. Targets E11018 (unused capture in dynamic function). -
generateNestedCoalescingFile
Generate a function with deeply nested coalescing operators. At depth 3+, cumulative complexity exceeds threshold 15 (scoring: 3^(depth-1) per level). Targets E11013 (excessive expression complexity). -
generateLowCohesionFile
Generate a class with many fields each accessed by exactly one method. No method shares fields with another, creating high LCOM4 (disconnected component groups). Targets E11014 (low cohesion). -
generateHighCouplingFile
Generate a two-file result where a consumer class/function references 9+ user-defined types from a provider module. Built-in types from org.ek9.lang are excluded from coupling count. Targets E11015 (excessive efferent coupling). -
generateLowModuleCohesionFile
Generate a single file with 65+ small independent constructs that don't reference each other. Creates many disconnected component groups exceeding module cohesion thresholds. Targets E11017 (low module cohesion): >30 groups, >88% disconnected, min 60 constructs. -
generateModuleCouplingFile2
Generate a multi-file result where a consumer module references 11+ external modules. Each provider file defines a unique module with one exported class. Targets E11016 (excessive module coupling, threshold >10 external modules).
-