Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: SA1028 code must not contain trailing whitespace #363

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,6 @@ dotnet_diagnostic.CA1859.severity = none
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers
##########################################

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md
# SA1000: Keywords should be spaced correctly
dotnet_diagnostic.SA1000.severity = suggestion

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md
# SA1028: Code should not contain trailing whitespace
dotnet_diagnostic.SA1028.severity = suggestion

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1101.md
# SA1101: Prefix local calls with this
dotnet_diagnostic.SA1101.severity = suggestion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class CargoComponentExtensions
/// <summary>
/// Converts a <see cref="CargoComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this CargoComponent cargoComponent) => new ()
public static SbomPackage? ToSbomPackage(this CargoComponent cargoComponent) => new()
{
Id = cargoComponent.Id,
PackageUrl = cargoComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class CondaComponentExtensions
/// <summary>
/// Converts a <see cref="CondaComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this CondaComponent condaComponent) => new ()
public static SbomPackage? ToSbomPackage(this CondaComponent condaComponent) => new()
{
Id = condaComponent.Id,
PackageUrl = condaComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class DockerImageComponentExtensions
/// <summary>
/// Converts a <see cref="DockerImageComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this DockerImageComponent dockerImageComponent) => new ()
public static SbomPackage? ToSbomPackage(this DockerImageComponent dockerImageComponent) => new()
{
Id = dockerImageComponent.Id,
PackageUrl = dockerImageComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class DockerReferenceComponentExtensions
/// <summary>
/// Converts a <see cref="DockerReferenceComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this DockerReferenceComponent dockerReferenceComponent) => new ()
public static SbomPackage? ToSbomPackage(this DockerReferenceComponent dockerReferenceComponent) => new()
{
Id = dockerReferenceComponent.Id,
PackageUrl = dockerReferenceComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class GitComponentExtensions
/// <summary>
/// Converts a <see cref="GitComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this GitComponent gitComponent) => new ()
public static SbomPackage? ToSbomPackage(this GitComponent gitComponent) => new()
{
Id = gitComponent.Id,
PackageName = gitComponent.Id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class GoComponentExtensions
/// <summary>
/// Converts a <see cref="GoComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this GoComponent goComponent) => new ()
public static SbomPackage? ToSbomPackage(this GoComponent goComponent) => new()
{
Id = goComponent.Id,
PackageUrl = goComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class LinuxComponentExtensions
/// <summary>
/// Converts a <see cref="LinuxComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this LinuxComponent linuxComponent) => new ()
public static SbomPackage? ToSbomPackage(this LinuxComponent linuxComponent) => new()
{
Id = linuxComponent.Id,
PackageUrl = linuxComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class MavenComponentExtensions
/// <summary>
/// Converts a <see cref="MavenComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this MavenComponent mavenComponent) => new ()
public static SbomPackage? ToSbomPackage(this MavenComponent mavenComponent) => new()
{
Id = mavenComponent.Id,
PackageName = $"{mavenComponent.GroupId}.{mavenComponent.ArtifactId}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class OtherComponentExtensions
/// <summary>
/// Converts a <see cref="OtherComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this OtherComponent otherComponent) => new ()
public static SbomPackage? ToSbomPackage(this OtherComponent otherComponent) => new()
{
Id = otherComponent.Id,
PackageUrl = otherComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class PipComponentExtensions
/// <summary>
/// Converts a <see cref="PipComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this PipComponent pipComponent) => new ()
public static SbomPackage? ToSbomPackage(this PipComponent pipComponent) => new()
{
Id = pipComponent.Id,
PackageUrl = pipComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class PodComponentExtensions
/// <summary>
/// Converts a <see cref="PodComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this PodComponent podComponent) => new ()
public static SbomPackage? ToSbomPackage(this PodComponent podComponent) => new()
{
Id = podComponent.Id,
PackageUrl = podComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class RubyGemsComponentExtensions
/// <summary>
/// Converts a <see cref="RubyGemsComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this RubyGemsComponent rubyGemsComponent) => new ()
public static SbomPackage? ToSbomPackage(this RubyGemsComponent rubyGemsComponent) => new()
{
Id = rubyGemsComponent.Id,
PackageUrl = rubyGemsComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class SpdxComponentExtensions
/// <summary>
/// Converts a <see cref="SpdxComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this SpdxComponent spdxComponent) => new ()
public static SbomPackage? ToSbomPackage(this SpdxComponent spdxComponent) => new()
{
Id = spdxComponent.Id,
PackageName = spdxComponent.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class VcpkgComponentExtensions
/// <summary>
/// Converts a <see cref="VcpkgComponent"/> to an <see cref="SbomPackage"/>.
/// </summary>
public static SbomPackage? ToSbomPackage(this VcpkgComponent vcpkgComponent) => new ()
public static SbomPackage? ToSbomPackage(this VcpkgComponent vcpkgComponent) => new()
{
Id = vcpkgComponent.Id,
PackageUrl = vcpkgComponent.PackageUrl?.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Microsoft.Sbom.Api.Output.Telemetry;
/// </summary>
public class TelemetryRecorder : IRecorder
{
private readonly ConcurrentBag<TimingRecorder> timingRecorders = new ();
private readonly ConcurrentBag<TimingRecorder> timingRecorders = new();
private readonly IDictionary<ManifestInfo, string> sbomFormats = new Dictionary<ManifestInfo, string>();
private readonly IDictionary<string, object> switches = new Dictionary<string, object>();
private readonly IList<Exception> exceptions = new List<Exception>();
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static class Constants
Version = "1.0.0"
};

public static List<Entities.ErrorType> SkipFailureReportingForErrors = new ()
public static List<Entities.ErrorType> SkipFailureReportingForErrors = new()
{
Entities.ErrorType.ManifestFolder,
Entities.ErrorType.FilteredRootPath,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Workflows/Helpers/FilesValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class FilesValidator
{
private readonly DirectoryWalker directoryWalker;
private readonly IConfiguration configuration;
private readonly ChannelUtils channelUtils = new ();
private readonly ChannelUtils channelUtils = new();
private readonly ILogger log;
private readonly FileHasher fileHasher;
private readonly ManifestFolderFilterer fileFilterer;
Expand Down
64 changes: 32 additions & 32 deletions src/Microsoft.Sbom.Common/Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ namespace Microsoft.Sbom.Common.Config;
[SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "This is the configuration class")]
public class Configuration : IConfiguration
{
private static readonly AsyncLocal<ConfigurationSetting<string>> buildDropPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> buildComponentPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> buildListFile = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> manifestDirPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> manifestPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> outputPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<int>> parallelism = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> configFilePath = new ();
private static readonly AsyncLocal<ConfigurationSetting<IList<ManifestInfo>>> manifestInfo = new ();
private static readonly AsyncLocal<ConfigurationSetting<AlgorithmName>> hashAlgorithm = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> rootFilterPath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> catalogFilePath = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> validateSignature = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> ignoreMissing = new ();
private static readonly AsyncLocal<ManifestToolActions> manifestToolAction = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageName = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageVersion = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageSupplier = new ();
private static readonly AsyncLocal<ConfigurationSetting<IEnumerable<SbomFile>>> filesList = new ();
private static readonly AsyncLocal<ConfigurationSetting<IEnumerable<SbomPackage>>> packagesList = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> telemetryFilePath = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> dockerImagesToScan = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> externalDocumentReferenceListFile = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> additionalComponentDetectorArgs = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> namespaceUriUniquePart = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> namespaceUriBase = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> generationTimestamp = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> followSymlinks = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> fetchLicenseInformation = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> deleteManifestDirIfPresent = new ();
private static readonly AsyncLocal<ConfigurationSetting<bool>> failIfNoPackages = new ();
private static readonly AsyncLocal<ConfigurationSetting<LogEventLevel>> verbosity = new ();
private static readonly AsyncLocal<ConfigurationSetting<string>> buildDropPath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> buildComponentPath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> buildListFile = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> manifestDirPath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> manifestPath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> outputPath = new();
private static readonly AsyncLocal<ConfigurationSetting<int>> parallelism = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> configFilePath = new();
private static readonly AsyncLocal<ConfigurationSetting<IList<ManifestInfo>>> manifestInfo = new();
private static readonly AsyncLocal<ConfigurationSetting<AlgorithmName>> hashAlgorithm = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> rootFilterPath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> catalogFilePath = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> validateSignature = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> ignoreMissing = new();
private static readonly AsyncLocal<ManifestToolActions> manifestToolAction = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageName = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageVersion = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> packageSupplier = new();
private static readonly AsyncLocal<ConfigurationSetting<IEnumerable<SbomFile>>> filesList = new();
private static readonly AsyncLocal<ConfigurationSetting<IEnumerable<SbomPackage>>> packagesList = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> telemetryFilePath = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> dockerImagesToScan = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> externalDocumentReferenceListFile = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> additionalComponentDetectorArgs = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> namespaceUriUniquePart = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> namespaceUriBase = new();
private static readonly AsyncLocal<ConfigurationSetting<string>> generationTimestamp = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> followSymlinks = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> fetchLicenseInformation = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> deleteManifestDirIfPresent = new();
private static readonly AsyncLocal<ConfigurationSetting<bool>> failIfNoPackages = new();
private static readonly AsyncLocal<ConfigurationSetting<LogEventLevel>> verbosity = new();

/// <inheritdoc cref="IConfiguration.BuildDropPath" />
[DirectoryExists]
Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.Sbom.Common/IFileSystemUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ public interface IFileSystemUtils
bool DirectoryExists(string path);

DirectoryInfo CreateDirectory(string path);

IEnumerable<string> GetFilesInDirectory(string path, bool followSymlinks = true);

IEnumerable<string> GetDirectories(string path, bool followSymlinks = true);

Stream OpenRead(string filePath);

Stream OpenWrite(string filePath);

string ReadAllText(string filePath);

void WriteAllText(string filePath, string contents);

string JoinPaths(string root, string relativePath);

string JoinPaths(string root, string relativePath, string secondRelativePath);
Expand All @@ -46,9 +46,9 @@ public interface IFileSystemUtils
string GetDirectoryName(string filePath);

bool DirectoryHasReadPermissions(string directoryPath);

bool DirectoryHasWritePermissions(string directoryPath);

void DeleteFile(string filePath);

/// <summary>
Expand All @@ -71,6 +71,6 @@ public interface IFileSystemUtils
string GetSbomToolTempPath();

string GetFullPath(string path);

DirectoryInfo GetParentDirectory(string path);
}
4 changes: 2 additions & 2 deletions src/Microsoft.Sbom.Contracts/Contracts/Enums/ParserState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.Sbom.Contracts.Enums;

/// <summary>
/// Defines the current state of the SBOM parser.
/// Defines the current state of the SBOM parser.
/// </summary>
public enum ParserState
{
Expand Down Expand Up @@ -40,7 +40,7 @@ public enum ParserState

/// <summary>
/// The parser is in a state where its returned a property that needs to be skipped.
/// This parser will never be in this state externally, internally we will try to move
/// This parser will never be in this state externally, internally we will try to move
/// to the next available state when we reach this state.
/// </summary>
INTERNAL_SKIP,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Contracts/Contracts/Spdx22Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Spdx22Metadata
/// Information about the package this SPDX document represents.
/// </summary>
public IEnumerable<string> DocumentDescribes { get; set; }

/// <summary>
/// The id of the spdx document.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Sbom.Extensions/ISbomParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ public interface ISbomParser
IEnumerable<SBOMReference> GetReferences();

/// <summary>
/// Returns a <see cref="SBOMMetadata"/> object using the metadata defined in the
/// Returns a <see cref="SBOMMetadata"/> object using the metadata defined in the
/// current SBOM.
/// </summary>
/// <param name="stream"></param>
/// <returns></returns>
Spdx22Metadata GetMetadata();

/// <summary>
/// This function is called by the sbom tool upon initialization to get all the
/// This function is called by the sbom tool upon initialization to get all the
/// manifest versions this library can parse.
/// </summary>
/// <returns>An version sorted array in ascending order of
/// <returns>An version sorted array in ascending order of
/// <see cref="ManifestInfo">manifests</see> this library can parse.</returns>
ManifestInfo[] RegisterManifest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
namespace Microsoft.Sbom.Parsers.Spdx22SbomParser.Entities.Enums;

/// <summary>
/// Defines the type of <see cref="SPDXRelationship"/> between the source and the
/// Defines the type of <see cref="SPDXRelationship"/> between the source and the
/// target element.
///
///
/// Full definition here: https://spdx.github.io/spdx-spec/7-relationships-between-SPDX-elements/#71-relationship.
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public ParserException(string message)
{
}

public ParserException(string message, Exception innerException)
public ParserException(string message, Exception innerException)
: base(message, innerException)
{
}

protected ParserException(SerializationInfo info, StreamingContext context)
protected ParserException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.Sbom.Parser;
internal readonly ref struct CreationInfoParser
{
private readonly Stream stream;
private readonly MetadataCreationInfo creationInfo = new ();
private readonly MetadataCreationInfo creationInfo = new();

public CreationInfoParser(Stream stream)
{
Expand All @@ -30,7 +30,7 @@ internal MetadataCreationInfo GetCreationInfo(ref byte[] buffer, ref Utf8JsonRea
{
throw new ArgumentException($"The {nameof(buffer)} value can't be null or of 0 length.");
}

// Read the start { of this object.
ParserUtils.SkipNoneTokens(stream, ref buffer, ref reader);
ParserUtils.AssertTokenType(stream, ref reader, JsonTokenType.StartObject);
Expand Down
Loading