Skip to content

SonarLint integration for Apache Netbeans

License

LGPL-2.1, Unknown licenses found

Licenses found

LGPL-2.1
LICENSE
Unknown
license-header
Notifications You must be signed in to change notification settings

philippefichet/sonarlint4netbeans

Repository files navigation

sonarlint4netbeans

SonarLint integration for Apache Netbeans

This plugin is a sonarlint integration for netbeans.
It requests netbeans in version 13.0 or higher and Java in version 11 or higher.

Features

  • Support Java, Javascript, PHP, HTML and XML

  • Annotation in editor

  • Type SonarLint in Action Items

  • "Analyze with SonarLint" action on Project/package/files, Favorites tab, …​

  • Enable/Disable Rules in Tools/Options/Miscellaneous/SonarLint

  • Filter Rules in Tools/Options/Miscellaneous/SonarLint option panel and "Sonar Rule Details" window

  • Change rule settings in Tools/Options/Miscellaneous/SonarLint or in "Sonar Rule Details" window

  • Enable/Disable/Configure Rules by project

  • Add or remove analyse properties (global or by project)

  • Restore selected rule from activated by default

  • Add or update plugins from configuration

  • Custom "Sonar Rule Details" window with CSS

  • Enable or disabled test rules on test files

  • Severity icons

  • Partial Support on C/C++ project (show README-CFamily)

Release 2.x to 3.x

Plugins

SonarLint no longer uses URLs to find plugins but file paths.
You have to update the path to the plugins you added in Tools → Options → Miscelaneous → SonarLint → Plugins.

Analyse properties

Now global properties and project properties are merged on files belonging to a project.
${projectDir} is now replaced by the absolute path of the project for files belonging to it.

Release 1.x to 2.x

Release 2.0.0 want publish this plugin in new Netbeans portal based on Maven central repository.
For this, all package are renamed and have

Preferences

In Netbeans User dirrectory move config/Preferences/fr/philippefichet/sonarlint/netbeans.properties to config/Preferences/com/github/philippefichet/sonarlint4netbeans/netbeans.properties.

You can found Netbeans User directory in menu Help/About.

"Analyze with SonarLint"

You can run an "Analyze with SonarLint by context menu (click right) on project, folder, many file, …​
This action is visible directly in context menu on through Tools sub menu.

SonarLintAnalyzerOnProject
Figure 1. Analyze with SonarLint on project
SonarLintAnalyzerOnFavorites
Figure 2. Analyze with SonarLint in Favorites tab

Rule settings

You can change rule settings by left click on this icon icon settings in Tools/Options/Miscellaneous/SonarLint or in "Sonar Rule Details" window.

When a rule has no settings, this icon icon settings empty is present.

SonarRuleDetailsWindowWithNameFilter
Figure 3. Sonar rule details window with name filter

Analyse properties (global or by project)

Properties can be added to the analysis by SonarLint, either globally or by project.+

Add or update plugins from configuration

It is possible to add a plugin compatible with SonarLint by indicating a key and the URL of the plugin.
To avoid downloading the plugin each time it is used, it is recommended to download the plugin and use the file scheme

Example:

file:/c:/path/to/plugin.jar (1)
file:/path/to/plugin.jar (2)
  1. On Windows

  2. On Linux or MacOS

"Sonar rule details" window StyleSheet

You can customize "Sonar rule details" with CSS.

Go to Tools/Options/Miscellaneous/SonarLint and click on "Options" and on button "Edit stylesheet for sonar rule detail window".

Important

CSS is limited by javax.swing.text.html.CSS, consult the documentation to know the supported properties.

Screenshot

JavaEditorAnnotationAndActionItems
Figure 4. SonarLint in Java editor and show action items for selected project
JavascriptActionItems
Figure 5. Show Action Items fo currently edited file only
SonarLintAnalyzerOnProject
Figure 6. Analyze with SonarLint on project
SonarLintAnalyzerOnFavorites
Figure 7. Analyze with SonarLint in Favorites tab
OptionsSonarLintAnalyzers
Figure 8. SonarLint analyzer name and version
OptionsSonarLintRules
Figure 9. SonarLint rules enabled or disabled
OptionsSonarLintRulesWithKeyFilter
Figure 10. SonarLint rules enabled or disabled with key filter
OptionsSonarLintRulesWithNameFilter
Figure 11. SonarLint rules enabled or disabled with name filter
OptionsSonarLintRulesRestoreToDefaultBefore
Figure 12. Restore selected rule from activated by default (before)
OptionsSonarLintRulesRestoreToDefaultAfter
Figure 13. Restore selected rule from activated by default (after)
OptionsSonarLintProperties
Figure 14. Add or remove analyse properties
OptionsSonarLintPlugins
Figure 15. Add or update plugins from configuration
SonarLint Options

image::docs/OptionsSonarLintOptions

SonarRuleDetailsWindowWithKeyFilter
Figure 16. Sonar rule details window with key filter
SonarRuleDetailsWindowWithNameFilter
Figure 17. Sonar rule details window with name filter
SonarRuleDetailsWindowWithCustomStyleSheet
Figure 18. Sonar rule details window with custom style
SonarRuleDetailsWithSettingsNoChangeJavaS1067
Figure 19. Sonar rule details window without change settings on java:S1067 rule
SonarRuleDetailsWithSettingsChangeJavaS1067
Figure 20. Sonar rule details window with change to "5" the "max" settings on java:S1067 rule
SonarLintProjectOptions
Figure 21. SonarLint global or project rules
SonarLintProjectRules
Figure 22. SonarLint Enable/Disable/Configure Rules by project
SonarLintProjectProperties
Figure 23. SonarLint Add or remove properties by project