Skip to content

Commit

Permalink
chore: SA1000 keywords must be spaced correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Sep 6, 2023
1 parent 63be2d2 commit 626e5a8
Show file tree
Hide file tree
Showing 35 changed files with 117 additions and 121 deletions.
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal ref struct SbomExternalDocumentReferenceParser
private const string ChecksumProperty = "checksum";

private readonly Stream stream;
private readonly SpdxExternalDocumentReference spdxExternalDocumentReference = new ();
private readonly SpdxExternalDocumentReference spdxExternalDocumentReference = new();

public SbomExternalDocumentReferenceParser(Stream stream)
{
Expand Down Expand Up @@ -114,7 +114,7 @@ private void ValidateSbomExternalDocumentReference(SpdxExternalDocumentReference
missingProps.Add(nameof(spdxExternalDocumentReference.ExternalDocumentId));
}

if (spdxExternalDocumentReference.Checksum == null
if (spdxExternalDocumentReference.Checksum == null
|| spdxExternalDocumentReference.Checksum.Algorithm != AlgorithmName.SHA1.Name)
{
missingProps.Add(nameof(spdxExternalDocumentReference.Checksum));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal ref struct SbomFileParser
private const string CopyrightTextProperty = "copyrightText";

private readonly Stream stream;
private readonly SPDXFile sbomFile = new ();
private readonly SPDXFile sbomFile = new();

public SbomFileParser(Stream stream)
{
Expand All @@ -35,7 +35,7 @@ public SbomFileParser(Stream stream)

/// <summary>
/// Parses the SPDX SBOM 'files' array section and generates a <see cref="SBOMFile"/> object for it.
///
///
/// If an object is parsed successfully, the <see cref="sbomFile"/> parameter will have the newly created
/// object.
/// </summary>
Expand Down Expand Up @@ -73,7 +73,7 @@ public long GetSbomFile(ref byte[] buffer, ref Utf8JsonReader reader, out SPDXFi
while (reader.TokenType != JsonTokenType.EndObject)
{
ParseProperty(ref reader, ref buffer);

// Read the end } of this object or the next property name.
ParserUtils.Read(stream, ref buffer, ref reader);
}
Expand All @@ -96,7 +96,7 @@ private void ValidateSbomFile(SPDXFile sbomFile)
// I want to use the DataAnnotations Validator here, but will check with CB first
// before adding a new dependency.
var missingProps = new List<string>();

if (sbomFile.FileChecksums == null || sbomFile.FileChecksums.All(c => c.Algorithm != AlgorithmName.SHA256.Name))
{
missingProps.Add(nameof(sbomFile.FileChecksums));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal ref struct SbomPackageParser
private const string HasFilesProperty = "hasFiles";
private const string ExternalRefsProperty = "externalRefs";
private readonly Stream stream;
private readonly SPDXPackage sbomPackage = new ();
private readonly SPDXPackage sbomPackage = new();

public SbomPackageParser(Stream stream)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ private void ValidateSbomPackage(SPDXPackage sbomPackage)
missingProps.Add(nameof(sbomPackage.Supplier));
}

if (sbomPackage.PackageVerificationCode != null
if (sbomPackage.PackageVerificationCode != null
&& string.IsNullOrWhiteSpace(sbomPackage.PackageVerificationCode.PackageVerificationCodeValue))
{
missingProps.Add(nameof(sbomPackage.PackageVerificationCode));
Expand Down Expand Up @@ -249,7 +249,7 @@ private IList<ExternalReference> ParseExternalReferences(ref Utf8JsonReader read

private ExternalReference ParseExternalReference(ref Utf8JsonReader reader, ref byte[] buffer)
{
ExternalReference reference = new ();
ExternalReference reference = new();

// Read the opening { of the object
ParserUtils.AssertTokenType(stream, ref reader, JsonTokenType.StartObject);
Expand Down Expand Up @@ -302,7 +302,7 @@ private ExternalReference ParseExternalReference(ref Utf8JsonReader reader, ref

private PackageVerificationCode ParsePackageVerificationCodeObject(ref byte[] buffer, ref Utf8JsonReader reader)
{
PackageVerificationCode packageVerificationCode = new ();
PackageVerificationCode packageVerificationCode = new();

// Read the opening { of the object
ParserUtils.AssertTokenType(stream, ref reader, JsonTokenType.StartObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal ref struct SbomRelationshipParser
private const string RelationshipTypeProperty = "relationshipType";

private readonly Stream stream;
private readonly SPDXRelationship sbomRelationship = new ();
private readonly SPDXRelationship sbomRelationship = new();

public SbomRelationshipParser(Stream stream)
{
Expand Down
Loading

0 comments on commit 626e5a8

Please sign in to comment.