|
1 | | -using Atc.CodingRules.Updater.CLI.Models.Options; |
2 | 1 | using Atc.DotNet; |
3 | 2 | using OfficeOpenXml; |
4 | 3 | using OfficeOpenXml.Style; |
@@ -198,40 +197,64 @@ private static async Task HandleTemporarySuppressions( |
198 | 197 | return; |
199 | 198 | } |
200 | 199 |
|
201 | | - var suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult); |
202 | | - if (!suppressionLinesPrAnalyzer.Any()) |
| 200 | + if (buildResult.Any(x => x.Key.StartsWith("MSB", StringComparison.Ordinal))) |
203 | 201 | { |
204 | | - logger.LogTrace(" No suppressions to add."); |
205 | | - return; |
206 | | - } |
207 | | - |
208 | | - await EditorConfigHelper.UpdateRootFileAddCustomAtcAutogeneratedRuleSuppressions(projectPath, suppressionLinesPrAnalyzer); |
209 | | - for (var i = 0; i < MaxNumberOfTimesToBuild; i++) |
210 | | - { |
211 | | - var runAgain = await BuildAndCollectErrorsAgainAndUpdateFile( |
212 | | - logger, |
213 | | - projectPath, |
214 | | - 2 + i, |
215 | | - buildFile, |
216 | | - buildResult, |
217 | | - analyzerProviderBaseRules); |
| 202 | + var errorTypes = buildResult |
| 203 | + .Where(x => x.Key.StartsWith("MSB", StringComparison.Ordinal)) |
| 204 | + .Select(x => x.Key) |
| 205 | + .OrderBy(x => x) |
| 206 | + .ToList(); |
218 | 207 |
|
219 | | - if (!runAgain) |
220 | | - { |
221 | | - break; |
222 | | - } |
| 208 | + logger.LogWarning($" MSB-errors ({string.Join(',', errorTypes)}) was found, please correct them manually first and try again."); |
223 | 209 | } |
224 | | - |
225 | | - suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult); |
226 | | - if (temporarySuppressionsPath is not null) |
| 210 | + else if (buildResult.Any(x => x.Key.StartsWith("NU", StringComparison.Ordinal))) |
227 | 211 | { |
228 | | - await EditorConfigHelper.WriteAllText(projectPath, rootEditorConfigContent); |
229 | | - await CreateSuppressionsFileInTempPath(logger, temporarySuppressionsPath, temporarySuppressionAsExcel, suppressionLinesPrAnalyzer); |
| 212 | + var errorTypes = buildResult |
| 213 | + .Where(x => x.Key.StartsWith("NU", StringComparison.Ordinal)) |
| 214 | + .Select(x => x.Key) |
| 215 | + .OrderBy(x => x) |
| 216 | + .ToList(); |
| 217 | + |
| 218 | + logger.LogWarning($" NU-errors ({string.Join(',', errorTypes)}) was found, please correct them manually first and try again."); |
230 | 219 | } |
231 | 220 | else |
232 | 221 | { |
233 | | - var totalSuppressions = suppressionLinesPrAnalyzer.Sum(x => x.Item2.Count); |
234 | | - logger.LogInformation($"{EmojisConstants.FileUpdated} [yellow]/[/]{EditorConfigHelper.FileName} is updated with {totalSuppressions} suppressions"); |
| 222 | + var suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult); |
| 223 | + if (suppressionLinesPrAnalyzer.Any()) |
| 224 | + { |
| 225 | + await EditorConfigHelper.UpdateRootFileAddCustomAtcAutogeneratedRuleSuppressions(projectPath, suppressionLinesPrAnalyzer); |
| 226 | + for (var i = 0; i < MaxNumberOfTimesToBuild; i++) |
| 227 | + { |
| 228 | + var runAgain = await BuildAndCollectErrorsAgainAndUpdateFile( |
| 229 | + logger, |
| 230 | + projectPath, |
| 231 | + 2 + i, |
| 232 | + buildFile, |
| 233 | + buildResult, |
| 234 | + analyzerProviderBaseRules); |
| 235 | + |
| 236 | + if (!runAgain) |
| 237 | + { |
| 238 | + break; |
| 239 | + } |
| 240 | + } |
| 241 | + |
| 242 | + suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult); |
| 243 | + if (temporarySuppressionsPath is not null) |
| 244 | + { |
| 245 | + await EditorConfigHelper.WriteAllText(projectPath, rootEditorConfigContent); |
| 246 | + await CreateSuppressionsFileInTempPath(logger, temporarySuppressionsPath, temporarySuppressionAsExcel, suppressionLinesPrAnalyzer); |
| 247 | + } |
| 248 | + else |
| 249 | + { |
| 250 | + var totalSuppressions = suppressionLinesPrAnalyzer.Sum(x => x.Item2.Count); |
| 251 | + logger.LogInformation($"{EmojisConstants.FileUpdated} [yellow]/[/]{EditorConfigHelper.FileName} is updated with {totalSuppressions} suppressions"); |
| 252 | + } |
| 253 | + } |
| 254 | + else |
| 255 | + { |
| 256 | + logger.LogTrace(" No suppressions to add."); |
| 257 | + } |
235 | 258 | } |
236 | 259 |
|
237 | 260 | stopwatch.Stop(); |
|
0 commit comments