mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 07:04:27 +00:00
Resolve CA1002
This commit is contained in:
parent
3903ef0dfb
commit
65dc5def01
8 changed files with 20 additions and 44 deletions
|
@ -108,7 +108,6 @@ dotnet_analyzer_diagnostic.severity = warning
|
|||
dotnet_code_quality_unused_parameters = all:warning
|
||||
|
||||
# TODO - one at a time
|
||||
dotnet_diagnostic.ca1002.severity = silent
|
||||
dotnet_diagnostic.ca1027.severity = silent
|
||||
dotnet_diagnostic.ca1028.severity = silent
|
||||
dotnet_diagnostic.ca1031.severity = silent
|
||||
|
|
|
@ -1725,15 +1725,16 @@ namespace ArchiSteamFarm {
|
|||
return 0;
|
||||
}
|
||||
|
||||
List<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_card_set_cards']/div[starts-with(@class, 'badge_card_set_card')]");
|
||||
IEnumerable<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_card_set_cards']/div[starts-with(@class, 'badge_card_set_card')]");
|
||||
|
||||
if (htmlNodes.Count == 0) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(htmlNodes));
|
||||
result = (byte) htmlNodes.Count();
|
||||
|
||||
if (result == 0) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(result));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = (byte) htmlNodes.Count;
|
||||
CachedCardCountsForGame.TryAdd(appID, result);
|
||||
|
||||
return result;
|
||||
|
@ -1782,13 +1783,9 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<IElement> htmlNodes = response.Content.SelectNodes("//div[@class='pending_gift']/div[starts-with(@id, 'pending_gift_')][count(div[@class='pending_giftcard_leftcol']) > 0]/@id");
|
||||
IEnumerable<IElement> htmlNodes = response.Content.SelectNodes("//div[@class='pending_gift']/div[starts-with(@id, 'pending_gift_')][count(div[@class='pending_giftcard_leftcol']) > 0]/@id");
|
||||
|
||||
if (htmlNodes.Count == 0) {
|
||||
return new HashSet<ulong>(0);
|
||||
}
|
||||
|
||||
HashSet<ulong> results = new(htmlNodes.Count);
|
||||
HashSet<ulong> results = new();
|
||||
|
||||
foreach (string? giftCardIDText in htmlNodes.Select(node => node.GetAttribute("id"))) {
|
||||
if (string.IsNullOrEmpty(giftCardIDText)) {
|
||||
|
@ -1832,14 +1829,9 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
List<IElement> htmlNodes = response.Content.SelectNodes("(//table[@class='accountTable'])[2]//a/@data-miniprofile");
|
||||
IEnumerable<IElement> htmlNodes = response.Content.SelectNodes("(//table[@class='accountTable'])[2]//a/@data-miniprofile");
|
||||
|
||||
if (htmlNodes.Count == 0) {
|
||||
// OK, no authorized steamIDs
|
||||
return new HashSet<ulong>(0);
|
||||
}
|
||||
|
||||
HashSet<ulong> result = new(htmlNodes.Count);
|
||||
HashSet<ulong> result = new();
|
||||
|
||||
foreach (string? miniProfile in htmlNodes.Select(htmlNode => htmlNode.GetAttribute("data-miniprofile"))) {
|
||||
if (string.IsNullOrEmpty(miniProfile)) {
|
||||
|
|
|
@ -1925,17 +1925,11 @@ namespace ArchiSteamFarm {
|
|||
throw new ArgumentNullException(nameof(badgePage));
|
||||
}
|
||||
|
||||
List<IElement> linkElements = badgePage.SelectNodes("//a[@class='badge_craft_button']");
|
||||
|
||||
// We need to also select all badges that we have max level, as those will not display with a craft button
|
||||
// We select badges that are ready to craft, as well as those that are already crafted to a maximum level, as those will not display with a craft button
|
||||
// Level 5 is maximum level for card badges according to https://steamcommunity.com/tradingcards/faq
|
||||
linkElements.AddRange(badgePage.SelectNodes("//div[@class='badges_sheet']/div[contains(@class, 'badge_row') and .//div[@class='badge_info_description']/div[contains(text(), 'Level 5')]]/a[@class='badge_row_overlay']"));
|
||||
IEnumerable<IElement> linkElements = badgePage.SelectNodes("//a[@class='badge_craft_button'] | //div[@class='badges_sheet']/div[contains(@class, 'badge_row') and .//div[@class='badge_info_description']/div[contains(text(), 'Level 5')]]/a[@class='badge_row_overlay']");
|
||||
|
||||
if (linkElements.Count == 0) {
|
||||
return new HashSet<uint>(0);
|
||||
}
|
||||
|
||||
HashSet<uint> result = new(linkElements.Count);
|
||||
HashSet<uint> result = new();
|
||||
|
||||
foreach (string? badgeUri in linkElements.Select(htmlNode => htmlNode.GetAttribute("href"))) {
|
||||
if (string.IsNullOrEmpty(badgeUri)) {
|
||||
|
|
|
@ -391,12 +391,7 @@ namespace ArchiSteamFarm {
|
|||
throw new ArgumentNullException(nameof(parsedAppIDs));
|
||||
}
|
||||
|
||||
List<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_row_inner']");
|
||||
|
||||
if (htmlNodes.Count == 0) {
|
||||
// No eligible badges whatsoever
|
||||
return;
|
||||
}
|
||||
IEnumerable<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_row_inner']");
|
||||
|
||||
HashSet<Task>? backgroundTasks = null;
|
||||
|
||||
|
|
|
@ -81,9 +81,9 @@ namespace ArchiSteamFarm {
|
|||
};
|
||||
}
|
||||
|
||||
List<IElement> revisionNodes = response.Content.SelectNodes("//li[contains(@class, 'wiki-history-revision')]");
|
||||
IEnumerable<IElement> revisionNodes = response.Content.SelectNodes("//li[contains(@class, 'wiki-history-revision')]");
|
||||
|
||||
Dictionary<string, DateTime> result = new(revisionNodes.Count);
|
||||
Dictionary<string, DateTime> result = new();
|
||||
|
||||
foreach (IElement revisionNode in revisionNodes) {
|
||||
IElement? versionNode = revisionNode.SelectSingleElementNode(".//input/@value");
|
||||
|
|
|
@ -117,14 +117,10 @@ namespace ArchiSteamFarm {
|
|||
return null;
|
||||
}
|
||||
|
||||
IEnumerable<IElement> confirmationNodes = htmlDocument.SelectNodes("//div[@class='mobileconf_list_entry']");
|
||||
|
||||
HashSet<Confirmation> result = new();
|
||||
|
||||
List<IElement> confirmationNodes = htmlDocument.SelectNodes("//div[@class='mobileconf_list_entry']");
|
||||
|
||||
if (confirmationNodes.Count == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (IElement confirmationNode in confirmationNodes) {
|
||||
string? idText = confirmationNode.GetAttribute("data-confid");
|
||||
|
||||
|
|
|
@ -232,10 +232,10 @@ namespace ArchiSteamFarm {
|
|||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static List<IElement> SelectElementNodes(this IElement element, string xpath) => element.SelectNodes(xpath).OfType<IElement>().ToList();
|
||||
public static IEnumerable<IElement> SelectElementNodes(this IElement element, string xpath) => element.SelectNodes(xpath).OfType<IElement>();
|
||||
|
||||
[PublicAPI]
|
||||
public static List<IElement> SelectNodes(this IDocument document, string xpath) => document.Body.SelectNodes(xpath).OfType<IElement>().ToList();
|
||||
public static IEnumerable<IElement> SelectNodes(this IDocument document, string xpath) => document.Body.SelectNodes(xpath).OfType<IElement>();
|
||||
|
||||
[PublicAPI]
|
||||
public static IElement? SelectSingleElementNode(this IElement element, string xpath) => (IElement?) element.SelectSingleNode(xpath);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>5.0.7.0</Version>
|
||||
<Version>5.1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
Loading…
Reference in a new issue