< Summary

Information
Class: GistBackend.Handlers.RssFeedHandler.Feeds.ArsTechnicaTechnologyLab
Assembly: GistBackend
File(s): /home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/ArsTechnicaTechnologyLab.cs
Line coverage
6%
Covered lines: 1
Uncovered lines: 14
Coverable lines: 15
Total lines: 39
Line coverage: 6.6%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_RssUrl()100%210%
get_Language()100%210%
get_Type()100%210%
get_AllowedCategories()100%210%
ExtractText(...)0%4260%

File(s)

/home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/ArsTechnicaTechnologyLab.cs

#LineLine coverage
 1using GistBackend.Exceptions;
 2using GistBackend.Types;
 3using HtmlAgilityPack;
 4using static System.Net.WebUtility;
 5using static GistBackend.Types.FeedType;
 6using static GistBackend.Types.Language;
 7using static GistBackend.Utils.RssFeedUtils;
 8
 9namespace GistBackend.Handlers.RssFeedHandler.Feeds;
 10
 2311public record ArsTechnicaTechnologyLab() : RssFeed()
 12{
 013    public override Uri RssUrl => new("https://feeds.arstechnica.com/arstechnica/technology-lab");
 014    public override Language Language => En;
 015    public override FeedType Type => News;
 016    public override IEnumerable<string> AllowedCategories => ["Security"];
 17
 18    public override string ExtractText(string content)
 19    {
 020        var doc = new HtmlDocument();
 021        doc.LoadHtml(content);
 22
 023        var entryContents = doc.DocumentNode.SelectNodes($"//div[{ContainsClassSpecifier("post-content")}]");
 024        if (entryContents == null || entryContents.Count == 0)
 25        {
 026            throw new ExtractingEntryTextException("Missing container element");
 27        }
 28
 029        var combinedText = string.Join("", entryContents.Select(node => node.InnerText));
 030        if (string.IsNullOrWhiteSpace(combinedText))
 31        {
 032            throw new ExtractingEntryTextException("No text found in container");
 33        }
 34
 035        var decodedText = HtmlDecode(combinedText);
 036        return decodedText.Trim().Replace("\n", " ");
 37    }
 38}
 39