< Summary

Information
Class: GistBackend.Handlers.RssFeedHandler.Feeds.BleepingComputer
Assembly: GistBackend
File(s): /home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/BleepingComputer.cs
Line coverage
5%
Covered lines: 1
Uncovered lines: 19
Coverable lines: 20
Total lines: 47
Line coverage: 5%
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
.ctor()100%11100%
get_RssUrl()100%210%
get_Language()100%210%
get_Type()100%210%
get_AllowedCategories()100%210%
ExtractText(...)0%4260%
CheckForSponsoredContent(...)0%620%

File(s)

/home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Handlers/RssFeedHandler/Feeds/BleepingComputer.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
 2310public record BleepingComputer() : RssFeed()
 11{
 012    public override Uri RssUrl => new("https://www.bleepingcomputer.com/feed/");
 013    public override Language Language => En;
 014    public override FeedType Type => News;
 015    public override IEnumerable<string> AllowedCategories => ["Security"];
 16
 17    public override string ExtractText(string content)
 18    {
 019        var doc = new HtmlDocument();
 020        doc.LoadHtml(content);
 21
 022        var entryContent = doc.DocumentNode.SelectSingleNode("//div[@class='articleBody']");
 023        if (entryContent == null)
 24        {
 025            throw new ExtractingEntryTextException("Missing container element");
 26        }
 27
 028        var textContent = entryContent.InnerText;
 029        if (string.IsNullOrWhiteSpace(textContent))
 30        {
 031            throw new ExtractingEntryTextException("No text found in container");
 32        }
 33
 034        var decodedText = HtmlDecode(textContent);
 35
 036        var trimmed = decodedText.Split("Related Articles:");
 037        return (trimmed.Length > 0 ? trimmed[0] : decodedText).Trim();
 38    }
 39
 40    public override bool CheckForSponsoredContent(string content)
 41    {
 042        var doc = new HtmlDocument();
 043        doc.LoadHtml(content);
 044        var sponsoredNode = doc.DocumentNode.SelectSingleNode("//div[@class='cz-news-title-left-area']/strong");
 045        return sponsoredNode?.InnerText.Trim() == "Sponsored by";
 46    }
 47}