Piotr Czajkowski 2 years ago
parent
commit
4cb3883a65
3 changed files with 6 additions and 6 deletions
  1. 3 3
      analyzeJSON/AnalyzeJSON.cs
  2. 2 2
      analyzeJSON/AnalyzeStructure.cs
  3. 1 1
      analyzeJSON/Statistics.cs

+ 3 - 3
analyzeJSON/AnalyzeJSON.cs

@@ -15,16 +15,16 @@ namespace analyzeJSON
         public AnalyzeJSON(string path)
         {
             if (!File.Exists(path))
-                throw new ArgumentNullException("path");
+                throw new ArgumentNullException(nameof(path));
 
-            using StreamReader sr = new StreamReader(path);
+            using var sr = new StreamReader(path);
             var jsonString = sr.ReadToEnd();
             json = JsonConvert.DeserializeObject<JObject>(jsonString);
         }
 
         public AnalyzeJSON(JObject jObject)
         {
-            json = jObject ?? throw new ArgumentNullException("jObject");
+            json = jObject ?? throw new ArgumentNullException(nameof(jObject));
         }
 
         public static string GetNameFromPath(string tokenPath)

+ 2 - 2
analyzeJSON/AnalyzeStructure.cs

@@ -12,8 +12,8 @@ namespace analyzeJSON
 
     public class AnalyzeStructure
     {
-        private Dictionary<string, Token> nodes = new Dictionary<string, Token>();
-        private Dictionary<string, Token> leafs = new Dictionary<string, Token>();
+        private readonly Dictionary<string, Token> nodes = new();
+        private readonly Dictionary<string, Token> leafs = new();
 
         public void AnalyzeToken(JToken token)
         {

+ 1 - 1
analyzeJSON/Statistics.cs

@@ -7,7 +7,7 @@ namespace analyzeJSON
     public record WordCountResult<T>(T NodeCounts, int TotalWordCount);
     public class Statistics
     {
-        private readonly Dictionary<string, int> nodeCounts = new Dictionary<string, int>();
+        private readonly Dictionary<string, int> nodeCounts = new();
         private int totalWordCount;
 
         private static int CountWords(string text)