mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-16 22:40:30 +00:00
Resolve CA1002
This commit is contained in:
@@ -108,7 +108,6 @@ dotnet_analyzer_diagnostic.severity = warning
|
|||||||
dotnet_code_quality_unused_parameters = all:warning
|
dotnet_code_quality_unused_parameters = all:warning
|
||||||
|
|
||||||
# TODO - one at a time
|
# TODO - one at a time
|
||||||
dotnet_diagnostic.ca1002.severity = silent
|
|
||||||
dotnet_diagnostic.ca1027.severity = silent
|
dotnet_diagnostic.ca1027.severity = silent
|
||||||
dotnet_diagnostic.ca1028.severity = silent
|
dotnet_diagnostic.ca1028.severity = silent
|
||||||
dotnet_diagnostic.ca1031.severity = silent
|
dotnet_diagnostic.ca1031.severity = silent
|
||||||
|
|||||||
@@ -1725,15 +1725,16 @@ namespace ArchiSteamFarm {
|
|||||||
return 0;
|
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) {
|
result = (byte) htmlNodes.Count();
|
||||||
Bot.ArchiLogger.LogNullError(nameof(htmlNodes));
|
|
||||||
|
if (result == 0) {
|
||||||
|
Bot.ArchiLogger.LogNullError(nameof(result));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (byte) htmlNodes.Count;
|
|
||||||
CachedCardCountsForGame.TryAdd(appID, result);
|
CachedCardCountsForGame.TryAdd(appID, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -1782,13 +1783,9 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
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) {
|
HashSet<ulong> results = new();
|
||||||
return new HashSet<ulong>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<ulong> results = new(htmlNodes.Count);
|
|
||||||
|
|
||||||
foreach (string? giftCardIDText in htmlNodes.Select(node => node.GetAttribute("id"))) {
|
foreach (string? giftCardIDText in htmlNodes.Select(node => node.GetAttribute("id"))) {
|
||||||
if (string.IsNullOrEmpty(giftCardIDText)) {
|
if (string.IsNullOrEmpty(giftCardIDText)) {
|
||||||
@@ -1832,14 +1829,9 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
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) {
|
HashSet<ulong> result = new();
|
||||||
// OK, no authorized steamIDs
|
|
||||||
return new HashSet<ulong>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<ulong> result = new(htmlNodes.Count);
|
|
||||||
|
|
||||||
foreach (string? miniProfile in htmlNodes.Select(htmlNode => htmlNode.GetAttribute("data-miniprofile"))) {
|
foreach (string? miniProfile in htmlNodes.Select(htmlNode => htmlNode.GetAttribute("data-miniprofile"))) {
|
||||||
if (string.IsNullOrEmpty(miniProfile)) {
|
if (string.IsNullOrEmpty(miniProfile)) {
|
||||||
|
|||||||
@@ -1925,17 +1925,11 @@ namespace ArchiSteamFarm {
|
|||||||
throw new ArgumentNullException(nameof(badgePage));
|
throw new ArgumentNullException(nameof(badgePage));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IElement> linkElements = badgePage.SelectNodes("//a[@class='badge_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
|
||||||
|
|
||||||
// We need to also select all badges that we have max 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
|
// 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) {
|
HashSet<uint> result = new();
|
||||||
return new HashSet<uint>(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<uint> result = new(linkElements.Count);
|
|
||||||
|
|
||||||
foreach (string? badgeUri in linkElements.Select(htmlNode => htmlNode.GetAttribute("href"))) {
|
foreach (string? badgeUri in linkElements.Select(htmlNode => htmlNode.GetAttribute("href"))) {
|
||||||
if (string.IsNullOrEmpty(badgeUri)) {
|
if (string.IsNullOrEmpty(badgeUri)) {
|
||||||
|
|||||||
@@ -391,12 +391,7 @@ namespace ArchiSteamFarm {
|
|||||||
throw new ArgumentNullException(nameof(parsedAppIDs));
|
throw new ArgumentNullException(nameof(parsedAppIDs));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_row_inner']");
|
IEnumerable<IElement> htmlNodes = htmlDocument.SelectNodes("//div[@class='badge_row_inner']");
|
||||||
|
|
||||||
if (htmlNodes.Count == 0) {
|
|
||||||
// No eligible badges whatsoever
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashSet<Task>? backgroundTasks = null;
|
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) {
|
foreach (IElement revisionNode in revisionNodes) {
|
||||||
IElement? versionNode = revisionNode.SelectSingleElementNode(".//input/@value");
|
IElement? versionNode = revisionNode.SelectSingleElementNode(".//input/@value");
|
||||||
|
|||||||
@@ -117,14 +117,10 @@ namespace ArchiSteamFarm {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerable<IElement> confirmationNodes = htmlDocument.SelectNodes("//div[@class='mobileconf_list_entry']");
|
||||||
|
|
||||||
HashSet<Confirmation> result = new();
|
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) {
|
foreach (IElement confirmationNode in confirmationNodes) {
|
||||||
string? idText = confirmationNode.GetAttribute("data-confid");
|
string? idText = confirmationNode.GetAttribute("data-confid");
|
||||||
|
|
||||||
|
|||||||
@@ -232,10 +232,10 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PublicAPI]
|
[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]
|
[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]
|
[PublicAPI]
|
||||||
public static IElement? SelectSingleElementNode(this IElement element, string xpath) => (IElement?) element.SelectSingleNode(xpath);
|
public static IElement? SelectSingleElementNode(this IElement element, string xpath) => (IElement?) element.SelectSingleNode(xpath);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>5.0.7.0</Version>
|
<Version>5.1.0.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user