< Summary

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

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace AspxLint.Core.Rules;
 4
 5public sealed class Sm001MultipleScriptManager : IRule
 6{
 2037    public string Id => "SM-001";
 308    public string Name => "Plusieurs ScriptManager dans la page";
 279    public Severity Severity => Severity.Error;
 10    public string Description =>
 2511        "Une page ASP.NET ne peut contenir qu'un seul <asp:ScriptManager>. Pour les content pages avec un master ayant d
 4612    public bool HasFix => false;
 13
 514    private static readonly Regex DetectRegex =
 515        new(@"<asp:ScriptManager\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
 16
 17    public IEnumerable<Issue> Detect(string content, string[] lines, RuleContext ctx)
 18    {
 19        var matches = new List<(int line, int col, string snippet)>();
 20        for (int i = 0; i < lines.Length; i++)
 21        {
 22            foreach (Match m in DetectRegex.Matches(lines[i]))
 23            {
 24                var rest = lines[i][m.Index..];
 25                var endTag = rest.IndexOf('>');
 26                var snippet = endTag >= 0 ? rest[..(endTag + 1)] : rest;
 27                matches.Add((i + 1, m.Index + 1, snippet));
 28            }
 29        }
 30
 31        if (matches.Count <= 1) yield break;
 32
 33        var firstLine = matches[0].line;
 34        for (int k = 1; k < matches.Count; k++)
 35        {
 36            var mm = matches[k];
 37            yield return new Issue(Id, Name, Severity,
 38                mm.line, mm.col, mm.snippet,
 39                $"Un ScriptManager existe deja ligne {firstLine}. Utiliser ScriptManagerProxy ici.");
 40        }
 41    }
 42
 443    public string? Fix(string content, RuleContext ctx) => null;
 44}