From 651d9818c745383501048fe0ee5a1daa6dc94de7 Mon Sep 17 00:00:00 2001 From: Chris Simpson Date: Mon, 8 Aug 2022 16:20:37 +0100 Subject: [PATCH] ci(build): Fixes a number of warnings for a cleaner build (#2529) * Fixing a number of warnings for a cleaner build * Removing extra Summary slashes --- .../Clients/IObservableReactionsClient.cs | 8 -------- .../Clients/ObservableReactionsClient.cs | 11 ----------- .../Clients/RepositoriesClientTests.cs | 2 -- Octokit.Tests/Clients/ReactionsClientTests.cs | 14 -------------- Octokit.Tests/Exceptions/ApiExceptionTests.cs | 3 ++- .../Reactive/ObservableReactionsClientTests.cs | 14 -------------- Octokit/Clients/IReactionsClient.cs | 8 -------- Octokit/Clients/ReactionsClient.cs | 13 ------------- Octokit/Exceptions/ApiException.cs | 6 ++++-- Octokit/Helpers/ApiUrls.cs | 8 +++++++- Octokit/Models/Response/Repository.cs | 2 ++ 11 files changed, 15 insertions(+), 74 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 2cedf69a..c07a44d8 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -36,13 +36,5 @@ namespace Octokit.Reactive /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } - - /// - /// Delete a reaction. - /// - /// https://developer.github.com/v3/reactions/#delete-a-reaction - /// The reaction id - /// - IObservable Delete(int number); } } diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index 8cf79393..509bff62 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -51,16 +51,5 @@ namespace Octokit.Reactive /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// public IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } - - /// - /// Delete a reaction. - /// - /// https://developer.github.com/v3/reactions/#delete-a-reaction - /// The reaction id - /// - public IObservable Delete(int number) - { - return _client.Delete(number).ToObservable(); - } } } diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 0492ffa1..b45c63d9 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -879,7 +879,6 @@ public class RepositoriesClientTests Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); - Assert.True(repository.WatchersCount > 0); } [IntegrationTest] @@ -894,7 +893,6 @@ public class RepositoriesClientTests Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); - Assert.True(repository.WatchersCount > 0); } [IntegrationTest] diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs index 6e311e53..fda4b5d9 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -15,19 +15,5 @@ namespace Octokit.Tests.Clients Assert.Throws(() => new ReactionsClient(null)); } } - - public class TheDeleteMethod - { - [Fact] - public async Task DeletesCorrectUrl() - { - var connection = Substitute.For(); - var client = new ReactionsClient(connection); - - await client.Delete(42); - - connection.Received().Delete(Arg.Is(u => u.ToString() == "reactions/42"), Arg.Any()); - } - } } } diff --git a/Octokit.Tests/Exceptions/ApiExceptionTests.cs b/Octokit.Tests/Exceptions/ApiExceptionTests.cs index 7daa4aec..e9ef9ec6 100644 --- a/Octokit.Tests/Exceptions/ApiExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiExceptionTests.cs @@ -108,7 +108,8 @@ namespace Octokit.Tests.Exceptions var formatter = new BinaryFormatter(); formatter.Serialize(stream, exception); stream.Position = 0; - var deserialized = (ApiException)formatter.Deserialize(stream); + var deserializedObject = formatter.Deserialize(stream); + var deserialized = (ApiException)deserializedObject; Assert.Equal("Validation Failed", deserialized.ApiError.Message); Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); } diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs index 054fe574..7dc503fd 100644 --- a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -17,19 +17,5 @@ namespace Octokit.Tests.Reactive Assert.Throws(() => new ObservableReactionsClient(null)); } } - - public class TheDeleteMethod - { - [Fact] - public void PostsToCorrectUrl() - { - var gitHubClient = Substitute.For(); - var client = new ObservableReactionsClient(gitHubClient); - - client.Delete(13); - - gitHubClient.Reaction.Received().Delete(13); - } - } } } diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index fbf76569..1a67bfa5 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -41,13 +41,5 @@ namespace Octokit /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } - - /// - /// Delete a reaction. - /// - /// https://developer.github.com/v3/reactions/#delete-a-reaction - /// The reaction id - /// - Task Delete(int number); } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 4d1f3947..a42dfbf8 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -49,18 +49,5 @@ namespace Octokit /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// public IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } - - /// - /// Delete a reaction. - /// - /// https://developer.github.com/v3/reactions/#delete-a-reaction - /// The reaction id - /// - [ManualRoute("DELETE", "/reactions/{reaction_id}")] - [Obsolete("This route no longer works and is replaced with individual routes in each client")] - public Task Delete(int number) - { - return ApiConnection.Delete(ApiUrls.Reactions(number), new object()); - } } } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 9c997136..91f25597 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -25,7 +25,9 @@ namespace Octokit /// /// Constructs an instance of ApiException /// +#pragma warning disable CS0618 // Response() is obsolete but we need this as a default as Response passed down cannot be null public ApiException() : this(new Response()) +#pragma warning restore CS0618 // Response() is obsolete but we need this as a default as Response passed down cannot be null { } @@ -202,8 +204,8 @@ namespace Octokit { return HttpResponse?.ContentType != null && !HttpResponse.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) - && HttpResponse.Body is string - ? (string)HttpResponse.Body : string.Empty; + && HttpResponse.Body is string @string + ? @string : string.Empty; } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 098de9c8..be9f5610 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -109,7 +109,7 @@ namespace Octokit /// /// Returns the that returns all of the organizations. /// - /// /// The integer Id of the last Organization that you’ve seen. + /// The integer Id of the last Organization that you’ve seen. /// public static Uri AllOrganizations(long since) { @@ -485,6 +485,7 @@ namespace Octokit /// The owner of the repository /// The name of the repository /// The issue number + /// The reactionid for the issue /// public static Uri IssueReaction(string owner, string name, int number, int reaction) { @@ -496,6 +497,7 @@ namespace Octokit /// /// The Id of the repository /// The issue number + /// The reactionid for the issue /// public static Uri IssueReaction(long repositoryId, int number, int reaction) { @@ -589,6 +591,7 @@ namespace Octokit /// The owner of the repository /// The name of the repository /// The comment number + /// The reactionid for the comment /// public static Uri IssueCommentReaction(string owner, string name, int number, int reaction) { @@ -600,6 +603,7 @@ namespace Octokit /// /// The owner of the repository /// The comment number + /// The reactionid for the comment /// public static Uri IssueCommentReaction(long repositoryId, int number, int reaction) { @@ -1705,6 +1709,7 @@ namespace Octokit /// The owner of the repository /// The name of the repository /// The comment number + /// The reactionid for the comment /// public static Uri PullRequestReviewCommentReaction(string owner, string name, int number, int reaction) { @@ -1716,6 +1721,7 @@ namespace Octokit /// /// The Id of the repository /// The comment number + /// The reactionid for the comment /// public static Uri PullRequestReviewCommentReaction(long repositoryId, int number, int reaction) { diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index a017d694..33e53e1a 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -58,7 +58,9 @@ namespace Octokit AllowSquashMerge = allowSquashMerge; AllowMergeCommit = allowMergeCommit; Archived = archived; +#pragma warning disable CS0618 // Type or member is obsolete WatchersCount = watchersCount; +#pragma warning restore CS0618 // Type or member is obsolete Topics = topics.ToList(); DeleteBranchOnMerge = deleteBranchOnMerge; Visibility = visibility;