SonarQube analysis hangs in the "Running Tarjan" step or throws OutofMemoryError

Unfortunately, it’s not as trivial as excluding individual files.

Can you check that the scanner is definitely recognising the SONAR_SCANNER_OPTS environment variable? You should see something like this at the begeinning of thee scanner logs.

INFO: Scanner configuration file: /Users/colin/Tools/sonar-scanner-4.0.0.1744/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 11.0.3 Oracle Corporation (64-bit)
INFO: Mac OS X 10.15.4 x86_64
INFO: SONAR_SCANNER_OPTS=-Xmx2048M -Xms2048M
INFO: User cache: /Users/colin/.sonar/cache