@@ -41,6 +41,16 @@ public class AdditionalFilesService(IDirectoryWrapper directoryWrapper) : IAddit
4141 ".sonar"
4242 ] ;
4343
44+ // See https://github.com/SonarSource/sonar-iac/pull/1249/files#diff-a10a88bfebc0f61ea4e5c34a130cd3c79b7bae47f716b1a8e405282724cb9141R28
45+ // and https://sonarsource.atlassian.net/browse/SONARIAC-1419
46+ // sonar-iac already excludes these files, but the plugin is updated only on later versions of SQ, at least after 10.4.
47+ // To support excluding them for previous versions, as long as we support them, we exclude them here.
48+ private static readonly IReadOnlyList < string > ExcludedFiles =
49+ [
50+ "build-wrapper-dump.json" ,
51+ "compile_commands.json" ,
52+ ] ;
53+
4454 private static readonly IReadOnlyList < string > SupportedLanguages =
4555 [
4656 "sonar.tsql.file.suffixes" ,
@@ -83,14 +93,17 @@ private FileInfo[] GetAllFiles(IEnumerable<string> extensions, DirectoryInfo pro
8393 . Concat ( [ projectBaseDir ] ) // also include the root directory
8494 . Where ( x => ! IsExcludedDirectory ( x ) )
8595 . SelectMany ( x => directoryWrapper . EnumerateFiles ( x , "*" , SearchOption . TopDirectoryOnly ) )
86- . Where ( x => extensions . Any ( e => x . Name . EndsWith ( e , StringComparison . OrdinalIgnoreCase ) && ! x . Name . Equals ( e , StringComparison . OrdinalIgnoreCase ) ) )
96+ . Where ( x => ! IsExcludedFile ( x ) && extensions . Any ( e => x . Name . EndsWith ( e , StringComparison . OrdinalIgnoreCase ) && ! x . Name . Equals ( e , StringComparison . OrdinalIgnoreCase ) ) )
8797 . ToArray ( ) ;
8898
8999 private static bool IsExcludedDirectory ( DirectoryInfo directory ) =>
90100 ExcludedDirectories . Any ( x => Array . Exists (
91101 directory . FullName . Split ( Path . DirectorySeparatorChar ) , // split it so that we also exclude subdirectories like .sonarqube/conf.
92102 part => part . Equals ( x , StringComparison . OrdinalIgnoreCase ) ) ) ;
93103
104+ private static bool IsExcludedFile ( FileInfo file ) =>
105+ ExcludedFiles . Any ( x => x . Equals ( file . Name , StringComparison . OrdinalIgnoreCase ) ) ;
106+
94107 private static AdditionalFiles PartitionAdditionalFiles ( FileInfo [ ] allFiles , AnalysisConfig analysisConfig )
95108 {
96109 var testExtensions = GetTestExtensions ( analysisConfig ) ;
0 commit comments