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

Address a targeted set of analyzer warnings #901

Merged
merged 11 commits into from
Jan 28, 2025
Merged
16 changes: 8 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ stylecop.documentation.xmlHeader = false

# SA1623: Property summary documentation must match accessors
# Justification: It's noise to start a summary with "Gets" or "Sets"
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md
dotnet_diagnostic.SA1623.severity = none

# CA1859: Use concrete types when possible
Expand Down Expand Up @@ -543,7 +543,7 @@ dotnet_diagnostic.SA1204.severity = suggestion

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1207.md
# SA1207: Member attributes should follow the order
dotnet_diagnostic.SA1207.severity = suggestion
dotnet_diagnostic.SA1207.severity = error

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1214.md
# SA1214: Readonly fields must appear before non-readonly fields
Expand Down Expand Up @@ -615,11 +615,11 @@ dotnet_diagnostic.SA1622.severity = suggestion

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1625.md
# SA1625: Element documentation should not be copied and pasted
dotnet_diagnostic.SA1625.severity = suggestion
dotnet_diagnostic.SA1625.severity = error

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1626.md
# SA1626: Single-line comments should not use documentation style slashes
dotnet_diagnostic.SA1626.severity = suggestion
dotnet_diagnostic.SA1626.severity = error

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1627.md
# SA1627: Documentation text should not be empty
Expand All @@ -631,7 +631,7 @@ dotnet_diagnostic.SA1629.severity = suggestion

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md
# SA1633: File should have header
dotnet_diagnostic.SA1633.severity = suggestion
dotnet_diagnostic.SA1633.severity = error

# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1642.md
# SA1642: Constructor summary documentation should begin with standard text
Expand Down Expand Up @@ -676,7 +676,7 @@ dotnet_diagnostic.CA1032.severity = suggestion

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1040
# CA1040: Avoid empty interfaces
dotnet_diagnostic.CA1040.severity = suggestion
dotnet_diagnostic.CA1040.severity = error

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1041
# CA1041: Provide ObsoleteAttribute message
Expand Down Expand Up @@ -752,7 +752,7 @@ dotnet_diagnostic.CA1311.severity = suggestion

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1508
# CA1508: Avoid dead conditional code
dotnet_diagnostic.CA1508.severity = suggestion
dotnet_diagnostic.CA1508.severity = error

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1510
# CA1510: Use '...' instead of explicitly throwing a new exception instance
Expand Down Expand Up @@ -952,7 +952,7 @@ dotnet_diagnostic.CS8632.severity = suggestion

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0005
# IDE0005: Using directive is unnecessary
dotnet_diagnostic.IDE0005.severity = suggestion
dotnet_diagnostic.IDE0005.severity = error

# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0009
# IDE0009: Add 'this' or 'Me' qualification
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Sbom.Api/Config/ApiConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static class ApiConfigurationBuilder
/// </summary>
/// <param name="rootPath">Path where package exists. If scanning start here.</param>
/// <param name="manifestDirPath">Output path to where manifest is generated.</param>
/// <param name="files">Use null to scan.</param>
/// <param name="packages">Use null to scan.</param>
/// <param name="files">Use null to scan all files.</param>
/// <param name="packages">Use null to scan all packages.</param>
/// <param name="metadata"></param>
/// <param name="specifications"></param>
/// <param name="runtimeConfiguration"></param>
Expand Down
4 changes: 0 additions & 4 deletions src/Microsoft.Sbom.Api/Config/Args/FormatValidationArgs.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Extensions.Entities;
using PowerArgs;

namespace Microsoft.Sbom.Api.Config.Args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Generic;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Extensions.Entities;
using PowerArgs;
using Serilog.Events;

