Get line wrap width from .editorconfig max_line_length instead of custom Sonar XML config

The “Line too long” rule in Sonar lint (S103 - SonarCloud) has a maximumLineLength parameter which by default is set to 200 characters. This can be overridden by using a custom Sonarlint XML for each project.
If you have other formatters that read the .editorconfig settings to get the max_line_width for project line wrap settings, then Sonarlint will have to be updated separately for the S103 warnings (An example of such a formatter would be CSharpier - using the .editorconfig configuration).

I propose having the maximumLineLength first use custom Sonar XML overrides, and if there are no overrides for S103 it should use the .editroconfig setting max_line_width as a fallback before using the built-in default value.

This will reduce the number of places you need to update and sync to get a consistent line wrap config for your project.
These priorities should preferably also be used by SonarCloud during CI jobs.

1 Like

Hi @OddMathisenNOV ,

Thank you for your feedback. I think that makes a lot of sense. I have raised a ticket for the team so that we can discuss this internally.

We have had a discussion internally and this is not something we plan to implement. The approach we prefer is to have SonarLint running in connected mode with SonarCloud/SonarQube. That way all users of SonarLint can inherit the line length parameter set once centrally on SonarCloud/SonarQube. Setting it at the user-system level would break that ‘one rule for all’ approach.

I appreciate that this doesn’t help with having one setting point that is consumed by multiple pieces of software on a user’s system, but at this time we do not see a way to make this work in the general case.