Changing the variable name regex in VSCode Sonarlint

Hi. I am a first time user of Sonarlint. I am a mentor on a FIRST High School Robotics Competition team. We are a register 501(c)3. And I just came across Sonarlint in the VSCode extension marketplace, so I really knew nothing about it until this week. I really would like the first time programmers on the team to get into the habit of writing good code rather than code that “just works” and static analysis like Lint is a big step in that direction.

So, as it happens, we immediately ran afoul of java:S116, “Field names should comply with a naming convention.” We use underscores in our variables. From the description, it appears that this regex can be changed: “Following parameter values can be set in the SonarLint:Rules user settings. In connected mode, server side configuration overrides local settings. format Regular expression used to check the field names against. (Default value: ^[a-z][a-zA-Z0-9]*$)”

My problem is that I can’t figure out how to change it. When I look for “sonarlint” in the settings page, I get a few options, but they mostly seem to deal with setting up “connected mode”. Does anyone know exactly what I need to do to change this value?

Now, that having been said, we would really like to be able to have any customizations made to these rules be shared by the whole team. Worst case scenario would be to record changes and try to maintain the discipline to have each user manually enter the changes on their laptops. Better would be checking the file used (if any) into the GIT workspace we use. Better still would be to use “connected mode”. The problem with that is we have literally no budget for doing something like that. Is there a free service for that we could use? Does our being a non-profit help with that? If so, how do I get started? We generally have between 10 and 20 software users each season, if that is an issue.

Thank you for any help you can provide.

1 Like

Hello Brian,

I am very sorry for this late response.

So first, some rules indeed have parameters that can be customized. When you open SonarLint settings (File> Preferences > Settings > User > Extensions > SonarLint), you will notice a rule section and a link to “Edit in settings.json”:

To customize a parameter you will need the rule key and parameter name. They can be found in the rule description. To open it, right click on a diagnostic in the Problems view and click ‘SonarLint: Open description of rule ‘XXX:YYYY’’, copy the rule key and parameter name:

So you should end up with something like this in the user’s settings.json file:

"sonarlint.rules": {
    "java:S116": {
        "level": "on",
        "parameters": {
            "format": "[a-z]"

This will apply the setting for the user’s SonarLint only. This product is well integrated in the Sonar ecosystem, so if you want to share configuration with a team, you can use either SonarQube or SonarCloud. They both have free options for open source projects, and they bring much more than just sharing settings between developers. You can find more details here.

Hope this helps, and thanks for using SonarLint!