Class SpecializedFileGenerator

java.lang.Object
org.ek9lang.compiler.fuzz.SpecializedFileGenerator

final class SpecializedFileGenerator extends Object
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 Details

  • Method Details

    • generateOperatorMisuseFile

      GenerationResult generateOperatorMisuseFile(Random random)
      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

      GenerationResult generateManyStatementsFile(Random random)
      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

      GenerationResult generateRepeatedLiteralFile(Random random)
      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

      GenerationResult generateDiComponentFile(Random random)
      Generate a DI application file with abstract and concrete components and injection. Targets E08140-E08230 (DI validation errors) through various mutation combinations.
    • generateServiceFile

      GenerationResult generateServiceFile(Random random)
      Generate a service file with various URI paths, HTTP params, and sanitized parameters. Targets E07790-E07950 (service validation errors).
    • generateExcessiveComplexityFile

      GenerationResult generateExcessiveComplexityFile(Random random)
      Generate a file with excessive complexity: deeply nested if/switch chains. Forces 30+ McCabe complexity score in a single method to trigger E11010.
    • generateExcessiveParamsFile

      GenerationResult generateExcessiveParamsFile(Random random)
      Generate a file with functions having excessive parameters (6+). Targets E11020 (too many parameters) and E11062 (missing named arguments).
    • generateLongLineFile

      GenerationResult generateLongLineFile(Random random)
      Generate a file with lines exceeding 120 characters. Targets E11040 (line too long).
    • generateModuleCouplingFile

      GenerationResult generateModuleCouplingFile(Random random)
      Generate a file with a class importing many external types from different modules. Targets E11050 (excessive coupling) and E11051 (too many dependencies).
    • generateGenericErrorFile

      GenerationResult generateGenericErrorFile(Random random)
      Generate a file with generic type errors: wrong type param count, constrained generics. Targets E06030 (wrong type param count), E06020, E06010, and E06330.
    • generatePurityOverrideFile

      GenerationResult generatePurityOverrideFile(Random random)
      Generate a file with a class hierarchy that has purity contract violations. Targets E05100-E05190 (override/purity), E08120 (mutation in pure).
    • generateDeepInheritanceFile

      GenerationResult generateDeepInheritanceFile(Random random)
      Generate a file with 4+ level inheritance chains to exercise hierarchy validation. Targets E05020-E05270 (type hierarchy), E11019 (deep inheritance).
    • generateCombinedComplexitySizeFile

      GenerationResult generateCombinedComplexitySizeFile(Random random)
      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 > Y adds 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.

    • generateDiscardedReturnFile

      GenerationResult generateDiscardedReturnFile(Random random)
      Generate a file with function calls whose return values are discarded. Targets E11066 (discarded return value).
    • generateUnusedCaptureFile

      GenerationResult generateUnusedCaptureFile(Random random)
      Generate a function containing a dynamic function that captures a variable but never uses it. Targets E11018 (unused capture in dynamic function).
    • generateNestedCoalescingFile

      GenerationResult generateNestedCoalescingFile(Random random)
      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

      GenerationResult generateLowCohesionFile(Random random)
      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

      GenerationResult generateHighCouplingFile(Random random)
      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

      GenerationResult generateLowModuleCohesionFile(Random random)
      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

      GenerationResult generateModuleCouplingFile2(Random random)
      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).