< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Languages.JScriptDelegateBuilder
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Languages/JScriptDelegateBuilder.cs
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
27%
Covered lines: 6
Uncovered lines: 16
Coverable lines: 22
Total lines: 45
Line coverage: 27.2%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 14:53:17 Line coverage: 19% (4/21) Branch coverage: 33.3% (2/6) Total lines: 43 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/06/2025 - 18:30:33 Line coverage: 23.8% (5/21) Branch coverage: 66.6% (4/6) Total lines: 43 Tag: Kestrun/Kestrun@aeddbedb8a96e9137aac94c2d5edd011b57ac87111/14/2025 - 12:29:34 Line coverage: 27.2% (6/22) Branch coverage: 66.6% (4/6) Total lines: 45 Tag: Kestrun/Kestrun@5e12b09a6838e68e704cd3dc975331b9e680a626 08/26/2025 - 14:53:17 Line coverage: 19% (4/21) Branch coverage: 33.3% (2/6) Total lines: 43 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/06/2025 - 18:30:33 Line coverage: 23.8% (5/21) Branch coverage: 66.6% (4/6) Total lines: 43 Tag: Kestrun/Kestrun@aeddbedb8a96e9137aac94c2d5edd011b57ac87111/14/2025 - 12:29:34 Line coverage: 27.2% (6/22) Branch coverage: 66.6% (4/6) Total lines: 45 Tag: Kestrun/Kestrun@5e12b09a6838e68e704cd3dc975331b9e680a626

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Implemented()100%11100%
Build(...)66.66%22623.8%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Languages/JScriptDelegateBuilder.cs

#LineLine coverage
 1using Kestrun.Hosting;
 2using Kestrun.Models;
 3using Microsoft.ClearScript.V8;
 4using Serilog.Events;
 5
 6namespace Kestrun.Languages;
 7// ---------------------------------------------------------------------------
 8//  Python delegate builder  –  now takes optional imports / references
 9// ---------------------------------------------------------------------------
 10
 11internal static class JScriptDelegateBuilder
 12{
 213    public static bool Implemented { get; set; }
 14    internal static RequestDelegate Build(KestrunHost host, string code)
 15    {
 116        var logger = host.Logger;
 117        if (logger.IsEnabled(LogEventLevel.Debug))
 18        {
 119            logger.Debug("Building JavaScript delegate, script length={Length}", code?.Length);
 20        }
 21
 122        if (!Implemented)
 23        {
 124            throw new NotImplementedException("JavaScript scripting is not yet supported in Kestrun.");
 25        }
 26
 027        var engine = new V8ScriptEngine();
 028        engine.AddHostType("KestrunResponse", typeof(KestrunResponse));
 029        engine.Execute(code);               // script defines global  function handle(ctx, res) { ... }
 30
 031        return async context =>
 032        {
 033            var krRequest = await KestrunRequest.NewRequest(context);
 034            var krResponse = new KestrunResponse(krRequest);
 035            engine.Script.handle(context, krResponse);
 036
 037            if (!string.IsNullOrEmpty(krResponse.RedirectUrl))
 038            {
 039                return;
 040            }
 041
 042            await krResponse.ApplyTo(context.Response);
 043        };
 44    }
 45}