< Summary

Information
Class: AspxLint.Core.Rules.Asp003ContentPlaceHolderMissingId
Assembly: AspxLint.Core
File(s): D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Asp003ContentPlaceHolderMissingId.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 39
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\Asp003ContentPlaceHolderMissingId.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace AspxLint.Core.Rules;
 4
 5public sealed class Asp003ContentPlaceHolderMissingId : IRule
 6{
 2057    public string Id => "ASP-003";
 288    public string Name => "ContentPlaceHolder sans ID (MASTER)";
 259    public Severity Severity => Severity.Error;
 10    public string Description =>
 2511        "Dans un fichier MASTER, chaque <asp:ContentPlaceHolder> doit avoir un attribut ID unique pour que les pages enf
 4612    public bool HasFix => false;
 13
 414    private static readonly Regex CphRegex = new(
 415        @"<asp:ContentPlaceHolder\b([^>]*?)\/?>",
 416        RegexOptions.IgnoreCase | RegexOptions.Compiled);
 17
 418    private static readonly Regex IdAttrRegex = new(
 419        @"\bID\s*=\s*[""'][^""']+[""']",
 420        RegexOptions.IgnoreCase | RegexOptions.Compiled);
 21
 22    public IEnumerable<Issue> Detect(string content, string[] lines, RuleContext ctx)
 23    {
 24        if (ctx.Ext != "master") yield break;
 25
 26        for (int i = 0; i < lines.Length; i++)
 27        {
 28            foreach (Match m in CphRegex.Matches(lines[i]))
 29            {
 30                if (IdAttrRegex.IsMatch(m.Groups[1].Value)) continue;
 31                yield return new Issue(Id, Name, Severity,
 32                    i + 1, m.Index + 1, m.Value,
 33                    "Ajouter un attribut ID unique a ce ContentPlaceHolder.");
 34            }
 35        }
 36    }
 37
 438    public string? Fix(string content, RuleContext ctx) => null;
 39}