< Summary

Information
Class: AspxLint.Core.Rules.Ws004FinalNewline
Assembly: AspxLint.Core
File(s): D:\a\claude-aspx-lint\claude-aspx-lint\src\AspxLint.Core\Rules\Ws004FinalNewline.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 26
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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%
Fix(...)100%22100%

File(s)

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

#LineLine coverage
 1namespace AspxLint.Core.Rules;
 2
 3public sealed class Ws004FinalNewline : IRule
 4{
 2125    public string Id => "WS-004";
 376    public string Name => "Pas de saut de ligne final";
 347    public Severity Severity => Severity.Info;
 8    public string Description =>
 259        "POSIX recommande qu'un fichier texte se termine par un saut de ligne. Sinon, certains outils Unix l'affichent m
 4610    public bool HasFix => true;
 11
 12    public IEnumerable<Issue> Detect(string content, string[] lines, RuleContext ctx)
 13    {
 14        if (content.Length == 0) yield break;
 15        if (content.EndsWith('\n')) yield break;
 16
 17        var lastLineLength = lines.Length == 0 ? 0 : lines[^1].Length;
 18        yield return new Issue(Id, Name, Severity,
 19            Math.Max(1, lines.Length), lastLineLength + 1,
 20            "— fin de fichier sans \\n",
 21            "Ajouter un saut de ligne a la fin du fichier.");
 22    }
 23
 24    public string? Fix(string content, RuleContext ctx) =>
 2125        content.EndsWith('\n') ? content : content + "\n";
 26}