Merge pull request #458 from EraYaN/code-cleanup

Clean up several minor issues and add TODOs
This commit is contained in:
Joshua M. Boniface
2019-01-13 12:14:53 -05:00
committed by GitHub
335 changed files with 1680 additions and 2648 deletions

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto;
@@ -46,14 +46,12 @@ namespace MediaBrowser.Controller.Channels
/// Gets the channels internal.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">The cancellation token.</param>
QueryResult<Channel> GetChannelsInternal(ChannelQuery query);
/// <summary>
/// Gets the channels.
/// </summary>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">The cancellation token.</param>
QueryResult<BaseItemDto> GetChannels(ChannelQuery query);
/// <summary>

View File

@@ -187,7 +187,7 @@ namespace MediaBrowser.Controller.Entities
{
if (child == null)
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(child));
}
_virtualChildren.Add(child);
@@ -203,7 +203,7 @@ namespace MediaBrowser.Controller.Entities
{
if (id.Equals(Guid.Empty))
{
throw new ArgumentNullException("id");
throw new ArgumentNullException(nameof(id));
}
foreach (var child in _virtualChildren)

View File

@@ -1139,7 +1139,7 @@ namespace MediaBrowser.Controller.Entities
{
if (item == null)
{
throw new ArgumentNullException("media");
throw new ArgumentNullException(nameof(item));
}
var protocol = item.PathProtocol;
@@ -1756,7 +1756,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException("user");
throw new ArgumentNullException(nameof(user));
}
if (!IsVisibleViaTags(user))
@@ -1906,7 +1906,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException("user");
throw new ArgumentNullException(nameof(user));
}
return IsParentalAllowed(user);
@@ -2087,7 +2087,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
var current = Studios;
@@ -2120,7 +2120,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
var genres = Genres;
@@ -2146,7 +2146,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(user));
}
var data = UserDataManager.GetUserData(user, this);
@@ -2181,7 +2181,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(user));
}
var data = UserDataManager.GetUserData(user, this);
@@ -2579,7 +2579,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException("user");
throw new ArgumentNullException(nameof(user));
}
var userdata = UserDataManager.GetUserData(user, this);

View File

@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("url");
throw new ArgumentNullException(nameof(url));
}
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));

View File

@@ -997,7 +997,7 @@ namespace MediaBrowser.Controller.Entities
{
if (items == null)
{
throw new ArgumentNullException("items");
throw new ArgumentNullException(nameof(items));
}
if (CollapseBoxSetItems(query, queryParent, user, configurationManager))
@@ -1252,7 +1252,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException();
throw new ArgumentNullException(nameof(user));
}
//the true root should return our users root folder children
@@ -1332,7 +1332,7 @@ namespace MediaBrowser.Controller.Entities
{
if (user == null)
{
throw new ArgumentNullException("user");
throw new ArgumentNullException(nameof(user));
}
var result = new Dictionary<Guid, BaseItem>();

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,12 +11,12 @@ namespace MediaBrowser.Controller.Entities
{
if (person == null)
{
throw new ArgumentNullException("person");
throw new ArgumentNullException(nameof(person));
}
if (string.IsNullOrEmpty(person.Name))
{
throw new ArgumentNullException();
throw new ArgumentException("The person's name was empty or null.", nameof(person));
}
// Normalize
@@ -103,7 +103,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
foreach (var i in people)

View File

@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}
var current = item.Tags;

View File

@@ -182,7 +182,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(newName))
{
throw new ArgumentNullException("newName");
throw new ArgumentNullException(nameof(newName));
}
// If only the casing is changing, leave the file system alone
@@ -259,7 +259,7 @@ namespace MediaBrowser.Controller.Entities
{
if (string.IsNullOrEmpty(username))
{
throw new ArgumentNullException("username");
throw new ArgumentNullException(nameof(username));
}
var safeFolderName = FileSystem.GetValidFilename(username);

View File

@@ -41,7 +41,7 @@ namespace MediaBrowser.Controller.Entities
{
if (value.Value < 0 || value.Value > 10)
{
throw new ArgumentOutOfRangeException("value", "A 0 to 10 rating is required for UserItemData.");
throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemData.");
}
}

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Library;
using MediaBrowser.Model.Querying;
@@ -78,7 +78,7 @@ namespace MediaBrowser.Controller.Entities
return new QueryResult<BaseItem>
{
TotalRecordCount = totalCount,
Items = itemsArray
Items = itemsArray //TODO Fix The co-variant conversion between Folder[] and BaseItem[], this can generate runtime issues.
};
}

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@@ -412,7 +412,7 @@ namespace MediaBrowser.Controller.Entities
{
return new QueryResult<BaseItem>
{
Items = result.Items,
Items = result.Items, //TODO Fix The co-variant conversion between T[] and BaseItem[], this can generate runtime issues if T is not BaseItem.
TotalRecordCount = result.TotalRecordCount
};
}

