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.Inspection (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
skolima committed May 17, 2020
1 parent 1595056 commit 27d299e
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 1 deletion.
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/Files/FolderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public FolderFactory(INuKeeperLogger logger)
/// <returns></returns>
public static IEnumerable<DirectoryInfo> GetTempDirsToCleanup(DirectoryInfo nukeeperTemp)
{
if (nukeeperTemp == null)
{
throw new ArgumentNullException(nameof(nukeeperTemp));
}

var dirs = nukeeperTemp.Exists ? nukeeperTemp.EnumerateDirectories() : Enumerable.Empty<DirectoryInfo>();
var filterDatetime = DateTime.Now.AddHours(-1);
return dirs.Where(d =>
Expand Down
11 changes: 11 additions & 0 deletions NuKeeper.Inspection/Logging/LogData.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using NuKeeper.Abstractions.Logging;

namespace NuKeeper.Inspection.Logging
Expand All @@ -12,6 +13,16 @@ public static class LoggerExtensions
{
public static void Log(this INuKeeperLogger logger, LogData data)
{
if (data == null)
{
throw new ArgumentNullException(nameof(data));
}

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

if (!string.IsNullOrWhiteSpace(data.Terse))
{
logger.Minimal(data.Terse);
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/NuGetApi/ApiPackageLookup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using NuGet.Packaging.Core;
using NuKeeper.Abstractions;
Expand All @@ -22,6 +23,11 @@ public async Task<PackageLookupResult> FindVersionUpdate(
VersionChange allowedChange,
UsePrerelease usePrerelease)
{
if (package == null)
{
throw new ArgumentNullException(nameof(package));
}

var includePrerelease = ShouldAllowPrerelease(package, usePrerelease);

var foundVersions = await _packageVersionsLookup.Lookup(package.Id, includePrerelease, sources);
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/NuGetApi/NuGetLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public NuGetLogger(INuKeeperLogger logger)

public override void Log(ILogMessage message)
{
if (message == null)
{
throw new ArgumentNullException(nameof(message));
}

switch (message.Level)
{
case LogLevel.Verbose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public PackageLookupResultReporter(INuKeeperLogger logger)

public void Report(PackageLookupResult lookupResult)
{
var highestVersion = lookupResult.Major?.Identity?.Version;
var highestVersion = lookupResult?.Major?.Identity?.Version;
if (highestVersion == null)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/NuGetApi/PackageVersionsLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public async Task<IReadOnlyCollection<PackageSearchMetadata>> Lookup(
string packageName, bool includePrerelease,
NuGetSources sources)
{
if (sources == null)
{
throw new ArgumentNullException(nameof(sources));
}

var tasks = sources.Items.Select(s => RunFinderForSource(packageName, includePrerelease, s));

var results = await Task.WhenAll(tasks);
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/PackagesFoundLogger.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 NuKeeper.Abstractions.Formats;
Expand All @@ -10,6 +11,11 @@ public static class PackagesFoundLogger
{
public static LogData Log(IReadOnlyCollection<PackageInProject> packages)
{
if (packages == null)
{
throw new ArgumentNullException(nameof(packages));
}

var projectPathCount = packages
.Select(p => p.Path)
.Distinct()
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/Report/Formats/CsvReportFormat.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 NuGet.Versioning;
Expand All @@ -18,6 +19,11 @@ public CsvReportFormat(IReportWriter writer)

public void Write(string name, IReadOnlyCollection<PackageUpdateSet> updates)
{
if (updates == null)
{
throw new ArgumentNullException(nameof(updates));
}

WriteHeading();

foreach (var update in updates)
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/Report/Formats/Description.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public static class Description
{
public static string ForUpdateSet(PackageUpdateSet update)
{
if (update == null)
{
throw new ArgumentNullException(nameof(update));
}

var occurrences = update.CurrentPackages.Count;
var versionsInUse = update.CurrentPackages
.Select(p => p.Version)
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/Report/Formats/MetricsReportFormat.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 NuGet.Versioning;
Expand All @@ -17,6 +18,11 @@ public MetricsReportFormat(IReportWriter writer)

public void Write(string name, IReadOnlyCollection<PackageUpdateSet> updates)
{
if (updates == null)
{
throw new ArgumentNullException(nameof(updates));
}

_writer.WriteLine($"Packages with updates: {updates.Count}");
WriteMajorMinorPatchCount(updates);
WriteProjectCount(updates);
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/Report/Formats/TextReportFormat.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using NuKeeper.Abstractions.RepositoryInspection;

Expand All @@ -14,6 +15,11 @@ public TextReportFormat(IReportWriter writer)

public void Write(string name, IReadOnlyCollection<PackageUpdateSet> updates)
{
if (updates == null)
{
throw new ArgumentNullException(nameof(updates));
}

_writer.WriteLine(MessageForCount(updates.Count));

foreach (var update in updates)
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/Report/Reporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public void Report(
string fileName,
IReadOnlyCollection<PackageUpdateSet> updates)
{
if (updates == null)
{
throw new ArgumentNullException(nameof(updates));
}

var destinationDesc = destination == OutputDestination.File ?
$" File '{fileName}'" :
destination.ToString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using NuKeeper.Abstractions.Logging;
using NuKeeper.Abstractions.NuGet;
Expand All @@ -19,6 +20,11 @@ public PackageInProject Read(
PackagePath path,
IEnumerable<string> projectReferences)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}

if (string.IsNullOrWhiteSpace(id))
{
_logger.Normal($"Skipping package with no id specified in file '{path.FullName}'.");
Expand Down
5 changes: 5 additions & 0 deletions NuKeeper.Inspection/Sort/TopologicalSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public TopologicalSort(INuKeeperLogger logger, Func<T, T, bool> match)
public IEnumerable<T> Sort(
IReadOnlyCollection<SortItemData<T>> inputMap)
{
if (inputMap == null)
{
throw new ArgumentNullException(nameof(inputMap));
}

var inputItems = inputMap
.Select(i => i.Item)
.ToList();
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/Sources/NuGetConfigFileReader.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 NuGet.Configuration;
Expand All @@ -18,6 +19,11 @@ public NuGetConfigFileReader(INuKeeperLogger logger)

public NuGetSources ReadNugetSources(IFolder workingFolder)
{
if (workingFolder == null)
{
throw new ArgumentNullException(nameof(workingFolder));
}

var settings = Settings.LoadDefaultSettings(workingFolder.FullPath);

foreach (var file in settings.GetConfigFilePaths())
Expand Down
6 changes: 6 additions & 0 deletions NuKeeper.Inspection/UpdatesLogger.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using NuKeeper.Abstractions.RepositoryInspection;
Expand All @@ -9,6 +10,11 @@ public static class UpdatesLogger
{
public static LogData Log(IReadOnlyCollection<PackageUpdateSet> updates)
{
if (updates == null)
{
throw new ArgumentNullException(nameof(updates));
}

var headline = $"Found {updates.Count} possible updates";
var details = new StringBuilder();

Expand Down

0 comments on commit 27d299e

Please sign in to comment.