< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Hosting.Options.MapRouteOptions
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
75%
Covered lines: 18
Uncovered lines: 6
Coverable lines: 24
Total lines: 109
Line coverage: 75%
Branch coverage
10%
Covered branches: 1
Total branches: 10
Branch coverage: 10%
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: 100% (22/22) Total lines: 110 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743110/13/2025 - 16:52:37 Line coverage: 100% (15/15) Total lines: 72 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e12/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c8330 12/12/2025 - 17:27:19 Line coverage: 66.6% (16/24) Branch coverage: 0% (0/10) Total lines: 109 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd12/15/2025 - 02:23:46 Line coverage: 75% (18/24) Branch coverage: 10% (1/10) Total lines: 109 Tag: Kestrun/Kestrun@7a3839f4de2254e22daae81ab8dc7cb2f40c8330

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Pattern()100%11100%
get_HttpVerbs()100%11100%
get_RequireSchemes()100%11100%
get_RequirePolicies()100%11100%
get_CorsPolicy()100%11100%
get_ShortCircuit()100%11100%
get_ShortCircuitStatusCode()100%11100%
get_AllowAnonymous()100%11100%
get_DisableAntiforgery()100%11100%
get_DisableResponseCompression()100%11100%
get_RateLimitPolicyName()100%11100%
get_Endpoints()100%11100%
get_DefaultResponseContentType()100%11100%
get_OpenAPI()100%11100%
get_PathLevelOpenAPIMetadata()100%210%
get_ScriptCode()100%11100%
get_ThrowOnDuplicate()100%11100%
ToString()50%22100%
AddSecurityRequirementObject(...)0%7280%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Hosting/Options/MapRouteOptions.cs

#LineLine coverage
 1using Kestrun.Utilities;
 2
 3namespace Kestrun.Hosting.Options;
 4/// <summary>
 5/// Options for mapping a route, including pattern, HTTP verbs, script code, authorization, and metadata.
 6/// </summary>
 7public class MapRouteOptions
 8{
 9    /// <summary>
 10    /// The route pattern to match for this option.
 11    /// </summary>
 48212    public string? Pattern { get; set; }
 13    /// <summary>
 14    /// The HTTP verbs (methods) that this route responds to.
 15    /// </summary>
 33516    public List<HttpVerb> HttpVerbs { get; set; } = [];
 17    /// <summary>
 18    /// Authorization Scheme names required for this route.
 19    /// </summary>
 16820    public List<string> RequireSchemes { get; init; } = []; // Authorization scheme name, if any
 21    /// <summary>
 22    /// Authorization policy names required for this route.
 23    /// </summary>
 15224    public List<string> RequirePolicies { get; init; } = []; // Authorization policies, if any
 25    /// <summary>
 26    /// Name of the CORS policy to apply, if any.
 27    /// </summary>
 10828    public string CorsPolicy { get; set; } = string.Empty; // Name of the CORS policy to apply, if any
 29    /// <summary>
 30    /// If true, short-circuits the pipeline after this route.
 31    /// </summary>
 3832    public bool ShortCircuit { get; set; } // If true, short-circuit the pipeline after this route
 33    /// <summary>
 34    /// Status code to return if short-circuiting the pipeline after this route.
 35    /// </summary>
 336    public int? ShortCircuitStatusCode { get; set; } = null; // Status code to return if short-circuiting
 37    /// <summary>
 38    /// If true, allows anonymous access to this route.
 39    /// </summary>
 3640    public bool AllowAnonymous { get; set; }
 41    /// <summary>
 42    /// If true, disables antiforgery protection for this route.
 43    /// </summary>
 6144    public bool DisableAntiforgery { get; set; }
 45    /// <summary>
 46    /// If true, disables response compression for this route.
 47    /// </summary>
 4048    public bool DisableResponseCompression { get; set; }
 49    /// <summary>
 50    /// The name of the rate limit policy to apply to this route, if any.
 51    /// </summary>
 3752    public string? RateLimitPolicyName { get; set; }
 53    /// <summary>
 54    /// Endpoints to bind the route to, if any.
 55    /// </summary>
 12456    public string[]? Endpoints { get; set; } = [];
 57
 58    /// <summary>
 59    /// Default response content type for this route.
 60    /// </summary>
 7361    public string DefaultResponseContentType { get; set; } = "text/html"; // Default response content type for this rout
 62
 63    /// <summary>
 64    /// OpenAPI metadata for this route.
 65    /// </summary>
 10466    public Dictionary<HttpVerb, OpenAPIMetadata> OpenAPI { get; set; } = []; // OpenAPI metadata for this route
 67
 68    /// <summary>
 69    /// Path-level OpenAPI common metadata for this route.
 70    /// </summary>
 071    public OpenAPICommonMetadata? PathLevelOpenAPIMetadata { get; set; }
 72
 73    /// <summary>
 74    /// Script code and language options for this route.
 75    /// </summary>
 38076    public LanguageOptions ScriptCode { get; init; } = new LanguageOptions();
 77    /// <summary>
 78    /// If true, throws an exception on duplicate routes.
 79    /// </summary>
 780    public bool ThrowOnDuplicate { get; set; }
 81
 82    /// <summary>
 83    /// Returns a string representation of the MapRouteOptions.
 84    /// </summary>
 85    /// <returns></returns>
 86    public override string ToString()
 87    {
 188        var verbs = HttpVerbs.Count > 0 ? string.Join(",", HttpVerbs) : "ANY";
 189        return $"{verbs} {Pattern}";
 90    }
 91
 92    /// <summary>
 93    /// Adds security requirement information to this route's authorization settings.
 94    /// </summary>
 95    /// <param name="schemes">the authorization schemes required for this route</param>
 96    /// <param name="policies">the authorization policies required for this route</param>
 97    public void AddSecurityRequirementObject(List<string>? schemes, List<string>? policies)
 98    {
 099        if (schemes is { Count: > 0 })
 100        {
 0101            RequireSchemes.AddRange(schemes);
 102        }
 103
 0104        if (policies is { Count: > 0 })
 105        {
 0106            RequirePolicies.AddRange(policies);
 107        }
 0108    }
 109}