< Summary

Information
Class: GistBackend.Handlers.RssFeedHandler.Feeds.TheVerge
Assembly: GistBackend
File(s): /home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/TheVerge.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 37
Line coverage: 0%
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
get_RssUrl()100%210%
get_Language()100%210%
get_Type()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/TheVerge.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 TheVerge : RssFeed
 11{
 012    public override Uri RssUrl => new("https://www.theverge.com/rss/cyber-security/index.xml");
 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 entryContents = doc.DocumentNode.SelectNodes("//div[@class='duet--article--article-body-component']");
 022        if (entryContents == null || entryContents.Count == 0)
 23        {
 024            throw new ExtractingEntryTextException("Missing container element");
 25        }
 26
 027        var combinedText = string.Join("", entryContents.Select(node => node.InnerText));
 028        if (string.IsNullOrWhiteSpace(combinedText))
 29        {
 030            throw new ExtractingEntryTextException("No text found in container");
 31        }
 32
 033        var decodedText = HtmlDecode(combinedText);
 034        return decodedText.Trim().Replace("\n", " ");
 35    }
 36}
 37