From 6b668c62d687f0c77e2a987990304fb0c476fbc8 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 10 Nov 2020 22:17:11 +0000 Subject: [PATCH] Fixed all warnings --- src/Ombi.Api.Plex/PlexApi.cs | 13 ++++++------- src/Ombi.Api/HttpRequestExtensions.cs | 6 +++--- .../Engine/Demo/DemoMovieSearchEngine.cs | 8 ++++---- .../Engine/Demo/DemoTvSearchEngine.cs | 2 +- src/Ombi.Core/Engine/V2/CalendarEngine.cs | 4 ++-- .../Agents/DiscordNotification.cs | 3 ++- .../Context/Sqlite/ExternalSqliteContext.cs | 2 ++ .../Requests/ITvRequestRepository.cs | 3 --- .../Controllers/V1/External/EmbyController.cs | 6 +----- src/Ombi/Controllers/V1/SettingsController.cs | 2 +- src/Ombi/Controllers/V1/TokenController.cs | 12 +++--------- src/Ombi/Extensions/StartupExtensions.cs | 2 +- src/Ombi/Ombi.csproj | 19 ------------------- 13 files changed, 26 insertions(+), 56 deletions(-) diff --git a/src/Ombi.Api.Plex/PlexApi.cs b/src/Ombi.Api.Plex/PlexApi.cs index eaafcd75f..0d6356457 100644 --- a/src/Ombi.Api.Plex/PlexApi.cs +++ b/src/Ombi.Api.Plex/PlexApi.cs @@ -135,16 +135,15 @@ public async Task GetLibrariesForMachineId(string aut } /// - // 192.168.1.69:32400/library/metadata/3662/allLeaves - // The metadata ratingkey should be in the Cache - // Search for it and then call the above with the Directory.RatingKey - // THEN! We need the episode metadata using result.Vide.Key ("/library/metadata/3664") - // We then have the GUID which contains the TVDB ID plus the season and episode number: guid="com.plexapp.agents.thetvdb://269586/2/8?lang=en" + /// 192.168.1.69:32400/library/metadata/3662/allLeaves + /// The metadata ratingkey should be in the Cache + /// Search for it and then call the above with the Directory.RatingKey + /// THEN! We need the episode metadata using result.Vide.Key ("/library/metadata/3664") + /// We then have the GUID which contains the TVDB ID plus the season and episode number: guid="com.plexapp.agents.thetvdb://269586/2/8?lang=en" /// /// /// /// - /// public async Task GetEpisodeMetaData(string authToken, string plexFullHost, int ratingKey) { var request = new Request($"/library/metadata/{ratingKey}", plexFullHost, HttpMethod.Get); @@ -308,7 +307,7 @@ private void AddLimitHeaders(Request request, int from, int to) } private async Task CheckInstallId(PlexSettings s) { - if (s.InstallId == null || s.InstallId == Guid.Empty) + if (s?.InstallId == Guid.Empty || s.InstallId == Guid.Empty) { s.InstallId = Guid.NewGuid(); await _plexSettings.SaveSettingsAsync(s); diff --git a/src/Ombi.Api/HttpRequestExtensions.cs b/src/Ombi.Api/HttpRequestExtensions.cs index fa2ded97d..a08180362 100644 --- a/src/Ombi.Api/HttpRequestExtensions.cs +++ b/src/Ombi.Api/HttpRequestExtensions.cs @@ -5,7 +5,7 @@ namespace Ombi.Api { - public static class HttpRequestExtnesions + public static class HttpRequestExtensions { public static async Task Clone(this HttpRequestMessage request) { @@ -14,9 +14,9 @@ public static async Task Clone(this HttpRequestMessage reque Content = await request.Content.Clone(), Version = request.Version }; - foreach (KeyValuePair prop in request.Properties) + foreach (KeyValuePair prop in request.Options) { - clone.Properties.Add(prop); + clone.Options.TryAdd(prop.Key, prop.Value); } foreach (KeyValuePair> header in request.Headers) { diff --git a/src/Ombi.Core/Engine/Demo/DemoMovieSearchEngine.cs b/src/Ombi.Core/Engine/Demo/DemoMovieSearchEngine.cs index 86582fb4d..f392bf7ad 100644 --- a/src/Ombi.Core/Engine/Demo/DemoMovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/Demo/DemoMovieSearchEngine.cs @@ -50,7 +50,7 @@ public async Task> Search(string search) return null; } - public async Task> NowPlayingMovies() + new public async Task> NowPlayingMovies() { var rand = new Random(); var responses = new List(); @@ -72,18 +72,18 @@ public async Task> NowPlayingMovies() return responses; } - public async Task> PopularMovies() + new public async Task> PopularMovies() { return await NowPlayingMovies(); } - public async Task> TopRatedMovies() + new public async Task> TopRatedMovies() { return await NowPlayingMovies(); } - public async Task> UpcomingMovies() + new public async Task> UpcomingMovies() { return await NowPlayingMovies(); diff --git a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs index dd117fb53..343fb400a 100644 --- a/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs +++ b/src/Ombi.Core/Engine/Demo/DemoTvSearchEngine.cs @@ -35,7 +35,7 @@ public DemoTvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvM private readonly DemoLists _demoLists; - public async Task> Search(string search) + new public async Task> Search(string search) { var searchResult = await TvMazeApi.Search(search); diff --git a/src/Ombi.Core/Engine/V2/CalendarEngine.cs b/src/Ombi.Core/Engine/V2/CalendarEngine.cs index 4b3618780..4a5814e1a 100644 --- a/src/Ombi.Core/Engine/V2/CalendarEngine.cs +++ b/src/Ombi.Core/Engine/V2/CalendarEngine.cs @@ -27,7 +27,7 @@ public CalendarEngine(IPrincipal user, OmbiUserManager um, IRuleEvaluator rules, private readonly IMovieRequestRepository _movieRepo; private readonly ITvRequestRepository _tvRepo; - public async Task> GetCalendarData() + public Task> GetCalendarData() { var viewModel = new List(); var movies = _movieRepo.GetAll().Where(x => @@ -78,7 +78,7 @@ public async Task> GetCalendarData() }); } - return viewModel; + return Task.FromResult(viewModel); } private string GetBackgroundColor(BaseRequest req) diff --git a/src/Ombi.Notifications/Agents/DiscordNotification.cs b/src/Ombi.Notifications/Agents/DiscordNotification.cs index 71d0e298c..dda10f210 100644 --- a/src/Ombi.Notifications/Agents/DiscordNotification.cs +++ b/src/Ombi.Notifications/Agents/DiscordNotification.cs @@ -144,7 +144,8 @@ protected override async Task Send(NotificationMessage model, DiscordNotificatio "Available" => "51283", "Denied" => "13959168", "Processing Request" => "37354", - "Pending Approval" => "16754470" + "Pending Approval" => "16754470", + _ => throw new ArgumentOutOfRangeException(nameof(color)) }; } } diff --git a/src/Ombi.Store/Context/Sqlite/ExternalSqliteContext.cs b/src/Ombi.Store/Context/Sqlite/ExternalSqliteContext.cs index c85084d4a..f442531bc 100644 --- a/src/Ombi.Store/Context/Sqlite/ExternalSqliteContext.cs +++ b/src/Ombi.Store/Context/Sqlite/ExternalSqliteContext.cs @@ -27,7 +27,9 @@ private void Upgrade() Database.ExecuteSqlRaw(@"INSERT OR IGNORE INTO __EFMigrationsHistory (MigrationId,ProductVersion) VALUES('20191103205133_Inital', '2.2.6-servicing-10079'); "); } +#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. catch (Exception) +#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { // ignored } diff --git a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs index 8c2c838e7..396ec9dfb 100644 --- a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs @@ -9,10 +9,7 @@ namespace Ombi.Store.Repository.Requests public interface ITvRequestRepository : IRepository { OmbiContext Db { get; } - Task Add(TvRequests request); Task AddChild(ChildRequests request); - Task Delete(TvRequests request); - Task DeleteRange(IEnumerable request); Task DeleteChild(ChildRequests request); IQueryable Get(); IQueryable GetLite(); diff --git a/src/Ombi/Controllers/V1/External/EmbyController.cs b/src/Ombi/Controllers/V1/External/EmbyController.cs index 4b201fe7c..29ad84eb2 100644 --- a/src/Ombi/Controllers/V1/External/EmbyController.cs +++ b/src/Ombi/Controllers/V1/External/EmbyController.cs @@ -19,11 +19,7 @@ namespace Ombi.Controllers.V1.External [Produces("application/json")] public class EmbyController : Controller { - /// - /// - /// - /// - /// + public EmbyController(IEmbyApiFactory emby, ISettingsService embySettings) { EmbyApi = emby; diff --git a/src/Ombi/Controllers/V1/SettingsController.cs b/src/Ombi/Controllers/V1/SettingsController.cs index 8cef872f4..1d340b4cd 100644 --- a/src/Ombi/Controllers/V1/SettingsController.cs +++ b/src/Ombi/Controllers/V1/SettingsController.cs @@ -183,7 +183,7 @@ public async Task GetClientId() [HttpPost("plex")] public async Task PlexSettings([FromBody]PlexSettings plex) { - if (plex.InstallId == null || plex.InstallId == Guid.Empty) + if (plex?.InstallId == Guid.Empty || plex.InstallId == Guid.Empty) { plex.InstallId = Guid.NewGuid(); } diff --git a/src/Ombi/Controllers/V1/TokenController.cs b/src/Ombi/Controllers/V1/TokenController.cs index ad6e8ca23..66013ecf5 100644 --- a/src/Ombi/Controllers/V1/TokenController.cs +++ b/src/Ombi/Controllers/V1/TokenController.cs @@ -135,7 +135,7 @@ private async Task CreateToken(bool rememberMe, OmbiUser user) new Claim("Id", user.Id) }; claims.AddRange(roles.Select(role => new Claim("role", role))); - if(user.Email.HasValue()) + if (user.Email.HasValue()) { claims.Add(new Claim("Email", user.Email)); } @@ -158,14 +158,8 @@ private async Task CreateToken(bool rememberMe, OmbiUser user) } user.LastLoggedIn = DateTime.UtcNow; - try - { - await _userManager.UpdateAsync(user); - } - catch (Exception) - { - - } + + await _userManager.UpdateAsync(user); return new JsonResult(new { diff --git a/src/Ombi/Extensions/StartupExtensions.cs b/src/Ombi/Extensions/StartupExtensions.cs index cc90155e7..d14dc2e9e 100644 --- a/src/Ombi/Extensions/StartupExtensions.cs +++ b/src/Ombi/Extensions/StartupExtensions.cs @@ -48,7 +48,7 @@ public static void AddSwagger(this IServiceCollection services) Type = SecuritySchemeType.ApiKey }); c.CustomSchemaIds(x => x.FullName); - var basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var basePath = Path.GetDirectoryName(AppContext.BaseDirectory); var xmlPath = Path.Combine(basePath, "Swagger.xml"); try { diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 7b27b8d96..6925e8903 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -20,22 +20,11 @@ false - - bin\Debug\netcoreapp2.2\Swagger.xml - 1701;1702;1705;1591; - - - - - bin\Release\netcoreapp2.2\Swagger.xml - 1701;1702;1705;1591; - TRACE;RELEASE;NETCOREAPP2_0 - @@ -72,7 +61,6 @@ - @@ -97,13 +85,6 @@ - - - Always - - - -