Respect .editorconfig configuration in the SonarQube code viewer

It would be great if the SonarQube code viewer could format code according to .editorconfig configuration.

We have the following configuration:

root = true

charset = utf-8
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

but the indent is represent as 8 spaces.

  • SonarQube:
    SonarQube code viewer
  • GitHub:
    GitHub code viewer


Hello @agabrys!

I’m curious: why is it important that the code viewer in SonarQube uses the same indentation strategy as in the editor?

Hello Fabrice,
To be honest, I don’t need exactly the same indentation strategy. Some people prefer spaces, other prefer tabs. I’m fine with it :wink: There is one common thing for both approach. The size is usually between 2 and 4. I prefer 4, it is not too big and not too small. SonarQube displays tabs as 8 spaces, and it sometimes makes code difficult to read (people have to scroll). That is the reason why I proposed to use the same formatting - it would be the best. I know it is probably quit difficult to implement (not worth the effort). If you could just make the tabs smaller - I would be also satisfied :wink:


Do’h, looks like there is an old ticket about this problem! => SONAR-11552

A fix is already on its way thanks to @Jonathan_Weibel!

1 Like