namespace Microsoft.Sbom.Api.Config.Args;

Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Api/Config/ConfigFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Sbom.Common;
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.Sbom.Api/Config/ConfigPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using AutoMapper;
using Microsoft.Sbom.Api.Output.Telemetry;
using Microsoft.Sbom.Common;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Common.Config.Attributes;
using Microsoft.Sbom.Common.Config.Validators;
using Microsoft.Sbom.Common.Utils;
using PowerArgs;
Expand Down
4 changes: 0 additions & 4 deletions src/Microsoft.Sbom.Api/Config/ConfigSanitizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.Sbom.Api.Executors;
using Microsoft.Sbom.Api.Hashing;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Common.Config.Attributes;
using Microsoft.Sbom.Common.Utils;
using Microsoft.Sbom.Contracts.Enums;
using Microsoft.Sbom.Extensions.Entities;
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Sbom.Api/Config/ISbomService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace Microsoft.Sbom.Api.Config;
/// Marker interface for an SBOM service.
/// </summary>
/// <typeparam name="T">The type of arguments against which this service is run.</typeparam>
#pragma warning disable CA1040 // Avoid empty interfaces
public interface ISbomService<T>
#pragma warning restore CA1040 // Avoid empty interfaces
where T : CommonArgs
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ConfigurationSetting<bool> Convert(bool? sourceMember, ResolutionContext
return new ConfigurationSetting<bool>
{
Source = settingSource,
Value = sourceMember ?? false
Value = sourceMember.Value
};
}
}
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Api/Executors/EnumeratorChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Api.Output.Telemetry;
using Microsoft.Sbom.JsonAsynchronousNodeKit.Exceptions;
using Serilog;

Expand Down
11 changes: 0 additions & 11 deletions src/Microsoft.Sbom.Api/Executors/FileHasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.Sbom.Api.Manifest;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Contracts;
using Microsoft.Sbom.Contracts.Enums;
using Microsoft.Sbom.Entities;
using Microsoft.Sbom.Extensions;
Expand Down Expand Up @@ -73,16 +72,6 @@ public FileHasher(
ManifestGeneratorProvider manifestGeneratorProvider,
IFileTypeUtils fileTypeUtils)
{
if (configuration is null)
{
throw new ArgumentNullException(nameof(configuration));
}

if (manifestGeneratorProvider is null)
{
throw new ArgumentNullException(nameof(manifestGeneratorProvider));
}

this.hashCodeGenerator = hashCodeGenerator ?? throw new ArgumentNullException(nameof(hashCodeGenerator));
this.manifestPathConverter = manifestPathConverter ?? throw new ArgumentNullException(nameof(manifestPathConverter));
this.log = log ?? throw new ArgumentNullException(nameof(log));
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Api/Executors/FileListEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Channels;
using System.Threading.Tasks;
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Api/Executors/HashValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Contracts;
using Microsoft.Sbom.Extensions.Entities;

namespace Microsoft.Sbom.Api.Executors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Contracts.BcdeModels;

namespace Microsoft.Sbom.Api.Executors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Channels;
using System.Threading.Tasks;
using Microsoft.Sbom.Api.Manifest;
using Microsoft.Sbom.Extensions;
using Microsoft.Sbom.Extensions.Entities;

namespace Microsoft.Sbom.Api.Executors;
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Sbom.Api/FormatValidator/ValidatedSBOM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ private FormatValidationResults Validate()
return ValidationDetails;
}

if (SPDXVersionParser.VersionMatchesRequiredVersion(sbom?.Version, requiredSpdxMajorVersion))
if (SPDXVersionParser.VersionMatchesRequiredVersion(sbom.Version, requiredSpdxMajorVersion))
{
ValidationDetails.AggregateValidationStatus(FormatValidationStatus.Valid);
return ValidationDetails;
}

ValidationDetails.AggregateValidationStatus(FormatValidationStatus.NotValid);
ValidationDetails.Errors.Add($"SBOM version {sbom?.Version} is not recognized as SPDX major version 2.");
ValidationDetails.Errors.Add($"SBOM version {sbom.Version} is not recognized as SPDX major version 2.");
return ValidationDetails;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.Sbom.Api.Output.Telemetry;
using Microsoft.Sbom.Common;
using Serilog;
using File = System.IO.File;

