From 48412bfdc6258d064ca63d71091fa317b3df505e Mon Sep 17 00:00:00 2001 From: magic56 Date: Wed, 18 Dec 2024 12:49:05 +0100 Subject: [PATCH] refactor: remove unused using directives and improve code clarity in various files --- CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs | 4 ---- CodeLineCounter.Tests/JsonHandlerTests.cs | 2 -- CodeLineCounter/Program.cs | 10 +++++++++- CodeLineCounter/Services/CodeDuplicationChecker.cs | 7 ------- CodeLineCounter/Services/DependencyAnalyzer.cs | 5 ----- CodeLineCounter/Services/DependencyGraphGenerator.cs | 1 - 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs b/CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs index 401ad57..1e8a434 100644 --- a/CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs +++ b/CodeLineCounter.Tests/DependencyGraphGeneratorTests.cs @@ -1,9 +1,5 @@ -using CodeLineCounter.Utils; using CodeLineCounter.Models; using CodeLineCounter.Services; -using System.Collections.Generic; -using System.IO; -using Xunit; namespace CodeLineCounter.Tests { diff --git a/CodeLineCounter.Tests/JsonHandlerTests.cs b/CodeLineCounter.Tests/JsonHandlerTests.cs index 0560b1e..5d90291 100644 --- a/CodeLineCounter.Tests/JsonHandlerTests.cs +++ b/CodeLineCounter.Tests/JsonHandlerTests.cs @@ -1,7 +1,5 @@ using CodeLineCounter.Utils; using System.Text.Json; -using System.Text.Json.Serialization; -using Xunit.Sdk; namespace CodeLineCounter.Tests { diff --git a/CodeLineCounter/Program.cs b/CodeLineCounter/Program.cs index 014b779..5924d6e 100644 --- a/CodeLineCounter/Program.cs +++ b/CodeLineCounter/Program.cs @@ -12,13 +12,21 @@ static void Main(string[] args) return; // file deepcode ignore PT: Not a web server. This software is a console application. - var solutionFiles = FileUtils.GetSolutionFiles(settings.DirectoryPath); + List solutionFiles = FileUtils.GetSolutionFiles(settings.DirectoryPath); if (solutionFiles.Count == 0) { Console.WriteLine("No solution (.sln) found in the specified directory."); return; } + // If only one solution found in directory, select it automatically + // if more than one waiting for user selection + if (solutionFiles.Count == 1) + { + SolutionAnalyzer.AnalyzeAndExportSolution(solutionFiles[0], settings.Verbose, settings.format); + return; + } + var solutionFilenameList = CoreUtils.GetFilenamesList(solutionFiles); CoreUtils.DisplaySolutions(solutionFilenameList); diff --git a/CodeLineCounter/Services/CodeDuplicationChecker.cs b/CodeLineCounter/Services/CodeDuplicationChecker.cs index 900b1a4..a6f4861 100644 --- a/CodeLineCounter/Services/CodeDuplicationChecker.cs +++ b/CodeLineCounter/Services/CodeDuplicationChecker.cs @@ -1,14 +1,7 @@ -using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; using CodeLineCounter.Models; using CodeLineCounter.Utils; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/CodeLineCounter/Services/DependencyAnalyzer.cs b/CodeLineCounter/Services/DependencyAnalyzer.cs index c54e4b7..deddb6c 100644 --- a/CodeLineCounter/Services/DependencyAnalyzer.cs +++ b/CodeLineCounter/Services/DependencyAnalyzer.cs @@ -4,11 +4,6 @@ using CodeLineCounter.Models; using CodeLineCounter.Utils; using System.Collections.Concurrent; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; namespace CodeLineCounter.Services diff --git a/CodeLineCounter/Services/DependencyGraphGenerator.cs b/CodeLineCounter/Services/DependencyGraphGenerator.cs index fef1817..4748a25 100644 --- a/CodeLineCounter/Services/DependencyGraphGenerator.cs +++ b/CodeLineCounter/Services/DependencyGraphGenerator.cs @@ -1,7 +1,6 @@ using CodeLineCounter.Models; using QuikGraph; using QuikGraph.Graphviz; -using System.Diagnostics; namespace CodeLineCounter.Services {