OSDN Git Service

フィールド名にアンダーバーを入れない (SA1310)
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 27 Feb 2022 21:16:00 +0000 (06:16 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Mon, 28 Feb 2022 11:41:22 +0000 (20:41 +0900)
OpenTween.Tests/Api/ApiLimitTest.cs
OpenTween.Tests/Api/TwitterApiStatusTest.cs
OpenTween.Tests/DateTimeUtcTest.cs
OpenTween.Tests/MyCommonTest.cs
OpenTween/Thumbnail/Services/SimpleThumbnailService.cs
OpenTween/Tween.cs
OpenTween/TweetExtractor.cs
OpenTween/Twitter.cs
OpenTween/WebBrowserController.cs

index e2e53d1..0c0b1d5 100644 (file)
@@ -30,7 +30,7 @@ namespace OpenTween.Api
 {
     public class ApiLimitTest
     {
-        public static readonly TheoryData<object?, bool> Equals_TestCase = new TheoryData<object?, bool>
+        public static readonly TheoryData<object?, bool> EqualsTestCase = new TheoryData<object?, bool>
         {
             { new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), true },
             { new ApiLimit(350, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0)), false },
@@ -41,7 +41,7 @@ namespace OpenTween.Api
         };
 
         [Theory]
-        [MemberData(nameof(Equals_TestCase))]
+        [MemberData(nameof(EqualsTestCase))]
         public void EqualsTest(object? obj2, bool expected)
         {
             var obj1 = new ApiLimit(150, 100, new DateTimeUtc(2013, 1, 1, 0, 0, 0));
index e9511b9..a1132e7 100644 (file)
@@ -49,7 +49,7 @@ namespace OpenTween.Api
             Assert.Equal(TwitterApiAccessLevel.Anonymous, apiStatus.AccessLevel);
         }
 
-        public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
+        public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseRateLimitTestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
         {
             {
                 new Dictionary<string, string> {
@@ -85,14 +85,14 @@ namespace OpenTween.Api
         };
 
         [Theory]
-        [MemberData(nameof(ParseRateLimit_TestCase))]
+        [MemberData(nameof(ParseRateLimitTestCase))]
         public void ParseRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
         {
             var limit = TwitterApiStatus.ParseRateLimit(header, "X-RateLimit-");
             Assert.Equal(expected, limit);
         }
 
-        public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimit_TestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
+        public static readonly TheoryData<Dictionary<string, string>, ApiLimit?> ParseMediaRateLimitTestCase = new TheoryData<Dictionary<string, string>, ApiLimit?>
         {
             {
                 new Dictionary<string, string> {
@@ -120,14 +120,14 @@ namespace OpenTween.Api
         };
 
         [Theory]
-        [MemberData(nameof(ParseMediaRateLimit_TestCase))]
+        [MemberData(nameof(ParseMediaRateLimitTestCase))]
         public void ParseMediaRateLimitTest(IDictionary<string, string> header, ApiLimit? expected)
         {
             var limit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-");
             Assert.Equal(expected, limit);
         }
 
-        public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevel_TestCase = new TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?>
+        public static readonly TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?> ParseAccessLevelTestCase = new TheoryData<Dictionary<string, string>, TwitterApiAccessLevel?>
         {
             {
                 new Dictionary<string, string> { { "X-Access-Level", "read" } },
@@ -152,7 +152,7 @@ namespace OpenTween.Api
         };
 
         [Theory]
-        [MemberData(nameof(ParseAccessLevel_TestCase))]
+        [MemberData(nameof(ParseAccessLevelTestCase))]
         public void ParseAccessLevelTest(IDictionary<string, string> header, TwitterApiAccessLevel? expected)
         {
             var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level");
index 9ed6cd2..532deec 100644 (file)
@@ -269,7 +269,7 @@ namespace OpenTween
                 utc.ToDateTimeUnsafe());
         }
 
-        public static readonly TheoryData<string, DateTimeUtc> Parse_Test_Fixtures = new TheoryData<string, DateTimeUtc>
+        public static readonly TheoryData<string, DateTimeUtc> ParseTestFixtures = new TheoryData<string, DateTimeUtc>
         {
             { "2018-05-06T11:22:33.111", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06T11:22:33.111+00:00", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
@@ -277,7 +277,7 @@ namespace OpenTween
         };
 
         [Theory]
-        [MemberData(nameof(Parse_Test_Fixtures))]
+        [MemberData(nameof(ParseTestFixtures))]
         public void Parse_Test(string input, DateTimeUtc expected)
             => Assert.Equal(expected, DateTimeUtc.Parse(input, DateTimeFormatInfo.InvariantInfo));
 
@@ -285,7 +285,7 @@ namespace OpenTween
         public void Parse_ErrorTest()
             => Assert.Throws<FormatException>(() => DateTimeUtc.Parse("### INVALID ###", DateTimeFormatInfo.InvariantInfo));
 
-        public static readonly TheoryData<string, bool, DateTimeUtc> TryParse_Test_Fixtures = new TheoryData<string, bool, DateTimeUtc>
+        public static readonly TheoryData<string, bool, DateTimeUtc> TryParseTestFixtures = new TheoryData<string, bool, DateTimeUtc>
         {
             { "2018-05-06T11:22:33.111", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06T11:22:33.111+00:00", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
@@ -294,7 +294,7 @@ namespace OpenTween
         };
 
         [Theory]
-        [MemberData(nameof(TryParse_Test_Fixtures))]
+        [MemberData(nameof(TryParseTestFixtures))]
         public void TryParse_Test(string input, bool expectedParsed, DateTimeUtc expectedResult)
         {
             var parsed = DateTimeUtc.TryParse(input, DateTimeFormatInfo.InvariantInfo, out var result);
@@ -303,7 +303,7 @@ namespace OpenTween
             Assert.Equal(expectedResult, result);
         }
 
-        public static readonly TheoryData<string, string, bool, DateTimeUtc> TryParseExact_Test_Fixtures = new TheoryData<string, string, bool, DateTimeUtc>
+        public static readonly TheoryData<string, string, bool, DateTimeUtc> TryParseExactTestFixtures = new TheoryData<string, string, bool, DateTimeUtc>
         {
             { "2018-05-06 11:22:33.111", "yyyy-MM-dd HH:mm:ss.fff", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06 11:22:33.111 +00:00", "yyyy-MM-dd HH:mm:ss.fff zzz", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
@@ -313,7 +313,7 @@ namespace OpenTween
         };
 
         [Theory]
-        [MemberData(nameof(TryParseExact_Test_Fixtures))]
+        [MemberData(nameof(TryParseExactTestFixtures))]
         public void TryParseExact_Test(string input, string format, bool expectedParsed, DateTimeUtc expectedResult)
         {
             var parsed = DateTimeUtc.TryParseExact(input, new[] { format }, DateTimeFormatInfo.InvariantInfo, out var result);
index 55fed12..497aab0 100644 (file)
@@ -104,14 +104,14 @@ namespace OpenTween
         public void IsAnimatedGifTest(string filename, bool expected)
             => Assert.Equal(expected, MyCommon.IsAnimatedGif(filename));
 
-        public static readonly TheoryData<string, DateTimeUtc> DateTimeParse_TestCase = new TheoryData<string, DateTimeUtc>
+        public static readonly TheoryData<string, DateTimeUtc> DateTimeParseTestCase = new TheoryData<string, DateTimeUtc>
         {
             { "Sun Nov 25 06:10:00 +00:00 2012", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
             { "Sun, 25 Nov 2012 06:10:00 +00:00", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
         };
 
         [Theory]
-        [MemberData(nameof(DateTimeParse_TestCase))]
+        [MemberData(nameof(DateTimeParseTestCase))]
         public void DateTimeParseTest(string date, DateTimeUtc excepted)
             => Assert.Equal(excepted, MyCommon.DateTimeParse(date));
 
@@ -124,7 +124,7 @@ namespace OpenTween
             [DataMember(Name = "body")]
             public string Body { get; set; }
         }
-        public static readonly TheoryData<string, JsonData> CreateDataFromJson_TestCase = new TheoryData<string, JsonData>
+        public static readonly TheoryData<string, JsonData> CreateDataFromJsonTestCase = new TheoryData<string, JsonData>
         {
             {
                 @"{""id"":""1"", ""body"":""hogehoge""}",
@@ -133,7 +133,7 @@ namespace OpenTween
         };
 
         [Theory]
-        [MemberData(nameof(CreateDataFromJson_TestCase))]
+        [MemberData(nameof(CreateDataFromJsonTestCase))]
         public void CreateDataFromJsonTest<T>(string json, T expected)
             => Assert.Equal(expected, MyCommon.CreateDataFromJson<T>(json));
 
@@ -185,7 +185,7 @@ namespace OpenTween
         public void GetReadableVersionTest(string fileVersion, string expected)
             => Assert.Equal(expected, MyCommon.GetReadableVersion(fileVersion));
 
-        public static readonly TheoryData<PostClass, string> GetStatusUrlTest1_TestCase = new TheoryData<PostClass, string>
+        public static readonly TheoryData<PostClass, string> GetStatusUrlTest1TestCase = new TheoryData<PostClass, string>
         {
             {
                 new PostClass { StatusId = 249493863826350080L, ScreenName = "Favstar_LM", RetweetedId = null, RetweetedBy = null },
@@ -198,7 +198,7 @@ namespace OpenTween
         };
 
         [Theory]
-        [MemberData(nameof(GetStatusUrlTest1_TestCase))]
+        [MemberData(nameof(GetStatusUrlTest1TestCase))]
         public void GetStatusUrlTest1(PostClass post, string expected)
             => Assert.Equal(expected, MyCommon.GetStatusUrl(post));
 
index 36154b7..9026935 100644 (file)
@@ -39,8 +39,8 @@ namespace OpenTween.Thumbnail.Services
     class SimpleThumbnailService : IThumbnailService
     {
         protected Regex regex;
-        protected string thumb_replacement;
-        protected string? fullsize_replacement;
+        protected string thumbReplacement;
+        protected string? fullsizeReplacement;
 
         public SimpleThumbnailService(string pattern, string replacement)
             : this(pattern, replacement, null)
@@ -55,8 +55,8 @@ namespace OpenTween.Thumbnail.Services
         public SimpleThumbnailService(Regex regex, string replacement, string? file_replacement)
         {
             this.regex = regex;
-            this.thumb_replacement = replacement;
-            this.fullsize_replacement = file_replacement;
+            this.thumbReplacement = replacement;
+            this.fullsizeReplacement = file_replacement;
         }
 
         public override Task<ThumbnailInfo?> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
@@ -71,14 +71,14 @@ namespace OpenTween.Thumbnail.Services
                     MediaPageUrl = url,
                     ThumbnailImageUrl = thumbnailUrl,
                     TooltipText = null,
-                    FullSizeImageUrl = this.ReplaceUrl(url, this.fullsize_replacement)
+                    FullSizeImageUrl = this.ReplaceUrl(url, this.fullsizeReplacement)
                 };
             },
             token);
         }
 
         protected string? ReplaceUrl(string url)
-            => this.ReplaceUrl(url, this.thumb_replacement);
+            => this.ReplaceUrl(url, this.thumbReplacement);
 
         protected string? ReplaceUrl(string url, string? replacement)
         {
index 2316bc4..6a9e446 100644 (file)
@@ -349,8 +349,8 @@ namespace OpenTween
 
         private bool isColumnChanged = false;
 
-        private const int MAX_WORKER_THREADS = 20;
-        private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
+        private const int MaxWorderThreads = 20;
+        private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MaxWorderThreads);
         private readonly CancellationTokenSource workerCts = new CancellationTokenSource();
         private readonly IProgress<string> workerProgress = null!;
 
@@ -7671,7 +7671,7 @@ namespace OpenTween
             void DisableTasktrayAnimation()
                 => this.TimerRefreshIcon.Enabled = false;
 
-            var busyTasks = this.workerSemaphore.CurrentCount != MAX_WORKER_THREADS;
+            var busyTasks = this.workerSemaphore.CurrentCount != MaxWorderThreads;
             if (busyTasks)
             {
                 this.iconCnt += 1;
@@ -8652,7 +8652,7 @@ namespace OpenTween
         {
             MatchCollection m;
             // ハッシュタグの保存
-            m = Regex.Matches(statusText, Twitter.HASHTAG, RegexOptions.IgnoreCase);
+            m = Regex.Matches(statusText, Twitter.Hashtag, RegexOptions.IgnoreCase);
             var hstr = "";
             foreach (Match hm in m)
             {
index ed5dc60..f26eccd 100644 (file)
@@ -142,7 +142,7 @@ namespace OpenTween
         /// </summary>
         public static IEnumerable<TwitterEntityHashtag> ExtractHashtagEntities(string text)
         {
-            var matches = Regex.Matches(text, Twitter.HASHTAG);
+            var matches = Regex.Matches(text, Twitter.Hashtag);
             foreach (var match in matches.Cast<Match>())
             {
                 var groupHashtagSharp = match.Groups[2];
index 770be4f..a37d13b 100644 (file)
@@ -72,14 +72,14 @@ namespace OpenTween
         //   permissions and limitations under the License.
 
         // Hashtag用正規表現
-        private const string LATIN_ACCENTS = @"\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff";
-        private const string NON_LATIN_HASHTAG_CHARS = @"\u0400-\u04ff\u0500-\u0527\u1100-\u11ff\u3130-\u3185\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF";
-        private const string CJ_HASHTAG_CHARACTERS = @"\u30A1-\u30FA\u30FC\u3005\uFF66-\uFF9F\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\u3041-\u309A\u3400-\u4DBF\p{IsCJKUnifiedIdeographs}";
-        private const string HASHTAG_BOUNDARY = @"^|$|\s|「|」|。|\.|!";
-        private const string HASHTAG_ALPHA = "[A-Za-z_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
-        private const string HASHTAG_ALPHANUMERIC = "[A-Za-z0-9_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
-        private const string HASHTAG_TERMINATOR = "[^A-Za-z0-9_" + LATIN_ACCENTS + NON_LATIN_HASHTAG_CHARS + CJ_HASHTAG_CHARACTERS + "]";
-        public const string HASHTAG = "(" + HASHTAG_BOUNDARY + ")(#|#)(" + HASHTAG_ALPHANUMERIC + "*" + HASHTAG_ALPHA + HASHTAG_ALPHANUMERIC + "*)(?=" + HASHTAG_TERMINATOR + "|" + HASHTAG_BOUNDARY + ")";
+        private const string LatinAccents = @"\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253\u0254\u0256\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u1e00-\u1eff";
+        private const string NonLatinHashtagChars = @"\u0400-\u04ff\u0500-\u0527\u1100-\u11ff\u3130-\u3185\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF";
+        private const string CJHashtagCharacters = @"\u30A1-\u30FA\u30FC\u3005\uFF66-\uFF9F\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\u3041-\u309A\u3400-\u4DBF\p{IsCJKUnifiedIdeographs}";
+        private const string HashtagBoundary = @"^|$|\s|「|」|。|\.|!";
+        private const string HashtagAlpha = "[A-Za-z_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+        private const string HashtagAlphanumeric = "[A-Za-z0-9_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+        private const string HashtagTerminator = "[^A-Za-z0-9_" + LatinAccents + NonLatinHashtagChars + CJHashtagCharacters + "]";
+        public const string Hashtag = "(" + HashtagBoundary + ")(#|#)(" + HashtagAlphanumeric + "*" + HashtagAlpha + HashtagAlphanumeric + "*)(?=" + HashtagTerminator + "|" + HashtagBoundary + ")";
         // URL正規表現
         private const string UrlValidPrecedingChars = @"(?:[^A-Za-z0-9@@$##\ufffe\ufeff\uffff\u202a-\u202e]|^)";
         public const string UrlInvalidWithoutProtocolPrecedingChars = @"[-_./]$";
@@ -91,13 +91,13 @@ namespace OpenTween
         private const string UrlValidCCTLD = @"(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?=[^0-9a-zA-Z]|$))";
         private const string UrlValidPunycode = @"(?:xn--[0-9a-z]+)";
         private const string UrlValidDomain = @"(?<domain>" + UrlValidSubdomain + "*" + UrlValidDomainName + "(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + ")|" + UrlValidPunycode + ")";
-        public const string UrlValidAsciiDomain = @"(?:(?:[a-z0-9" + LATIN_ACCENTS + @"]+)\.)+(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + "|" + UrlValidPunycode + ")";
+        public const string UrlValidAsciiDomain = @"(?:(?:[a-z0-9" + LatinAccents + @"]+)\.)+(?:" + UrlValidGTLD + "|" + UrlValidCCTLD + "|" + UrlValidPunycode + ")";
         public const string UrlInvalidShortDomain = "^" + UrlValidDomainName + UrlValidCCTLD + "$";
         private const string UrlValidPortNumber = @"[0-9]+";
 
-        private const string UrlValidGeneralPathChars = @"[a-z0-9!*';:=+,.$/%#\[\]\-_~|&" + LATIN_ACCENTS + "]";
+        private const string UrlValidGeneralPathChars = @"[a-z0-9!*';:=+,.$/%#\[\]\-_~|&" + LatinAccents + "]";
         private const string UrlBalanceParens = @"(?:\(" + UrlValidGeneralPathChars + @"+\))";
-        private const string UrlValidPathEndingChars = @"(?:[+\-a-z0-9=_#/" + LATIN_ACCENTS + "]|" + UrlBalanceParens + ")";
+        private const string UrlValidPathEndingChars = @"(?:[+\-a-z0-9=_#/" + LatinAccents + "]|" + UrlBalanceParens + ")";
         private const string Pth = "(?:" +
             "(?:" +
                 UrlValidGeneralPathChars + "*" +
index 40158dc..1677522 100644 (file)
@@ -25,6 +25,7 @@
 // Boston, MA 02110-1301, USA.
 
 #nullable enable
+#pragma warning disable SA1310
 
 using System;
 using System.Collections.Generic;