Skip to content

Commit 92cc2ab

Browse files
daniel-akiliDaniel Akili
andauthored
fix: CA1308 (#335)
* CA1002 * CA1308 * pr build check * _ * pr build check2 * CA1308 * fixed conversation suggestions Co-authored-by: Daniel Akili <[email protected]>
1 parent 59a5d57 commit 92cc2ab

File tree

9 files changed

+18
-14
lines changed

9 files changed

+18
-14
lines changed

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,6 @@ dotnet_diagnostic.CA1304.severity = suggestion
609609
# CA1822: Mark members as static
610610
dotnet_diagnostic.CA1822.severity = suggestion
611611

612-
# CA1308: Normalize strings to uppercase
613-
dotnet_diagnostic.CA1308.severity = suggestion
614-
615612
# CA1307: Specify StringComparison for clarity
616613
dotnet_diagnostic.CA1307.severity = suggestion
617614

src/Microsoft.ComponentDetection.Contracts/TypedComponent/LinuxComponent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,27 @@ public override PackageURL PackageUrl
5555

5656
private bool IsUbuntu()
5757
{
58-
return this.Distribution.ToLowerInvariant() == "ubuntu";
58+
return this.Distribution.ToUpperInvariant() == "UBUNTU";
5959
}
6060

6161
private bool IsDebian()
6262
{
63-
return this.Distribution.ToLowerInvariant() == "debian";
63+
return this.Distribution.ToUpperInvariant() == "DEBIAN";
6464
}
6565

6666
private bool IsCentOS()
6767
{
68-
return this.Distribution.ToLowerInvariant() == "centos";
68+
return this.Distribution.ToUpperInvariant() == "CENTOS";
6969
}
7070

7171
private bool IsFedora()
7272
{
73-
return this.Distribution.ToLowerInvariant() == "fedora";
73+
return this.Distribution.ToUpperInvariant() == "FEDORA";
7474
}
7575

7676
private bool IsRHEL()
7777
{
78-
return this.Distribution.ToLowerInvariant() == "red hat enterprise linux";
78+
return this.Distribution.ToUpperInvariant() == "RED HAT ENTERPRISE LINUX";
7979
}
8080
}
8181
}

src/Microsoft.ComponentDetection.Contracts/TypedComponent/PipComponent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics.CodeAnalysis;
12
using PackageUrl;
23

34
namespace Microsoft.ComponentDetection.Contracts.TypedComponent
@@ -21,6 +22,7 @@ public PipComponent(string name, string version)
2122

2223
public override ComponentType Type => ComponentType.Pip;
2324

25+
[SuppressMessage("Usage", "CA1308:Normalize String to Uppercase", Justification = "Casing cannot be overwritten.")]
2426
public override string Id => $"{this.Name} {this.Version} - {this.Type}".ToLowerInvariant();
2527

2628
public override PackageURL PackageUrl => new PackageURL("pypi", null, this.Name, this.Version, null, null);

src/Microsoft.ComponentDetection.Detectors/cocoapods/PodComponentDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ public string GetSpecRepositoryOfSpec(string specName)
404404
{
405405
// CocoaPods specs are stored in a git repo but depending on settings/CocoaPods version
406406
// the repo is shown differently in the Podfile.lock
407-
return repository.Key.ToLowerInvariant() switch
407+
return repository.Key.ToUpperInvariant() switch
408408
{
409-
"trunk" or "https://github.com/cocoapods/specs.git" => "trunk",
409+
"TRUNK" or "https://github.com/cocoapods/specs.git" => "TRUNK",
410410
_ => repository.Key,
411411
};
412412
}

src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ protected override async Task OnFileFound(ProcessRequest processRequest, IDictio
7575
}
7676
else
7777
{
78-
var fileExtension = Path.GetExtension(file.Location).ToLowerInvariant();
78+
var fileExtension = Path.GetExtension(file.Location).ToUpperInvariant();
7979
switch (fileExtension)
8080
{
81-
case ".mod":
81+
case ".MOD":
8282
{
8383
this.Logger.LogVerbose("Found Go.mod: " + file.Location);
8484
this.ParseGoModFile(singleFileComponentRecorder, file);
8585
break;
8686
}
8787

88-
case ".sum":
88+
case ".SUM":
8989
{
9090
this.Logger.LogVerbose("Found Go.sum: " + file.Location);
9191
this.ParseGoSumFile(singleFileComponentRecorder, file);

src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ public class LinuxContainerDetector : IComponentDetector
4040

4141
public async Task<IndividualDetectorScanResult> ExecuteDetectorAsync(ScanRequest request)
4242
{
43+
#pragma warning disable CA1308
4344
var imagesToProcess = request.ImagesToScan?.Where(image => !string.IsNullOrWhiteSpace(image))
4445
.Select(image => image.ToLowerInvariant())
4546
.ToList();
47+
#pragma warning restore CA1308
4648

4749
if (imagesToProcess == null || !imagesToProcess.Any())
4850
{

src/Microsoft.ComponentDetection.Detectors/pip/PythonVersion.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Linq;
45
using System.Text.RegularExpressions;
56

@@ -149,6 +150,7 @@ public int CompareTo(PythonVersion other)
149150
return devNumberComparison;
150151
}
151152

153+
[SuppressMessage("Usage", "CA1308:Normalize String to Uppercase", Justification = "Casing cannot be overwritten.")]
152154
private static int ComparePreRelease(PythonVersion a, PythonVersion b)
153155
{
154156
if (string.IsNullOrEmpty(a.PreReleaseLabel) && string.IsNullOrEmpty(b.PreReleaseLabel))

src/Microsoft.ComponentDetection.Detectors/rust/Contracts/CargoPackage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public override bool Equals(object obj)
3535
string.Equals(this.Checksum, package.Checksum);
3636
}
3737

38+
[SuppressMessage("Usage", "CA1308:Normalize String to Uppercase", Justification = "Casing cannot be overwritten.")]
3839
public override int GetHashCode()
3940
{
4041
return HashCode.Combine(

test/Microsoft.ComponentDetection.Detectors.Tests/PipComponentDetectorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;

0 commit comments

Comments
 (0)