Skip to content

Commit 013feab

Browse files
committed
cleanup '#pragma warning disable'
1 parent f8d57ba commit 013feab

File tree

6 files changed

+1
-17
lines changed

6 files changed

+1
-17
lines changed

src/coverlet.core/Helpers/InstrumentationHelper.cs

-2
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,8 @@ private static bool IsTypeFilterMatch(string module, string type, string[] filte
468468

469469
foreach (string filter in filters)
470470
{
471-
#pragma warning disable IDE0057 // Use range operator
472471
string typePattern = filter.Substring(filter.IndexOf(']') + 1);
473472
string modulePattern = filter.Substring(1, filter.IndexOf(']') - 1);
474-
#pragma warning restore IDE0057 // Use range operator
475473

476474
typePattern = WildcardToRegex(typePattern);
477475
modulePattern = WildcardToRegex(modulePattern);

src/coverlet.core/Helpers/SourceRootTranslator.cs

-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ private Dictionary<string, List<SourceRootMapping>> LoadSourceRootMapping(string
101101
_logger.LogWarning($"Malformed mapping '{mappingRecord}'");
102102
continue;
103103
}
104-
#pragma warning disable IDE0057 // Use range operator
105104
string projectPath = mappingRecord.Substring(0, projectFileSeparatorIndex);
106105
string originalPath = mappingRecord.Substring(projectFileSeparatorIndex + 1, pathMappingSeparatorIndex - projectFileSeparatorIndex - 1);
107106
string mappedPath = mappingRecord.Substring(pathMappingSeparatorIndex + 1);
108-
#pragma warning restore IDE0057 // Use range operator
109107

110108
if (!mapping.ContainsKey(mappedPath))
111109
{

src/coverlet.core/Instrumentation/CecilAssemblyResolver.cs

-2
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,8 @@ public NetCoreSharedFrameworkResolver(string modulePath, ILogger logger)
244244
var semVersion = NuGetVersion.Parse(frameworkVersion);
245245
var directory = new DirectoryInfo(Path.Combine(runtimeRootPath, frameworkName));
246246
string majorVersion = $"{semVersion.Major}.{semVersion.Minor}.";
247-
#pragma warning disable IDE0057 // Use range operator
248247
uint latestVersion = directory.GetDirectories().Where(x => x.Name.StartsWith(majorVersion))
249248
.Select(x => Convert.ToUInt32(x.Name.Substring(majorVersion.Length))).Max();
250-
#pragma warning restore IDE0057 // Use range operator
251249
_aspNetSharedFrameworkDirs.Add(Directory.GetDirectories(directory.FullName, majorVersion + $"{latestVersion}*", SearchOption.TopDirectoryOnly)[0]);
252250
}
253251

src/coverlet.core/Instrumentation/Instrumenter.cs

-6
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,7 @@ private void InstrumentType(TypeDefinition type)
463463
MethodDefinition actualMethod = method;
464464
IEnumerable<CustomAttribute> customAttributes = method.CustomAttributes;
465465
if (_instrumentationHelper.IsLocalMethod(method.Name))
466-
#pragma warning disable IDE0057 // Use range operator
467466
actualMethod = methods.FirstOrDefault(m => m.Name == method.Name.Split('>')[0].Substring(1)) ?? method;
468-
#pragma warning restore IDE0057 // Use range operator
469467

470468
if (actualMethod.IsGetter || actualMethod.IsSetter)
471469
{
@@ -927,9 +925,7 @@ public ExcludedFilesHelper(string[] excludes, ILogger logger)
927925
{
928926
continue;
929927
}
930-
#pragma warning disable IDE0057 // Use range operator
931928
_matcher.AddInclude(Path.IsPathRooted(excludeRule) ? excludeRule.Substring(Path.GetPathRoot(excludeRule).Length) : excludeRule);
932-
#pragma warning restore IDE0057 // Use range operator
933929
}
934930
}
935931
}
@@ -940,9 +936,7 @@ public bool Exclude(string sourceFile)
940936
return false;
941937

942938
// We strip out drive because it doesn't work with globbing
943-
#pragma warning disable IDE0057 // Use range operator
944939
return _matcher.Match(Path.IsPathRooted(sourceFile) ? sourceFile.Substring(Path.GetPathRoot(sourceFile).Length) : sourceFile).HasMatches;
945-
#pragma warning restore IDE0057 // Use range operator
946940
}
947941
}
948942
}

src/coverlet.core/Reporters/CoberturaReporter.cs

-2
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ private static string GetRelativePathFromBase(IEnumerable<string> basePaths, str
224224
{
225225
if (path.StartsWith(basePath))
226226
{
227-
#pragma warning disable IDE0057 // Use range operator
228227
return path.Substring(basePath.Length);
229-
#pragma warning restore IDE0057 // Use range operator
230228
}
231229
}
232230
return path;

test/coverlet.integration.tests/BaseTest.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ private protected string GetPackageVersion(string filter)
4545
using var reader = new PackageArchiveReader(pkg);
4646
using Stream nuspecStream = reader.GetNuspec();
4747
var manifest = Manifest.ReadFrom(nuspecStream, false);
48-
#pragma warning disable CS8603 // Possible null reference return.
49-
return manifest.Metadata.Version.OriginalVersion;
50-
#pragma warning restore CS8603 // Possible null reference return.
48+
return manifest.Metadata.Version?.OriginalVersion ?? throw new InvalidOperationException("Version is null");
5149
}
5250
}
5351

0 commit comments

Comments
 (0)