< Summary

Information
Class: AspxLint.Core.Rules.Asp004ContentMissingPlaceHolderId
Assembly: AspxLint.Core
File(s): D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Asp004ContentMissingPlaceHolderId.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 37
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Name()100%11100%
get_Severity()100%11100%
get_Description()100%11100%
get_HasFix()100%11100%
.cctor()100%11100%
Fix(...)100%11100%

File(s)

D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Asp004ContentMissingPlaceHolderId.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace AspxLint.Core.Rules;
 4
 5public sealed class Asp004ContentMissingPlaceHolderId : IRule
 6{
 2037    public string Id => "ASP-004";
 268    public string Name => "Content sans ContentPlaceHolderID (page enfant)";
 239    public Severity Severity => Severity.Error;
 10    public string Description =>
 2511        "Une balise <asp:Content> doit referencer un placeholder du master via ContentPlaceHolderID, sinon la page ne sa
 4612    public bool HasFix => false;
 13
 514    private static readonly Regex ContentRegex = new(
 515        @"<asp:Content\b([^>]*?)>",
 516        RegexOptions.IgnoreCase | RegexOptions.Compiled);
 17
 518    private static readonly Regex CphIdAttr = new(
 519        @"ContentPlaceHolderID\s*=\s*[""'][^""']+[""']",
 520        RegexOptions.IgnoreCase | RegexOptions.Compiled);
 21
 22    public IEnumerable<Issue> Detect(string content, string[] lines, RuleContext ctx)
 23    {
 24        for (int i = 0; i < lines.Length; i++)
 25        {
 26            foreach (Match m in ContentRegex.Matches(lines[i]))
 27            {
 28                if (CphIdAttr.IsMatch(m.Groups[1].Value)) continue;
 29                yield return new Issue(Id, Name, Severity,
 30                    i + 1, m.Index + 1, m.Value,
 31                    "Ajouter ContentPlaceHolderID=\"...\" pointant vers un placeholder du master.");
 32            }
 33        }
 34    }
 35
 436    public string? Fix(string content, RuleContext ctx) => null;
 37}