< Summary

Information
Class: GistBackend.Handlers.RssFeedHandler.Feeds.TheRecord
Assembly: GistBackend
File(s): /home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/TheRecord.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 43
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_RssUrl()100%210%
get_Language()100%210%
get_Type()100%210%
ExtractText(...)0%7280%

File(s)

/home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/TheRecord.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;
 7
 8namespace GistBackend.Handlers.RssFeedHandler.Feeds;
 9
 10public record TheRecord : RssFeed
 11{
 012    public override Uri RssUrl => new("https://therecord.media/feed");
 013    public override Language Language => En;
 014    public override FeedType Type => News;
 15
 16    public override string ExtractText(string content)
 17    {
 018        var doc = new HtmlDocument();
 019        doc.LoadHtml(content);
 20
 021        var articleContent = doc.DocumentNode.SelectSingleNode("//div[@class='article__content']");
 022        if (articleContent == null)
 23        {
 024            throw new ExtractingEntryTextException("Missing container element");
 25        }
 26
 027        var entryContents = articleContent.SelectNodes(".//span[@class='wysiwyg-parsed-content']");
 028        if (entryContents == null || entryContents.Count == 0)
 29        {
 030            throw new ExtractingEntryTextException("Missing container element");
 31        }
 32
 033        var textContent = entryContents.First().InnerText;
 034        if (string.IsNullOrWhiteSpace(textContent))
 35        {
 036            throw new ExtractingEntryTextException("No text found in container");
 37        }
 38
 039        var decodedText = HtmlDecode(textContent);
 040        return decodedText.Trim();
 41    }
 42}
 43