Skip to content

Commit fe9dc5b

Browse files
committed
Enable MSML_ParameterLocalVarName for the full solution
1 parent ef12e13 commit fe9dc5b

File tree

15 files changed

+193
-196
lines changed

15 files changed

+193
-196
lines changed

.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ dotnet_diagnostic.MSML_NoBestFriendInternal.severity = none
2424
# MSML_NoInstanceInitializers: No initializers on instance fields or properties
2525
dotnet_diagnostic.MSML_NoInstanceInitializers.severity = none
2626

27-
# MSML_ParameterLocalVarName: Parameter or local variable name not standard
28-
dotnet_diagnostic.MSML_ParameterLocalVarName.severity = none
29-
3027
[test/Microsoft.ML.CodeAnalyzer.Tests/**.cs]
3128
# BaseTestClass does not apply for analyzer testing.
3229
# MSML_ExtendBaseTestClass: Test classes should be derived from BaseTestClass

test/Microsoft.Extensions.ML.Tests/UriLoaderTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void no_reload_no_change()
7474

7575
class UriLoaderMock : UriModelLoader
7676
{
77-
public Func<Uri, string, bool> ETagMatches { get; set; } = (_, __) => false;
77+
public Func<Uri, string, bool> ETagMatches { get; set; } = delegate { return false; };
7878

7979
public UriLoaderMock(IOptions<MLOptions> contextOptions,
8080
ILogger<UriModelLoader> logger) : base(contextOptions, logger)

test/Microsoft.ML.Benchmarks/ImageClassificationBench.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ public static void UnZip(String gzArchiveName, String destFolder)
205205

206206
public static string GetAbsolutePath(string relativePath)
207207
{
208-
FileInfo _dataRoot = new FileInfo(typeof(
208+
FileInfo dataRoot = new FileInfo(typeof(
209209
ImageClassificationBench).Assembly.Location);
210210

211-
string assemblyFolderPath = _dataRoot.Directory.FullName;
211+
string assemblyFolderPath = dataRoot.Directory.FullName;
212212

213213
string fullPath = Path.Combine(assemblyFolderPath, relativePath);
214214

test/Microsoft.ML.Benchmarks/PredictionEngineBench.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void SetupIrisPipeline()
3434
PetalWidth = 5.1f,
3535
};
3636

37-
string _irisDataPath = BaseTestClass.GetDataPath("iris.txt");
37+
string irisDataPath = BaseTestClass.GetDataPath("iris.txt");
3838

3939
var env = new MLContext(seed: 1);
4040

@@ -53,7 +53,7 @@ public void SetupIrisPipeline()
5353
};
5454
var loader = new TextLoader(env, options: options);
5555

56-
IDataView data = loader.Load(_irisDataPath);
56+
IDataView data = loader.Load(irisDataPath);
5757

5858
var pipeline = new ColumnConcatenatingEstimator(env, "Features", new[] { "SepalLength", "SepalWidth", "PetalLength", "PetalWidth" })
5959
.Append(env.Transforms.Conversion.MapValueToKey("Label"))
@@ -73,7 +73,7 @@ public void SetupSentimentPipeline()
7373
SentimentText = "Not a big fan of this."
7474
};
7575

76-
string _sentimentDataPath = BaseTestClass.GetDataPath("wikipedia-detox-250-line-data.tsv");
76+
string sentimentDataPath = BaseTestClass.GetDataPath("wikipedia-detox-250-line-data.tsv");
7777

7878
var mlContext = new MLContext(seed: 1);
7979

@@ -89,7 +89,7 @@ public void SetupSentimentPipeline()
8989
};
9090
var loader = new TextLoader(mlContext, options: options);
9191

92-
IDataView data = loader.Load(_sentimentDataPath);
92+
IDataView data = loader.Load(sentimentDataPath);
9393

9494
var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "SentimentText")
9595
.Append(mlContext.BinaryClassification.Trainers.SdcaNonCalibrated(
@@ -108,7 +108,7 @@ public void SetupBreastCancerPipeline()
108108
Features = new[] { 5f, 1f, 1f, 1f, 2f, 1f, 3f, 1f, 1f }
109109
};
110110

111-
string _breastCancerDataPath = BaseTestClass.GetDataPath("breast-cancer.txt");
111+
string breastCancerDataPath = BaseTestClass.GetDataPath("breast-cancer.txt");
112112

113113
var env = new MLContext(seed: 1);
114114

@@ -124,7 +124,7 @@ public void SetupBreastCancerPipeline()
124124
};
125125
var loader = new TextLoader(env, options: options);
126126

127-
IDataView data = loader.Load(_breastCancerDataPath);
127+
IDataView data = loader.Load(breastCancerDataPath);
128128

129129
var pipeline = env.BinaryClassification.Trainers.SdcaNonCalibrated(
130130
new SdcaNonCalibratedBinaryTrainer.Options { NumberOfThreads = 1, ConvergenceTolerance = 1e-2f, });

test/Microsoft.ML.CpuMath.PerformanceTests/PerformanceTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ private float NextFloat(Random rand, int expRange)
4848
private int GetSeed()
4949
{
5050
int seed = DefaultSeed;
51-
string CPUMATH_SEED = Environment.GetEnvironmentVariable("CPUMATH_SEED");
51+
string cpumathSeed = Environment.GetEnvironmentVariable("CPUMATH_SEED");
5252

53-
if (CPUMATH_SEED != null)
53+
if (cpumathSeed != null)
5454
{
55-
if (!int.TryParse(CPUMATH_SEED, out seed))
55+
if (!int.TryParse(cpumathSeed, out seed))
5656
{
57-
if (string.Equals(CPUMATH_SEED, "random", StringComparison.OrdinalIgnoreCase))
57+
if (string.Equals(cpumathSeed, "random", StringComparison.OrdinalIgnoreCase))
5858
{
5959
seed = new Random().Next();
6060
}

test/Microsoft.ML.NugetPackageVersionUpdater/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ private static void UpdatePackageVersion(string projectFiles, IDictionary<string
5656

5757
foreach (var projectFilePath in projectFilePaths)
5858
{
59-
var CsprojDoc = new XmlDocument();
60-
CsprojDoc.Load(projectFilePath);
59+
var csprojDoc = new XmlDocument();
60+
csprojDoc.Load(projectFilePath);
6161

62-
var packageReferenceNodes = CsprojDoc.DocumentElement.SelectNodes(packageReferencePath);
62+
var packageReferenceNodes = csprojDoc.DocumentElement.SelectNodes(packageReferencePath);
6363

6464
for (int i = 0; i < packageReferenceNodes.Count; i++)
6565
{
@@ -75,7 +75,7 @@ private static void UpdatePackageVersion(string projectFiles, IDictionary<string
7575
Console.WriteLine($"Can't find newer version of Package {packageName} from NuGet source, don't need to update version.");
7676
}
7777

78-
CsprojDoc.Save(projectFilePath);
78+
csprojDoc.Save(projectFilePath);
7979
}
8080
}
8181
}

test/Microsoft.ML.Predictor.Tests/TestParallelFasttreeInterface.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal sealed class FastTreeParallelInterfaceChecker : Trainers.FastTree.IPara
2424
private bool _isInitTreeLearner = false;
2525
private bool _isInitIteration = false;
2626
private bool _isCache = false;
27-
public void CacheHistogram(bool isSmallerLeaf, int featureIdx, int subfeature, SufficientStatsBase sufficientStatsBase, bool HasWeights)
27+
public void CacheHistogram(bool isSmallerLeaf, int featureIdx, int subfeature, SufficientStatsBase sufficientStatsBase, bool hasWeights)
2828
{
2929
Assert.True(_isInitEnv);
3030
Assert.True(_isInitTreeLearner);

test/Microsoft.ML.TestFramework/RemoteExecutor.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -112,35 +112,35 @@ private static void RemoteInvoke(MethodInfo method, string[] args, RemoteInvokeO
112112
CheckProcess(Process.Start(psi), options);
113113
}
114114

115-
private static void CheckProcess(Process process, RemoteInvokeOptions Options)
115+
private static void CheckProcess(Process process, RemoteInvokeOptions options)
116116
{
117117
if (process != null)
118118
{
119119
// A bit unorthodox to do throwing operations in a Dispose, but by doing it here we avoid
120120
// needing to do this in every derived test and keep each test much simpler.
121121
try
122122
{
123-
Assert.True(process.WaitForExit(Options.TimeOut),
124-
$"Timed out after {Options.TimeOut}ms waiting for remote process {process.Id}");
123+
Assert.True(process.WaitForExit(options.TimeOut),
124+
$"Timed out after {options.TimeOut}ms waiting for remote process {process.Id}");
125125

126-
if (File.Exists(Options.ExceptionFile))
126+
if (File.Exists(options.ExceptionFile))
127127
{
128-
throw new RemoteExecutionException(File.ReadAllText(Options.ExceptionFile));
128+
throw new RemoteExecutionException(File.ReadAllText(options.ExceptionFile));
129129
}
130130

131-
if (Options.CheckExitCode)
131+
if (options.CheckExitCode)
132132
{
133-
int expected = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? Options.ExpectedExitCode : unchecked((sbyte)Options.ExpectedExitCode);
133+
int expected = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? options.ExpectedExitCode : unchecked((sbyte)options.ExpectedExitCode);
134134
int actual = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? process.ExitCode : unchecked((sbyte)process.ExitCode);
135135

136-
Assert.True(expected == actual, $"Exit code was {process.ExitCode} but it should have been {Options.ExpectedExitCode}");
136+
Assert.True(expected == actual, $"Exit code was {process.ExitCode} but it should have been {options.ExpectedExitCode}");
137137
}
138138
}
139139
finally
140140
{
141-
if (File.Exists(Options.ExceptionFile))
141+
if (File.Exists(options.ExceptionFile))
142142
{
143-
File.Delete(Options.ExceptionFile);
143+
File.Delete(options.ExceptionFile);
144144
}
145145

146146
// Cleanup

test/Microsoft.ML.Tests/OnnxSequenceTypeWithAttributesTest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public void OnnxSequenceTypeWithColumnNameAttributeTest()
5656

5757
FloatInput input = new FloatInput() { Input = new float[] { 1.0f, 2.0f, 3.0f } };
5858
var output = predictor.Predict(input);
59-
var onnx_out = output.Output.FirstOrDefault();
60-
Assert.True(onnx_out.Count == 3, "Output missing data.");
61-
var keys = new List<string>(onnx_out.Keys);
62-
for(var i =0; i < onnx_out.Count; ++i)
59+
var onnxOut = output.Output.FirstOrDefault();
60+
Assert.True(onnxOut.Count == 3, "Output missing data.");
61+
var keys = new List<string>(onnxOut.Keys);
62+
for(var i =0; i < onnxOut.Count; ++i)
6363
{
64-
Assert.Equal(onnx_out[keys[i]], input.Input[i]);
64+
Assert.Equal(onnxOut[keys[i]], input.Input[i]);
6565
}
6666

6767
}

test/Microsoft.ML.Tests/ScenariosWithDirectInstantiation/TensorflowTests.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void TensorFlowTransforCifarEndToEndTest2()
108108
{
109109
var imageHeight = 32;
110110
var imageWidth = 32;
111-
var model_location = "cifar_model/frozen_model.pb";
111+
var modelLocation = "cifar_model/frozen_model.pb";
112112
var dataFile = GetDataPath("images/images.tsv");
113113
var imageFolder = Path.GetDirectoryName(dataFile);
114114

@@ -125,7 +125,7 @@ public void TensorFlowTransforCifarEndToEndTest2()
125125
var pipeEstimator = new ImageLoadingEstimator(mlContext, imageFolder, ("ImageReal", "ImagePath"))
126126
.Append(new ImageResizingEstimator(mlContext, "ImageCropped", imageHeight, imageWidth, "ImageReal"))
127127
.Append(new ImagePixelExtractingEstimator(mlContext, "Input", "ImageCropped", interleavePixelColors: true))
128-
.Append(mlContext.Model.LoadTensorFlowModel(model_location).ScoreTensorFlowModel("Output", "Input"))
128+
.Append(mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel("Output", "Input"))
129129
.Append(new ColumnConcatenatingEstimator(mlContext, "Features", "Output"))
130130
.Append(new ValueToKeyMappingEstimator(mlContext, "Label"))
131131
.AppendCacheCheckpoint(mlContext)
@@ -345,7 +345,7 @@ private class TypesData
345345
public void TensorFlowTransformInputOutputTypesTest()
346346
{
347347
// This an identity model which returns the same output as input.
348-
var model_location = "model_types_test";
348+
var modelLocation = "model_types_test";
349349

350350
//Data
351351
var data = new List<TypesData>(
@@ -382,7 +382,7 @@ public void TensorFlowTransformInputOutputTypesTest()
382382

383383
var inputs = new string[] { "f64", "f32", "i64", "i32", "i16", "i8", "u64", "u32", "u16", "u8", "b" };
384384
var outputs = new string[] { "o_f64", "o_f32", "o_i64", "o_i32", "o_i16", "o_i8", "o_u64", "o_u32", "o_u16", "o_u8", "o_b" };
385-
var trans = mlContext.Model.LoadTensorFlowModel(model_location).ScoreTensorFlowModel(outputs, inputs).Fit(loader).Transform(loader); ;
385+
var trans = mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel(outputs, inputs).Fit(loader).Transform(loader); ;
386386

387387
using (var cursor = trans.GetRowCursorForAllColumns())
388388
{
@@ -546,8 +546,8 @@ public void TensorFlowTransformInceptionTest()
546546
public void TensorFlowInputsOutputsSchemaTest()
547547
{
548548
var mlContext = new MLContext(seed: 1);
549-
var model_location = "mnist_model/frozen_saved_model.pb";
550-
var schema = TensorFlowUtils.GetModelSchema(mlContext, model_location);
549+
var modelLocation = "mnist_model/frozen_saved_model.pb";
550+
var schema = TensorFlowUtils.GetModelSchema(mlContext, modelLocation);
551551
Assert.Equal(86, schema.Count);
552552
Assert.True(schema.TryGetColumnIndex("Placeholder", out int col));
553553
var type = (VectorDataViewType)schema[col].Type;
@@ -607,8 +607,8 @@ public void TensorFlowInputsOutputsSchemaTest()
607607
Assert.Equal(1, inputOps.Length);
608608
Assert.Equal("sequential/dense_1/BiasAdd", inputOps.GetValues()[0].ToString());
609609

610-
model_location = "model_matmul/frozen_saved_model.pb";
611-
schema = TensorFlowUtils.GetModelSchema(mlContext, model_location);
610+
modelLocation = "model_matmul/frozen_saved_model.pb";
611+
schema = TensorFlowUtils.GetModelSchema(mlContext, modelLocation);
612612
char name = 'a';
613613
for (int i = 0; i < schema.Count; i++)
614614
{
@@ -663,7 +663,7 @@ public void TensorFlowTransformMNISTLRTrainingTest()
663663
{
664664
const double expectedMicroAccuracy = 0.72173913043478266;
665665
const double expectedMacroAccruacy = 0.67482993197278918;
666-
var model_location = "mnist_lr_model";
666+
var modelLocation = "mnist_lr_model";
667667
try
668668
{
669669
var mlContext = new MLContext(seed: 1);
@@ -686,7 +686,7 @@ public void TensorFlowTransformMNISTLRTrainingTest()
686686
labelColumnName: "OneHotLabel",
687687
dnnLabel: "Label",
688688
optimizationOperation: "SGDOptimizer",
689-
modelPath: model_location,
689+
modelPath: modelLocation,
690690
lossOperation: "Loss",
691691
epoch: 10,
692692
learningRateOperation: "SGDOptimizer/learning_rate",
@@ -724,16 +724,16 @@ public void TensorFlowTransformMNISTLRTrainingTest()
724724
{
725725
// This test changes the state of the model.
726726
// Cleanup folder so that other test can also use the same model.
727-
CleanUp(model_location);
727+
CleanUp(modelLocation);
728728
}
729729
}
730730

731-
private void CleanUp(string model_location)
731+
private void CleanUp(string modelLocation)
732732
{
733-
var directories = Directory.GetDirectories(model_location, "variables-*");
733+
var directories = Directory.GetDirectories(modelLocation, "variables-*");
734734
if (directories != null && directories.Length > 0)
735735
{
736-
var varDir = Path.Combine(model_location, "variables");
736+
var varDir = Path.Combine(modelLocation, "variables");
737737
if (Directory.Exists(varDir))
738738
Directory.Delete(varDir, true);
739739
Directory.Move(directories[0], varDir);

test/Microsoft.ML.Tests/TextLoaderTests.cs

+34-34
Original file line numberDiff line numberDiff line change
@@ -287,38 +287,38 @@ public void CanSuccessfullyRetrieveQuotedData()
287287

288288
using (var cursor = data.GetRowCursorForAllColumns())
289289
{
290-
var IDGetter = cursor.GetGetter<float>(cursor.Schema[0]);
291-
var TextGetter = cursor.GetGetter<ReadOnlyMemory<char>>(cursor.Schema[1]);
290+
var idGetter = cursor.GetGetter<float>(cursor.Schema[0]);
291+
var textGetter = cursor.GetGetter<ReadOnlyMemory<char>>(cursor.Schema[1]);
292292

293293
Assert.True(cursor.MoveNext());
294294

295-
float ID = 0;
296-
IDGetter(ref ID);
297-
Assert.Equal(1, ID);
295+
float id = 0;
296+
idGetter(ref id);
297+
Assert.Equal(1, id);
298298

299-
ReadOnlyMemory<char> Text = new ReadOnlyMemory<char>();
300-
TextGetter(ref Text);
301-
Assert.Equal("This text contains comma, within quotes.", Text.ToString());
299+
ReadOnlyMemory<char> text = new ReadOnlyMemory<char>();
300+
textGetter(ref text);
301+
Assert.Equal("This text contains comma, within quotes.", text.ToString());
302302

303303
Assert.True(cursor.MoveNext());
304304

305-
ID = 0;
306-
IDGetter(ref ID);
307-
Assert.Equal(2, ID);
305+
id = 0;
306+
idGetter(ref id);
307+
Assert.Equal(2, id);
308308

309-
Text = new ReadOnlyMemory<char>();
310-
TextGetter(ref Text);
311-
Assert.Equal("This text contains extra punctuations and special characters.;*<>?!@#$%^&*()_+=-{}|[]:;'", Text.ToString());
309+
text = new ReadOnlyMemory<char>();
310+
textGetter(ref text);
311+
Assert.Equal("This text contains extra punctuations and special characters.;*<>?!@#$%^&*()_+=-{}|[]:;'", text.ToString());
312312

313313
Assert.True(cursor.MoveNext());
314314

315-
ID = 0;
316-
IDGetter(ref ID);
317-
Assert.Equal(3, ID);
315+
id = 0;
316+
idGetter(ref id);
317+
Assert.Equal(3, id);
318318

319-
Text = new ReadOnlyMemory<char>();
320-
TextGetter(ref Text);
321-
Assert.Equal("This text has no quotes", Text.ToString());
319+
text = new ReadOnlyMemory<char>();
320+
textGetter(ref text);
321+
Assert.Equal("This text has no quotes", text.ToString());
322322

323323
Assert.False(cursor.MoveNext());
324324
}
@@ -548,28 +548,28 @@ public void CanSuccessfullyTrimSpaces()
548548

549549
using (var cursor = data.GetRowCursorForAllColumns())
550550
{
551-
var IDGetter = cursor.GetGetter<float>(cursor.Schema[0]);
552-
var TextGetter = cursor.GetGetter<ReadOnlyMemory<char>>(cursor.Schema[1]);
551+
var idGetter = cursor.GetGetter<float>(cursor.Schema[0]);
552+
var textGetter = cursor.GetGetter<ReadOnlyMemory<char>>(cursor.Schema[1]);
553553

554554
Assert.True(cursor.MoveNext());
555555

556-
float ID = 0;
557-
IDGetter(ref ID);
558-
Assert.Equal(1, ID);
556+
float id = 0;
557+
idGetter(ref id);
558+
Assert.Equal(1, id);
559559

560-
ReadOnlyMemory<char> Text = new ReadOnlyMemory<char>();
561-
TextGetter(ref Text);
562-
Assert.Equal("There is a space at the end", Text.ToString());
560+
ReadOnlyMemory<char> text = new ReadOnlyMemory<char>();
561+
textGetter(ref text);
562+
Assert.Equal("There is a space at the end", text.ToString());
563563

564564
Assert.True(cursor.MoveNext());
565565

566-
ID = 0;
567-
IDGetter(ref ID);
568-
Assert.Equal(2, ID);
566+
id = 0;
567+
idGetter(ref id);
568+
Assert.Equal(2, id);
569569

570-
Text = new ReadOnlyMemory<char>();
571-
TextGetter(ref Text);
572-
Assert.Equal("There is no space at the end", Text.ToString());
570+
text = new ReadOnlyMemory<char>();
571+
textGetter(ref text);
572+
Assert.Equal("There is no space at the end", text.ToString());
573573

574574
Assert.False(cursor.MoveNext());
575575
}

0 commit comments

Comments
 (0)