Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Fix CA1062 in NuKeeper.Update (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
skolima committed May 18, 2020
1 parent 7a0b057 commit 37b937d
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 2 deletions.
15 changes: 15 additions & 0 deletions NuKeeper.Update/Process/DotNetUpdatePackageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ public DotNetUpdatePackageCommand(IExternalProcess externalProcess)
public async Task Invoke(PackageInProject currentPackage,
NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

if (packageSource == null)
{
throw new ArgumentNullException(nameof(packageSource));
}

if (allSources == null)
{
throw new ArgumentNullException(nameof(allSources));
}

var projectPath = currentPackage.Path.Info.DirectoryName;
var projectFileName = currentPackage.Path.Info.Name;
var sourceUrl = UriEscapedForArgument(packageSource.SourceUri);
Expand Down
16 changes: 16 additions & 0 deletions NuKeeper.Update/Process/NuGetFileRestoreCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
Expand Down Expand Up @@ -31,6 +32,16 @@ public NuGetFileRestoreCommand(

public async Task Invoke(FileInfo file, NuGetSources sources)
{
if (file == null)
{
throw new ArgumentNullException(nameof(file));
}

if (sources == null)
{
throw new ArgumentNullException(nameof(sources));
}

_logger.Normal($"Nuget restore on {file.DirectoryName} {file.Name}");

var nuget = _nuGetPath.Executable;
Expand Down Expand Up @@ -83,6 +94,11 @@ public async Task Invoke(FileInfo file, NuGetSources sources)
public async Task Invoke(PackageInProject currentPackage,
NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

await Invoke(currentPackage.Path.Info, allSources);
}
}
Expand Down
11 changes: 11 additions & 0 deletions NuKeeper.Update/Process/NuGetUpdatePackageCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using NuGet.Configuration;
Expand Down Expand Up @@ -31,6 +32,16 @@ public NuGetUpdatePackageCommand(
public async Task Invoke(PackageInProject currentPackage,
NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

if (allSources == null)
{
throw new ArgumentNullException(nameof(allSources));
}

var projectPath = currentPackage.Path.Info.DirectoryName;

var nuget = _nuGetPath.Executable;
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Update/Process/SolutionsRestore.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -18,6 +19,11 @@ public SolutionsRestore(IFileRestoreCommand fileRestoreCommand)

public async Task CheckRestore(IEnumerable<PackageUpdateSet> targetUpdates, IFolder workingFolder, NuGetSources sources)
{
if (workingFolder == null)
{
throw new ArgumentNullException(nameof(workingFolder));
}

if (AnyProjectRequiresNuGetRestore(targetUpdates))
{
await Restore(workingFolder, sources);
Expand Down
10 changes: 10 additions & 0 deletions NuKeeper.Update/Process/UpdateDirectoryBuildTargetsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public UpdateDirectoryBuildTargetsCommand(INuKeeperLogger logger)
public Task Invoke(PackageInProject currentPackage, NuGetVersion newVersion, PackageSource packageSource,
NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

if (newVersion == null)
{
throw new ArgumentNullException(nameof(newVersion));
}

XDocument xml;
using (var xmlInput = File.OpenRead(currentPackage.Path.FullName))
{
Expand Down
12 changes: 11 additions & 1 deletion NuKeeper.Update/Process/UpdateNuspecCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -7,7 +8,6 @@
using NuKeeper.Abstractions.Logging;
using NuKeeper.Abstractions.NuGet;
using NuKeeper.Abstractions.RepositoryInspection;
using NuKeeper.Inspection.RepositoryInspection;

namespace NuKeeper.Update.Process
{
Expand All @@ -23,6 +23,16 @@ public UpdateNuspecCommand(INuKeeperLogger logger)
public Task Invoke(PackageInProject currentPackage,
NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

if (newVersion == null)
{
throw new ArgumentNullException(nameof(newVersion));
}

XDocument xml;
using (var xmlInput = File.OpenRead(currentPackage.Path.FullName))
{
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Update/Process/UpdateProjectImportsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class UpdateProjectImportsCommand : IUpdateProjectImportsCommand
public Task Invoke(PackageInProject currentPackage,
NuGetVersion newVersion, PackageSource packageSource, NuGetSources allSources)
{
if (currentPackage == null)
{
throw new ArgumentNullException(nameof(currentPackage));
}

var projectsToUpdate = new Stack<string>();
projectsToUpdate.Push(currentPackage.Path.FullName);

Expand Down
8 changes: 7 additions & 1 deletion NuKeeper.Update/Selection/UpdateSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public IReadOnlyCollection<PackageUpdateSet> Filter(
IReadOnlyCollection<PackageUpdateSet> candidates,
FilterSettings settings)
{
_settings = settings;
_settings = settings ?? throw new ArgumentNullException(nameof(settings));

if (candidates == null)
{
throw new ArgumentNullException(nameof(candidates));
}

if (settings.MinimumAge != TimeSpan.Zero)
{
_maxPublishedDate = DateTime.UtcNow.Subtract(settings.MinimumAge);
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Update/UpdateRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public UpdateRunner(

public async Task Update(PackageUpdateSet updateSet, NuGetSources sources)
{
if (updateSet == null)
{
throw new ArgumentNullException(nameof(updateSet));
}

var sortedUpdates = Sort(updateSet.CurrentPackages);

_logger.Detailed($"Updating '{updateSet.SelectedId}' to {updateSet.SelectedVersion} in {sortedUpdates.Count} projects");
Expand Down

0 comments on commit 37b937d

Please sign in to comment.