namespace Microsoft.Sbom.Api.PackageDetails;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.ComponentDetection.Contracts.BcdeModels;
using Microsoft.Sbom.Api.Converters;
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Api.Exceptions;
using Microsoft.Sbom.Api.Executors;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common.Config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Channels;
using Microsoft.Sbom.Api.Converters;
using Microsoft.Sbom.Api.Entities;
using Microsoft.Sbom.Api.Exceptions;
using Microsoft.Sbom.Api.Executors;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common.Config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Microsoft.ComponentDetection.Contracts.BcdeModels;
using Microsoft.ComponentDetection.Orchestrator.Commands;
using Serilog;
using Spectre.Console.Cli;

namespace Microsoft.Sbom.Api.Utils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.Sbom.Api.Providers;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Extensions;
using Microsoft.Sbom.Extensions.Entities;
using Serilog;

namespace Microsoft.Sbom.Api.Workflows.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Sbom.Api.FormatValidator;
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Common/Config/IConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Sbom.Common.Config.Attributes;
using Microsoft.Sbom.Contracts;
using Microsoft.Sbom.Contracts.Enums;
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Common/FileSystemUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public abstract class FileSystemUtils : IFileSystemUtils
public string JoinPaths(string root, string relativePath, string secondRelativePath) =>
Path.Join(root, relativePath, secondRelativePath);

/// <inheritdoc />
/// <inheritdoc />
public string GetRelativePath(string relativeTo, string path) => Path.GetRelativePath(relativeTo, path);

Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Sbom.Common/GeneratorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
namespace Microsoft.Sbom.Common;

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Sbom.Contracts;
using Microsoft.Sbom.Contracts.Enums;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Sbom.Extensions;
using Microsoft.Sbom.Extensions.Entities;
using HashAlgorithmName = Microsoft.Sbom.Contracts.Enums.AlgorithmName;

namespace Microsoft.Sbom.Common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.ComponentDetection.Orchestrator;
using Microsoft.ComponentDetection.Orchestrator.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Sbom.Api;
using Microsoft.Sbom.Api.Config;
Expand Down Expand Up @@ -41,7 +40,6 @@
using Serilog.Extensions.Logging;
using Serilog.Filters;
using Constants = Microsoft.Sbom.Api.Utils.Constants;
using IComponentDetector = Microsoft.ComponentDetection.Contracts.IComponentDetector;
using ILogger = Serilog.ILogger;

namespace Microsoft.Sbom.Extensions.DependencyInjection;
Expand Down Expand Up @@ -105,7 +103,7 @@ public static IServiceCollection AddSbomTool(this IServiceCollection services, L
.AddTransient<RelationshipGenerator>()
.AddTransient<ConfigSanitizer>()
.AddTransient<IProcessExecutor, ProcessExecutor>()
.AddTransient<Api.Utils.IComponentDetector, ComponentDetector>()
.AddTransient<IComponentDetector, ComponentDetector>()
.AddTransient<IMetadataBuilderFactory, MetadataBuilderFactory>()
.AddTransient<FileInfoWriter>()
.AddTransient<ComponentToExternalReferenceInfoConverter>()
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Extensions/Entities/ManifestInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Sbom.Extensions.Entities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Runtime.Serialization;

namespace Microsoft.Sbom.Extensions.Exceptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Text.Json.Serialization;
using Microsoft.Sbom.Parsers.Spdx22SbomParser.Entities.Enums;

namespace Microsoft.Sbom.Parsers.Spdx22SbomParser.Entities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Microsoft.Sbom.Parsers.Spdx22SbomParser.Entities;

using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Runtime.Serialization;

namespace Microsoft.Sbom.Parsers.Spdx22SbomParser.Exceptions;

Expand Down
Loading