How do you customize SonarLint rules in IntelliJ IDEA? - intellij-idea

Is it possible to have SonarLint for IntelliJ IDEA enforce only the rules I have enabled on my Sonar server?

As it is now possible with the current release of SonarLint (I'm using version 3.0.0.2041), people might be interested in the solution.
File -> Settings -> Other Settings -> SonarLint General Settings
Click on the green + in "SonarQube servers" :
Enter a name (ex : SonarQube / localhost)
Select SonarQube and enter URL like http://localhost:9000
Authentication : select your user token or your login/pwd
Click on Finish
Click on "Update binding" to synchronize with the SonarQube server
Go to SonarLint Project Settings and bind your project to the SonarQube project
Thus, when you open your files, SonarLint will automatically retrieve the SonarQube server's issues.

SonarLint 1.0 for Eclipse and IntelliJ do not allow to edit the quality profile (or set of rules) to be used for the analysis. Moreover, SonarLint 1.x works completely independently of a SonarQube server (having a SonarQube server is not a requirement), and therefore does not have the ability to reuse a quality profile defined there.
SonarLint 2.0 will have an optional mode that connects to a SonarQube server, and will offer this feature - but this isn't available yet.

For Android Studio Chipmunk , Dolphin 2022, Bumblebee and Arctic Fox
File >> Settings >> Tools >> SonarLint >> Rules
Then select your project language and any rule then check/uncheck it, you can edit its options (if exist)

These connections settings for SonarLint in the latest version of IntelliJ (2020.2) are in the Preferences window at Tools>SonarLint>Project Settings.

Related

How to turn off SonarLint automatic triggering on IntelliJ IDEA

Is there some way of turning-off automatic SonarLint analysis in Intellij IDEA?
I have some 10,000 to 20,000 lines-of-code classes (don't ask, not my fault, trying to refactor). Every time I edit even a single character in the class, the SonarLint plugin makes IDEA unusable for a few minutes.
It is not possible to save the "Automatically trigger analysis" checkbox in the unchecked state in Other Settings > SonarLint General Settings. Is there some other solution to my problem? I really want to use the plugin. I just can't use it in automatic mode.
For intellij:
Go to File -> Settings
New window will open
In new window
Expand tools -> locate SonarLint and click on it.
Under settings tab of SonarLint -> uncheck the box 'Automatically trigger Analysis'.
Go to File -> Settings -> Other Settings -> SonarLint General Settings then
uncheck the Automatically trigger analysis check box
There was a bug in SonarLint for IntelliJ that prevented the configuration to be properly saved.
It was fixed in the latest version 2.3.2:
https://jira.sonarsource.com/browse/SLI-106
About the performance, please make sure you are using the Java analyzer 4.2, as you might be experiencing this problem: https://jira.sonarsource.com/browse/SLI-100.
It is embedded in the latest SonarLint, but if you use the connected mode, you also need to check which version of the Java analyzer is installed in the SonarQube server.
We are always trying to improve performance, so feel free to open a topic in the SonarLint Google group with the verbose analysis log so that we can investigate why it takes so long to analyze the file.
In Android Studio 3.5.2:
Go to File -> Settings -> Tools -> SonarLint -> Settings(Tab) then uncheck the Automatically trigger analysis check box.

IntelliJ Run Configuration Broken by an Incompatible Plugin I Can't Uninstall?

I had been developing an application on a trial version of IntelliJ 2016 Ultimate. Since the trial version ran out, I resumed work using the Community Edition. However, trying to launch my application yielded the following error:
Unknown run configuration type #com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory
"No problem" I thought, just an incompatible plugin that was installed with Ultimate that I don't really need anyway. I opened the Plugins section of the Preferences menu, but I can't find the plugin in question. Below is a partial screenshot of the plugin list where I would expect to see the plugin listed in the error message.
The configuration can also not be edited from the Run/Debug Configurations menu, but lists the Run Configuration error as: "Broken configuration due to unavailable plugin or invalid configuration data."
Am I really unable to uninstall the Ultimate plugin preventing my run configuration from working from the Community Edition? What can I do to fix this if so?
It's have been a long time since this question was launched but it might be useful for new searches.
I got the same error with Dart and Flutter.
Just go to Menu >> File >> Settings. Then type plugins on the search box. Check if your plugins need to be updated (in my case Dart and Flutter). I the screenshot I had clicked in the "update" green button. So it turns into "Restart IDE" text. It should fix the problem once you restart the IDE.
To the best of my knowledge the community edition of IDEA will not load and run plugins that are not compatible with it. Moreover, by default, the community edition uses a different configuration directory than the Ultimate edition. So unless you modified the config directory to use, the community version should not be picking up the Ultimate Edition's plugins. Based on the error you show, I think the issue is you simply need to delete that Run configuration. The error is saying that that Run configuration wants to use a Plugin (The Tomcat Plugin) that is not available (i.e. not installed).
If you still want to confirm what plugins are installed, you can manually uninstall a plugin by removing it from the plugins directory. Note that some plugins are simply a standalone JAR, in the plugins directory, others are sub-directories within the plugins directory. Just delete the JAR or sub-directory.
That plugins directory is the idea config directory. See Directories used by the IDE to store settings, caches, plugins and logs for information on its location. On windows for example, by default it will be:
Ultimate: C:\Users\UserName\.IntelliJIdea2016\config\plugins
Community: C:\Users\UserName\..IdeaIC2016\config\plugins
UPDATE
I forgot to mention... bundled plugins are in ${idea-install-directory}/plugins. So for the ultimate edition, the Tomcat plugin is in ${idea-install-directory}/plugins/Tomcat. That is why, as you mentioned in your comment below, you are not seeing that plugin in the user installed plugin directory I mentioned above.
updating flutter and android studio worked in my
case
Simple upgrade Dart plugin..
Go to Settings/Plugins/Browse Repositories and search dart (Language) and upgrade
this will work.
I had a similar worded issue "Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data."
In the bottom right part of the Rider IDE, you will see a popup that says
"Plugin supporting feature (Run Configuration[UNITY_ATTACH_AND_PLAY]) is currently disabled."
Click enable plugins, and restart when Rider asks you to do so.
If this does not work, remember that one possible reason is the issues with macOS indexing (my Macbook started to malfunction after its battery hit 0). A way to check is to try and search a file from the top right corner(). If you can not find existing files, this means macOS messed up with indexing.
To solve it, click Apple icon on top left side and go to System Preferences -> Spotlight -> Privacy Tab -> Add all folders to the "won't index" box -> Remove everything you have added so they get reindexed.
https://www.techradar.com/how-to/software/operating-systems/how-to-fix-a-mac-s-broken-find-function-1298964
Lastly, go to Rider and hit File -> Invalidate Caches and Restart.

SonarLint : What does SonarQube project option do?

I am using SonarLint plugin for IntelliJ and when setting this up it gives me the option to select a SonarQube project from the list of all SonarQube projects available as you can see in the picture below
What exactly does this do when I select a particular project as I am not exactly clear on this and it does not explain on the SonarLint main site?
Does it take the rules for the selected project and use these rules for any project I am working on in IntelliJ?
This option sets up "Connected Mode" so that, as you guessed, the rule set applied to your project matches the one on your server.
You explicitly connect a single workspace project to a single SonarQube project. The default rule set(s) will be used on un-connected projects.

Connected Mode on SonarLint v2.0 on IntelliJ not working?

SonarLint v2.0 for IntelliJ is out now, and has this "connect to sonar server" feature, but even so, it seems it isn't in sync with my server rules.
http://www.sonarlint.org/intellij/#Connected
Is it working for someone?
I'm I missing a step?
Or could it be a bug?
Thanks!
IntelliJ Idea Version: 2016.1
SonarLint Version: 2.0.1
SonarQube Version: 5.4
SonarLint, as of now, won't work with third party analyzers like PMD or FindBug, if you are using those, they will simple be ignored.
You can update your rules in SonarQube Server to only use rules defined in the SonarQube repository, most of them have an equivalent version.
Please check SonarLint console for details and open a thread on SonarLint Google group so that we can investigate.

Enable Perforce in all IntelliJ windows

For some reason, Perforce is working on one project window but not the other. Does anybody know what I have do to make intellij recognize that the current project uses perforce. I have checked the Settings -> Version Control -> Perforce settings. Settings are good, I was able to connect.
I am lost, any help is appreciated.
VCS -> Enable VCS Integration
Note that the this option is not visible if VCS Integration is already enabled.