@@ -7,15 +7,23 @@ namespace CodeLineCounter.Services
77{
88 public static partial class SolutionAnalyzer
99 {
10-
1110 public static void AnalyzeAndExportSolution ( string solutionPath , bool verbose , CoreUtils . ExportFormat format , string ? outputPath = null )
1211 {
1312 try
1413 {
1514 var analysisResult = PerformAnalysis ( solutionPath ) ;
1615 OutputAnalysisResults ( analysisResult , verbose ) ;
1716 ExportResults ( analysisResult , solutionPath , format , outputPath ) ;
18-
17+ }
18+ catch ( UnauthorizedAccessException ex )
19+ {
20+ Console . Error . WriteLine ( $ "Access denied: { ex . Message } ") ;
21+ throw ;
22+ }
23+ catch ( FileNotFoundException ex )
24+ {
25+ Console . Error . WriteLine ( $ "File not found: { ex . Message } ") ;
26+ throw ;
1927 }
2028 catch ( Exception ex )
2129 {
@@ -56,7 +64,7 @@ public static void OutputAnalysisResults(AnalysisResult result, bool verbose)
5664 }
5765
5866 var percentageDuplication = ( result . DuplicatedLines / ( double ) result . TotalLines ) * 100 ;
59- NumberFormatInfo nfi = new System . Globalization . CultureInfo ( "en-US" , false ) . NumberFormat ;
67+ NumberFormatInfo nfi = new System . Globalization . CultureInfo ( "en-US" , false ) . NumberFormat ;
6068
6169 Console . WriteLine ( $ "Processing completed, number of source files processed: { result . TotalFiles } ") ;
6270 Console . WriteLine ( $ "Total lines of code: { result . TotalLines } ") ;
@@ -68,52 +76,23 @@ public static void OutputAnalysisResults(AnalysisResult result, bool verbose)
6876 public static void ExportResults ( AnalysisResult result , string solutionPath , CoreUtils . ExportFormat format , string ? outputPath = null )
6977 {
7078 string baseFileName = Path . GetFileNameWithoutExtension ( solutionPath ) ;
71-
72- // Export metrics
7379 string metricsFileName = $ "{ baseFileName } .CodeMetrics.json";
7480 metricsFileName = CoreUtils . GetExportFileNameWithExtension ( metricsFileName , format ) ;
75- if ( string . IsNullOrEmpty ( outputPath ) )
76- {
77- outputPath = "." ;
78- }
81+ outputPath ??= "." ;
7982
80- string metricsOutputPath = outputPath != null
81- ? Path . Combine ( outputPath , metricsFileName )
82- : metricsFileName ;
83-
84- // Export duplications
83+ string metricsOutputPath = Path . Combine ( outputPath , metricsFileName ) ;
8584 string duplicationsFileName = $ "{ baseFileName } .CodeDuplications.json";
8685 duplicationsFileName = CoreUtils . GetExportFileNameWithExtension ( duplicationsFileName , format ) ;
87- string duplicationsOutputPath = outputPath != null
88- ? Path . Combine ( outputPath , duplicationsFileName )
89- : duplicationsFileName ;
90- // Export des duplications...
91-
92- // Export dependencies graph
86+ string duplicationsOutputPath = Path . Combine ( outputPath , duplicationsFileName ) ;
9387 string graphFileName = $ "{ baseFileName } .Dependencies.dot";
94- string graphOutputPath = outputPath != null
95- ? Path . Combine ( outputPath , graphFileName )
96- : graphFileName ;
88+ string graphOutputPath = Path . Combine ( outputPath , graphFileName ) ;
9789
9890 try
9991 {
10092 Parallel . Invoke (
101- ( ) => DataExporter . ExportMetrics (
102- metricsFileName ,
103- outputPath ?? "." ,
104- result ,
105- solutionPath ,
106- format ) ,
107- ( ) => DataExporter . ExportDuplications (
108- duplicationsFileName ,
109- outputPath ?? "." ,
110- result . DuplicationMap ,
111- format ) ,
112- async ( ) => await DataExporter . ExportDependencies (
113- graphFileName ,
114- outputPath ?? "." ,
115- result . DependencyList ,
116- format )
93+ ( ) => DataExporter . ExportMetrics ( metricsFileName , outputPath , result , solutionPath , format ) ,
94+ ( ) => DataExporter . ExportDuplications ( duplicationsFileName , outputPath , result . DuplicationMap , format ) ,
95+ async ( ) => await DataExporter . ExportDependencies ( graphFileName , outputPath , result . DependencyList , format )
11796 ) ;
11897
11998 Console . WriteLine ( $ "The data has been exported to { metricsOutputPath } ") ;
@@ -144,6 +123,5 @@ public static void OutputDetailedMetrics(List<NamespaceMetrics> metrics, Diction
144123 Console . WriteLine ( $ "Project { projectTotal . Key } has { projectTotal . Value } total lines of code.") ;
145124 }
146125 }
147-
148126 }
149- }
127+ }
0 commit comments