Sonar scanner hangs indefinitely on `deprecation` sonar eslint rule

Setup:

  • SonarQube@10.5.1.90531 (Community Edition)
  • Scanner@6.1.0.4477
  • localhost setup with postgresql

Tried

  • Complete reinstall
  • Numerous sonar settings, exclusions, etc

The deprecation rule took 99911.889ms to execute.

20:09:26.307 INFO  Rule                                           | Time (ms)      | Relative
20:09:26.307 INFO  :----------------------------------------------|---------------:|---------:
20:09:26.307 INFO  deprecation                                    | 99911.889      |  69.0%
20:09:26.307 INFO  aws-restricted-ip-admin-access                 | 10739.742      |  7.4%
20:09:26.307 INFO  no-redundant-assignments                       |  4776.300      |  3.3%
20:09:26.307 INFO  no-dead-store                                  |  3821.831      |  2.6%
20:09:26.307 INFO  no-duplicates                                  |  2666.670      |  1.8%
20:09:26.307 INFO  no-misused-promises                            |  2351.199      |  1.6%
20:09:26.307 INFO  no-direct-mutation-state                       |  1129.350      |  0.8%
20:09:26.307 INFO  no-unstable-nested-components                  |  1069.325      |  0.7%
20:09:26.307 INFO  no-deprecated-react                            |  1048.066      |  0.7%
20:09:26.307 INFO  prefer-object-spread                           |   864.321      |  0.6%
20:09:26.307 INFO  no-array-index-key                             |   832.733      |  0.6%
20:09:26.307 INFO  no-clear-text-protocols                        |   621.379      |  0.4%
20:09:26.307 INFO  no-base-to-string                              |   378.586      |  0.3%
20:09:26.307 INFO  cognitive-complexity                           |   371.332      |  0.3%
20:09:26.307 INFO  hook-use-state                                 |   365.799      |  0.3%

Hello @passbyval,

Welcome to the Sonar community and thank you for the feedback!

We recently made an attempt to enhance the performance of this rule. However, it appears that it did not have the expected impact, at least in your project. In order to assist you, we would need the following:

  • A rough estimate of the project size, including the number of source files and TSConfigs if you are using TypeScript.
  • The debug logs from the scanner during the analysis can be made available by setting the command-line option. -X , --verbose , or -Dsonar.verbose=true.

It’s currently just an assumption, but it’s possible that the issue is related to a specific file in your source code.

Best,
Yassin

Hello, thank you for the response!

The project is an NX monorepo with about 2,485 source {tsx,ts} files. 3,082 including index.{ts,tsx} or barrel files.

Each project and app have a base tsconfig.json that a tsconfig.lib.json and tsconfig.spec.json inherit from. However, SQ does not use tsconfig.spec.json. Only Jest does.

The entire project has a single tsconfig.base.json, located in the project root, that each sub tsconfig.json inherits from.

Roughly, we have the following number of TS config files:

  • tsconfig.base.json: 1
  • tsconfig.json: 33
  • tsconfig.lib.json: 28
  • tsconfig.spec.json: 29

Total: ~91

When I enable verbose or debug logging, the scan hangs on processing the files, repeating an empty INFO over and over:

# ...
15:22:08.575 DEBUG Declared patterns of language CloudFormation were converted to sonar.lang.patterns.cloudformation : 
15:22:08.575 DEBUG Declared patterns of language YAML were converted to sonar.lang.patterns.yaml : **/*.yaml,**/*.yml
15:22:08.575 DEBUG Declared patterns of language Go were converted to sonar.lang.patterns.go : **/*.go
15:22:08.575 DEBUG Declared patterns of language Kotlin were converted to sonar.lang.patterns.kotlin : **/*.kt,**/*.kts
15:22:08.575 DEBUG Declared patterns of language Secrets were converted to sonar.lang.patterns.secrets : 
15:22:08.575 DEBUG Declared patterns of language Ruby were converted to sonar.lang.patterns.ruby : **/*.rb
15:22:08.575 DEBUG Declared patterns of language C# were converted to sonar.lang.patterns.cs : **/*.cs,**/*.razor
15:22:08.575 DEBUG Declared patterns of language PHP were converted to sonar.lang.patterns.php : **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
15:22:08.575 DEBUG Declared patterns of language Terraform were converted to sonar.lang.patterns.terraform : **/*.tf
15:22:08.575 DEBUG Declared patterns of language AzureResourceManager were converted to sonar.lang.patterns.azureresourcemanager : **/*.bicep
15:22:08.576 DEBUG Declared patterns of language TypeScript were converted to sonar.lang.patterns.ts : **/*.ts,**/*.tsx,**/*.cts,**/*.mts
15:22:08.582 INFO  Preprocessing files...
15:22:08.591 DEBUG loading config FileBasedConfig[/Users/***/.config/jgit/config]
15:22:08.592 DEBUG readpipe [bash, --login, -c, which git],/Users/***
15:22:08.616 DEBUG readpipe may return '/usr/bin/git'
15:22:08.616 DEBUG remaining output:

15:22:08.616 DEBUG readpipe [xcode-select, -p],/Users/***
15:22:08.623 DEBUG readpipe may return '/Applications/Xcode.app/Contents/Developer'
15:22:08.623 DEBUG remaining output:

15:22:08.623 DEBUG readpipe [/usr/bin/git, --version],/usr/bin
15:22:08.651 DEBUG readpipe may return 'git version 2.39.3 (Apple Git-145)'
15:22:08.651 DEBUG remaining output:

15:22:08.651 DEBUG readpipe [/usr/bin/git, config, --system, --show-origin, --list, -z],/usr/bin
15:22:08.673 DEBUG readpipe may return 'null'
15:22:08.673 DEBUG remaining output:

15:22:08.699 DEBUG readpipe rc=128
15:22:08.699 DEBUG Exception caught during execution of command '[/usr/bin/git, config, --system, --show-origin, --list, -z]' in '/usr/bin', return code '128', error message 'fatal: unable to read config file '/etc/gitconfig': No such file or directory
'
15:22:08.700 DEBUG loading config FileBasedConfig[/Users/***/.config/git/config]
15:22:08.700 DEBUG loading config UserConfigFile[/Users/***/.gitconfig]
15:22:08.882 DEBUG 3737 non excluded files in this Git repository
15:22:18.588 INFO  
15:22:28.591 INFO  
15:22:38.596 INFO  
15:22:48.601 INFO  
15:22:58.607 INFO  
15:23:08.612 INFO  
15:23:18.617 INFO  
15:23:28.622 INFO  
15:23:38.627 INFO  
15:23:48.633 INFO  
15:23:58.638 INFO  
15:24:08.639 INFO  

The other thing is, this is only an issue locally. The sonar scan runs on CI just fine.

Thanks for sharing this!

Are these the only logs? Does the analysis eventually end?

It does eventually end, yes! No obvious errors or issues except for the total time reported as shown in my original post.

Hi,

We have created a ticket to improve the logs. This won’t solve the possible performance issue, but it might help to investigate.

1 Like

Much thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.