Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Commit 0675741

Browse files
authored
Merge pull request #25 from mark-monteiro/document-parameters
Fix StyleCop Issues - Document Parameters
2 parents 116d2ee + 82c5e36 commit 0675741

27 files changed

+368
-30
lines changed

Emby.AutoOrganize/Api/FileOrganizationService.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2+
13
using System.Collections.Generic;
24
using System.Diagnostics.CodeAnalysis;
35
using System.Threading.Tasks;

Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Globalization;
45
using System.IO;
56
using System.Linq;
@@ -8,7 +9,6 @@
89
using Emby.AutoOrganize.Model;
910
using Emby.Naming.Common;
1011
using Emby.Naming.TV;
11-
using MediaBrowser.Controller.Configuration;
1212
using MediaBrowser.Controller.Dto;
1313
using MediaBrowser.Controller.Entities;
1414
using MediaBrowser.Controller.Entities.TV;
@@ -23,6 +23,9 @@
2323

2424
namespace Emby.AutoOrganize.Core
2525
{
26+
/// <summary>
27+
/// Service to use for organizing episode media files.
28+
/// </summary>
2629
public class EpisodeFileOrganizer
2730
{
2831
private readonly ILibraryMonitor _libraryMonitor;
@@ -34,6 +37,10 @@ public class EpisodeFileOrganizer
3437

3538
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
3639

40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="EpisodeFileOrganizer"/> class.
42+
/// </summary>
43+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter types/names are self-documenting")]
3744
public EpisodeFileOrganizer(
3845
IFileOrganizationService organizationService,
3946
IFileSystem fileSystem,
@@ -66,6 +73,13 @@ private NamingOptions GetNamingOptionsInternal()
6673

6774
private FileOrganizerType CurrentFileOrganizerType => FileOrganizerType.Episode;
6875

76+
/// <summary>
77+
/// Organize an episode file.
78+
/// </summary>
79+
/// <param name="path">The path to the episode file.</param>
80+
/// <param name="options">The options to use for organizing the file.</param>
81+
/// <param name="cancellationToken">Cancellation token for the operation.</param>
82+
/// <returns>A task representing the file organization operation and containing the operation result.</returns>
6983
public async Task<FileOrganizationResult> OrganizeEpisodeFile(
7084
string path,
7185
TvFileOrganizationOptions options,
@@ -306,6 +320,13 @@ private async Task<Series> CreateNewSeries(
306320
return series;
307321
}
308322

323+
/// <summary>
324+
/// Organize an episode file with parameters provided by the end-user.
325+
/// </summary>
326+
/// <param name="request">The parameters provided by the user via API request.</param>
327+
/// <param name="options">The organization options to use.</param>
328+
/// <param name="cancellationToken">A cancellation token for the operation.</param>
329+
/// <returns>A task representing the organization operation and containing the operation result.</returns>
309330
public async Task<FileOrganizationResult> OrganizeWithCorrection(
310331
EpisodeFileOrganizationRequest request,
311332
TvFileOrganizationOptions options,

Emby.AutoOrganize/Core/Extensions.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ public static class ConfigurationExtension
2121
/// <summary>
2222
/// Perform a one-time migration of smart match info from the plugin configuration to the SQLite database.
2323
/// </summary>
24-
[SuppressMessage("Compiler", "CS0618:Type or member is obsolete", Justification = "This method is used to migrates configuration away from the obsolete property.")]
24+
/// <param name="manager">The manager to use for migrating the configuration.</param>
25+
/// <param name="service">The file organization service to use to save the migrated <see cref="SmartMatchResult"/> records.</param>
2526
public static void ConvertSmartMatchInfo(this IConfigurationManager manager, IFileOrganizationService service)
2627
{
2728
var options = manager.GetConfiguration<AutoOrganizeOptions>(AutoOrganizeOptionsKey);
2829
if (!options.Converted)
2930
{
3031
options.Converted = true;
3132

33+
#pragma warning disable CS0618 // Type or member is obsolete
3234
foreach (SmartMatchInfo optionsSmartMatchInfo in options.SmartMatchInfos)
35+
#pragma warning restore CS0618 // Type or member is obsolete
3336
{
3437
var result = new SmartMatchResult
3538
{

Emby.AutoOrganize/Core/FileOrganizationService.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Concurrent;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Globalization;
45
using System.Linq;
56
using System.Threading;
@@ -18,6 +19,7 @@
1819

1920
namespace Emby.AutoOrganize.Core
2021
{
22+
/// <inheritdoc/>
2123
public class FileOrganizationService : IFileOrganizationService
2224
{
2325
private readonly ITaskManager _taskManager;
@@ -33,6 +35,7 @@ public class FileOrganizationService : IFileOrganizationService
3335
/// <summary>
3436
/// Initializes a new instance of the <see cref="FileOrganizationService"/> class.
3537
/// </summary>
38+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter names/types are self-documenting.")]
3639
public FileOrganizationService(
3740
ITaskManager taskManager,
3841
IFileOrganizationRepository repo,

Emby.AutoOrganize/Core/IFileOrganizationService.cs

+15
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@
77

88
namespace Emby.AutoOrganize.Core
99
{
10+
/// <summary>
11+
/// A service that can be used to auto-organize media files.
12+
/// </summary>
1013
public interface IFileOrganizationService
1114
{
15+
/// <summary>
16+
/// Occurs when a new <see cref="FileOrganizationResult"/> record has been created.
17+
/// </summary>
1218
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemAdded;
1319

20+
/// <summary>
21+
/// Occurs when a <see cref="FileOrganizationResult"/> record has been updated.
22+
/// </summary>
1423
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemUpdated;
1524

25+
/// <summary>
26+
/// Occurs when a <see cref="FileOrganizationResult"/> record has been deleted.
27+
/// </summary>
1628
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemRemoved;
1729

30+
/// <summary>
31+
/// Occurs when multiple <see cref="FileOrganizationResult"/> records are deleted.
32+
/// </summary>
1833
event EventHandler LogReset;
1934

2035
/// <summary>

Emby.AutoOrganize/Core/MovieFileOrganizer.cs

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Globalization;
45
using System.IO;
56
using System.Linq;
@@ -19,6 +20,9 @@
1920

2021
namespace Emby.AutoOrganize.Core
2122
{
23+
/// <summary>
24+
/// Service used for organizing movie media files.
25+
/// </summary>
2226
public class MovieFileOrganizer
2327
{
2428
private readonly ILibraryMonitor _libraryMonitor;
@@ -32,6 +36,7 @@ public class MovieFileOrganizer
3236
/// <summary>
3337
/// Initializes a new instance of the <see cref="MovieFileOrganizer"/> class.
3438
/// </summary>
39+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter types/names are self-documenting")]
3540
public MovieFileOrganizer(
3641
IFileOrganizationService organizationService,
3742
IFileSystem fileSystem,
@@ -50,6 +55,14 @@ public MovieFileOrganizer(
5055

5156
private FileOrganizerType CurrentFileOrganizerType => FileOrganizerType.Movie;
5257

58+
/// <summary>
59+
/// Organize a movie media file.
60+
/// </summary>
61+
/// <param name="path">The filepath of the movie.</param>
62+
/// <param name="options">The organize options to use.</param>
63+
/// <param name="overwriteExisting">If true, any existing file at the same destination path will be overwritten.</param>
64+
/// <param name="cancellationToken">A cancellation token for the operation.</param>
65+
/// <returns>A task representing the operation completion and containing the operation result.</returns>
5366
public async Task<FileOrganizationResult> OrganizeMovieFile(
5467
string path,
5568
MovieFileOrganizationOptions options,
@@ -162,6 +175,13 @@ private Movie CreateNewMovie(MovieFileOrganizationRequest request, FileOrganizat
162175
return movie;
163176
}
164177

178+
/// <summary>
179+
/// Organize a movie media file with user-supplied parameters.
180+
/// </summary>
181+
/// <param name="request">The user supplied parameters provided via API request.</param>
182+
/// <param name="options">The organize options to use.</param>
183+
/// <param name="cancellationToken">A cancellation token for the operation.</param>
184+
/// <returns>A task representing the operation completion and containing the operation result.</returns>
165185
public async Task<FileOrganizationResult> OrganizeWithCorrection(MovieFileOrganizationRequest request, MovieFileOrganizationOptions options, CancellationToken cancellationToken)
166186
{
167187
var result = _organizationService.GetResult(request.ResultId);

Emby.AutoOrganize/Core/MovieFolderOrganizer.cs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.IO;
45
using System.Linq;
56
using System.Threading;
@@ -13,6 +14,9 @@
1314

1415
namespace Emby.AutoOrganize.Core
1516
{
17+
/// <summary>
18+
/// Service used to organize all files in the movie watch folders.
19+
/// </summary>
1620
public class MovieFolderOrganizer
1721
{
1822
private readonly ILibraryMonitor _libraryMonitor;
@@ -23,6 +27,10 @@ public class MovieFolderOrganizer
2327
private readonly IServerConfigurationManager _config;
2428
private readonly IProviderManager _providerManager;
2529

30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="MovieFolderOrganizer"/> class.
32+
/// </summary>
33+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter types/names are self-documenting")]
2634
public MovieFolderOrganizer(
2735
ILibraryManager libraryManager,
2836
ILogger logger,
@@ -41,7 +49,7 @@ public MovieFolderOrganizer(
4149
_providerManager = providerManager;
4250
}
4351

44-
private bool EnableOrganization(FileSystemMetadata fileInfo, MovieFileOrganizationOptions options)
52+
private bool CanOrganize(FileSystemMetadata fileInfo, MovieFileOrganizationOptions options)
4553
{
4654
var minFileBytes = options.MinFileSizeMb * 1024 * 1024;
4755

@@ -73,20 +81,27 @@ private bool IsPathAlreadyInMediaLibrary(string path, List<string> libraryFolder
7381
return libraryFolderPaths.Any(i => string.Equals(i, path, StringComparison.Ordinal) || _fileSystem.ContainsSubPath(i, path));
7482
}
7583

84+
/// <summary>
85+
/// Perform organization for the movie watch folders.
86+
/// </summary>
87+
/// <param name="options">The organization options.</param>
88+
/// <param name="progress">The <see cref="IProgress{T}"/> to use for reporting operation progress.</param>
89+
/// <param name="cancellationToken">A cancellation token for the operation.</param>
90+
/// <returns>A task representing the operation completion.</returns>
7691
public async Task Organize(
7792
MovieFileOrganizationOptions options,
7893
IProgress<double> progress,
7994
CancellationToken cancellationToken)
8095
{
96+
// Get all valid watch locations
8197
var libraryFolderPaths = _libraryManager.GetVirtualFolders().SelectMany(i => i.Locations).ToList();
82-
8398
var watchLocations = options.WatchLocations
8499
.Where(i => IsValidWatchLocation(i, libraryFolderPaths))
85100
.ToList();
86101

87102
var eligibleFiles = watchLocations.SelectMany(GetFilesToOrganize)
88103
.OrderBy(_fileSystem.GetCreationTimeUtc)
89-
.Where(i => EnableOrganization(i, options))
104+
.Where(i => CanOrganize(i, options))
90105
.ToList();
91106

92107
var processedFolders = new HashSet<string>();

Emby.AutoOrganize/Core/NameUtils.cs

+19
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66

77
namespace Emby.AutoOrganize.Core
88
{
9+
/// <summary>
10+
/// Static helper class containing methods to work with names.
11+
/// </summary>
912
public static class NameUtils
1013
{
1114
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
1215

16+
/// <summary>
17+
/// Assign a score to a matched media item.
18+
/// </summary>
19+
/// <param name="sortedName">The sorted name.</param>
20+
/// <param name="year">The sorted year.</param>
21+
/// <param name="itemName">The item name.</param>
22+
/// <param name="itemProductionYear">The item production year.</param>
23+
/// <returns>The calculated score.</returns>
1324
internal static int GetMatchScore(string sortedName, int? year, string itemName, int? itemProductionYear)
1425
{
1526
var score = 0;
@@ -41,6 +52,14 @@ internal static int GetMatchScore(string sortedName, int? year, string itemName,
4152
return score;
4253
}
4354

55+
/// <summary>
56+
/// Assign a score to a matched media item.
57+
/// </summary>
58+
/// <typeparam name="T">The item type.</typeparam>
59+
/// <param name="sortedName">The sorted name.</param>
60+
/// <param name="year">The sorted year.</param>
61+
/// <param name="item">The item.</param>
62+
/// <returns>A tuple containing the item and the calculated score.</returns>
4463
internal static Tuple<T, int> GetMatchScore<T>(string sortedName, int? year, T item)
4564
where T : BaseItem
4665
{

Emby.AutoOrganize/Core/OrganizationException.cs

+10
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44

55
namespace Emby.AutoOrganize.Core
66
{
7+
/// <summary>
8+
/// An generic exception that occurs during file organization.
9+
/// </summary>
710
public class OrganizationException : Exception
811
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="OrganizationException"/> class.
14+
/// </summary>
915
public OrganizationException()
1016
{
1117
}
1218

19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="OrganizationException"/> class with a specified error message.
21+
/// </summary>
22+
/// <param name="msg">The message that describes the error.</param>
1323
public OrganizationException(string msg) : base(msg)
1424
{
1525
}

Emby.AutoOrganize/Core/OrganizerScheduledTask.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Threading;
45
using System.Threading.Tasks;
56
using Emby.AutoOrganize.Model;
@@ -12,6 +13,9 @@
1213

1314
namespace Emby.AutoOrganize.Core
1415
{
16+
/// <summary>
17+
/// A scheduled task that organizes media files.
18+
/// </summary>
1519
public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask
1620
{
1721
private readonly ILibraryMonitor _libraryMonitor;
@@ -24,6 +28,7 @@ public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask
2428
/// <summary>
2529
/// Initializes a new instance of the <see cref="OrganizerScheduledTask"/> class.
2630
/// </summary>
31+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter types/names are self-documenting")]
2732
public OrganizerScheduledTask(ILibraryMonitor libraryMonitor, ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem, IServerConfigurationManager config, IProviderManager providerManager)
2833
{
2934
_libraryMonitor = libraryMonitor;

Emby.AutoOrganize/Core/TvFolderOrganizer.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.IO;
45
using System.Linq;
56
using System.Threading;
@@ -13,6 +14,9 @@
1314

1415
namespace Emby.AutoOrganize.Core
1516
{
17+
/// <summary>
18+
/// Service used to organize all files in the TV watch folders.
19+
/// </summary>
1620
public class TvFolderOrganizer
1721
{
1822
private readonly ILibraryMonitor _libraryMonitor;
@@ -23,6 +27,10 @@ public class TvFolderOrganizer
2327
private readonly IServerConfigurationManager _config;
2428
private readonly IProviderManager _providerManager;
2529

30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="TvFolderOrganizer"/> class.
32+
/// </summary>
33+
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Parameter types/names are self-documenting")]
2634
public TvFolderOrganizer(ILibraryManager libraryManager, ILogger logger, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IFileOrganizationService organizationService, IServerConfigurationManager config, IProviderManager providerManager)
2735
{
2836
_libraryManager = libraryManager;
@@ -66,6 +74,13 @@ private bool IsPathAlreadyInMediaLibrary(string path, List<string> libraryFolder
6674
return libraryFolderPaths.Any(i => string.Equals(i, path, StringComparison.Ordinal) || _fileSystem.ContainsSubPath(i, path));
6775
}
6876

77+
/// <summary>
78+
/// Perform organization for the TV watch folders.
79+
/// </summary>
80+
/// <param name="options">The organization options.</param>
81+
/// <param name="progress">The <see cref="IProgress{T}"/> to use for reporting operation progress.</param>
82+
/// <param name="cancellationToken">A cancellation token for the operation.</param>
83+
/// <returns>A task representing the operation completion.</returns>
6984
public async Task Organize(
7085
TvFileOrganizationOptions options,
7186
IProgress<double> progress,

0 commit comments

Comments
 (0)