View File

@@ -46,11 +46,11 @@ namespace MediaBrowser.Controller.IO
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException("path");
throw new ArgumentNullException(nameof(path));
}
if (args == null)
{
throw new ArgumentNullException("args");
throw new ArgumentNullException(nameof(args));
}
var entries = directoryService.GetFileSystemEntries(path);

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
@@ -163,7 +163,6 @@ namespace MediaBrowser.Controller.Library
/// Adds the parts.
/// </summary>
/// <param name="rules">The rules.</param>
/// <param name="pluginFolders">The plugin folders.</param>
/// <param name="resolvers">The resolvers.</param>
/// <param name="introProviders">The intro providers.</param>
/// <param name="itemComparers">The item comparers.</param>
@@ -298,7 +297,7 @@ namespace MediaBrowser.Controller.Library
string name,
Guid parentId,
string viewType,
string sortNamen);
string sortName);
/// <summary>
/// Gets the named view.
@@ -547,4 +546,4 @@ namespace MediaBrowser.Controller.Library
string videoPath,
string[] files);
}
}
}

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using System;
using System.Collections.Generic;
@@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Library
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException();
throw new ArgumentException("The path was empty or null.", nameof(path));
}
if (AdditionalLocations == null)
@@ -190,7 +190,7 @@ namespace MediaBrowser.Controller.Library
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException();
throw new ArgumentException("The name was empty or null.", nameof(name));
}
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name));
@@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Library
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException();
throw new ArgumentException("The path was empty or null.", nameof(path));
}
foreach (var file in FileSystemChildren)

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -1137,7 +1137,7 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary>
/// Gets the number of audio channels to specify on the command line
/// </summary>
/// <param name="request">The request.</param>
/// <param name="state">The state.</param>
/// <param name="audioStream">The audio stream.</param>
/// <param name="outputAudioCodec">The output audio codec.</param>
/// <returns>System.Nullable{System.Int32}.</returns>
@@ -1908,11 +1908,11 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (state == null)
{
throw new ArgumentNullException("state");
throw new ArgumentNullException(nameof(state));
}
if (mediaSource == null)
{
throw new ArgumentNullException("mediaSource");
throw new ArgumentNullException(nameof(mediaSource));
}
var path = mediaSource.Path;

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Extensions;
using System;
using System.Globalization;
using System.IO;
@@ -39,6 +39,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
catch (ObjectDisposedException)
{
//TODO Investigate and properly fix.
// Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
}
catch (Exception ex)

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Threading;
using System.Collections.Generic;
using System.Globalization;
@@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Net
{
if (logger == null)
{
throw new ArgumentNullException("logger");
throw new ArgumentNullException(nameof(logger));
}
Logger = logger;
@@ -65,7 +65,7 @@ namespace MediaBrowser.Controller.Net
{
if (message == null)
{
throw new ArgumentNullException("message");
throw new ArgumentNullException(nameof(message));
}
if (string.Equals(message.MessageType, Name + "Start", StringComparison.OrdinalIgnoreCase))
@@ -269,7 +269,7 @@ namespace MediaBrowser.Controller.Net
}
catch (ObjectDisposedException)
{
//TODO Investigate and properly fix.
}
}
@@ -280,10 +280,13 @@ namespace MediaBrowser.Controller.Net
}
catch (ObjectDisposedException)
{
//TODO Investigate and properly fix.
}
ActiveConnections.Remove(connection);
lock (ActiveConnections)
{
ActiveConnections.Remove(connection);
}
}
/// <summary>

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using System.Collections.Generic;
using System.Threading;
@@ -13,7 +13,6 @@ namespace MediaBrowser.Controller.Persistence
/// Deletes the user.
/// </summary>
/// <param name="user">The user.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
void DeleteUser(User user);

View File

@@ -1,4 +1,5 @@
using System.Reflection;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -7,21 +8,14 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("MediaBrowser.Controller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MediaBrowser.Controller")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyCompany("Jellyfin Project")]
[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")]
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//

View File

@@ -1,4 +1,4 @@
using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Devices;
using MediaBrowser.Model.Querying;
using System.Threading;
@@ -10,7 +10,6 @@ namespace MediaBrowser.Controller.Security
/// Creates the specified information.
/// </summary>
/// <param name="info">The information.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
void Create(AuthenticationInfo info);
@@ -18,7 +17,6 @@ namespace MediaBrowser.Controller.Security
/// Updates the specified information.
/// </summary>
/// <param name="info">The information.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
void Update(AuthenticationInfo info);