Skip to content

Commit a811dba

Browse files
committed
* fix all violations of Roslyn analyzer rules and ReSharper inspection * rename lambda param with type `ImageInReply` from `reply` to `image` @ `ReplyContentImageSaver.Save()` @ c#
1 parent cddbec5 commit a811dba

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

c#/crawler/src/Db/Post/PostWithContentAndAuthorExpGrade.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// ReSharper disable PropertyCanBeMadeInitOnly.Global
2+
// ReSharper disable UnusedAutoPropertyAccessor.Global
23
namespace tbm.Crawler.Db.Post;
34

5+
#pragma warning disable AV1000 // Type name contains the word 'and', which suggests it has multiple purposes
46
public abstract class PostWithContentAndAuthorExpGrade : PostWithAuthorExpGrade
7+
#pragma warning restore AV1000 // Type name contains the word 'and', which suggests it has multiple purposes
58
{
69
[NotMapped] public byte[]? Content { get; set; }
710

c#/crawler/src/Tieba/Crawl/Parser/Post/ReplyParser.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ protected override ReplyPost Convert(Reply inPost)
4343
throw new InvalidDataException("Reply parse error.", e);
4444
}
4545
}
46-
46+
}
47+
public partial class ReplyParser
48+
{
4749
public static void SimplifyImagesInReplyContent<TLoggerCategory>
4850
(ILogger<TLoggerCategory> logger, ref Reply inPost)
4951
{

c#/crawler/src/Tieba/Crawl/Saver/ReplyContentImageSaver.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where images.Keys.Contains(e.UrlFilename)
3636
.Where(pair => GlobalLockedImagesInReplyKeyByUrlFilename.TryAdd(pair.Key, pair.Value))
3737
.ToDictionary();
3838
newlyLockedImages.Values()
39-
.Where(reply => !Monitor.TryEnter(reply, TimeSpan.FromSeconds(10)))
39+
.Where(image => !Monitor.TryEnter(image, TimeSpan.FromSeconds(10)))
4040
.ForEach(image => logger.LogWarning(
4141
"Wait for locking newly locked image {} timed out after 10s", image.UrlFilename));
4242

@@ -45,7 +45,7 @@ where images.Keys.Contains(e.UrlFilename)
4545
.Keys().Except(newlyLockedImages.Keys()))
4646
.ToDictionary();
4747
alreadyLockedImages.Values()
48-
.Where(reply => !Monitor.TryEnter(reply, TimeSpan.FromSeconds(10)))
48+
.Where(image => !Monitor.TryEnter(image, TimeSpan.FromSeconds(10)))
4949
.ForEach(image => logger.LogWarning(
5050
"Wait for locking already locked image {} timed out after 10s", image.UrlFilename));
5151
if (alreadyLockedImages.Count != 0)

c#/shared/src/Db/TbmDbContext.cs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ private static void ManipulateCommand(DbCommand command) =>
130130
"RETURNING pg_current_xact_id()::xid");
131131
}
132132
}
133+
133134
public class TbmDbContext<TModelCacheKeyFactory>(ILogger<TbmDbContext<TModelCacheKeyFactory>> logger)
134135
: TbmDbContext(logger)
135136
where TModelCacheKeyFactory : class, IModelCacheKeyFactory

c#/shared/src/TransformEntityWorker.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async Task SaveThenLog(int processedCount, Process currentProcess)
5858
logger.LogTrace("processedEntityCount:{} updatedEntityCount:{} elapsed:{}ms processMemory:{}MiB exceptions:{}",
5959
processedCount, updatedEntityCount,
6060
stopwatch.ElapsedMilliseconds,
61-
currentProcess.PrivateMemorySize64 / 1024 / 1024,
61+
currentProcess.PrivateMemorySize64 / 1024f / 1024,
6262
JsonSerializer.Serialize(exceptions, JsonSerializerOptions));
6363
stopwatch.Restart();
6464
}

0 commit comments

Comments
 (0)