-
Notifications
You must be signed in to change notification settings - Fork 41
Eclipse Settings
This page collects advanced settings and plugins for Eclipse. Before you use them, make sure you have successfully configured Ultimate in Eclipse because the setup takes some time.
The following plugins help you analyze your code automatically.
You can install them via the Eclipse Marketplace (Help
-> Eclipse Marketplace...
) or just follow the links below and drag the install icon in your Eclipse window.
- SonarLint
- Checkstyle Plug-in (Note: There are other plugins with the prefix "Checkstyle".)
- FindBugs Eclipse Plugin
You have to restart Eclipse afterward. SonarLint synchronizes its rules with our SonarQube server. Checkstyle and FindBugs use local rules, so reports might not always be accurately mirrored without servers. In most cases, the reports should still be valid.
Below are our configuration suggestions.
Instructions for SonarLint for Eclipse 4.1, March 2019.
- Go to
Window
->Show View
->Other...
, typeSonarLint Bindings
, and select it. - Find the new SonarLint Bindings view in your workspace and select
Connect to a SonarQube server...
(only displayed when you did not already connect to some server. Alternatively you can right-click inside the SonarLint Bindings view and selectNew Server connection...
). - Select SonarQube.
- Use the following URL:
https://sonar.sopranium.de
. - Select Username + Password (or generate a personal token if you have an SSO account).
- Username:
ultimate
- Password:
ultimate
- Username:
- Keep the connection name
sonar.sopranium.de
.
- In the Project Explorer view or Package Explorer view, mark the projects you want to work with.
If you want to work with all projects, mark them as follows.
- Mark all projects in your Ultimate workspace.
- Unmark all projects that already have Sonar bindings.
- Unmark non-Java projects like Servers,
BA_*
,Web*
. - Unmark all test projects (end in
Test
).
- Right-click on the marked projects and select
SonarLint
->Bind to SonarQube or SonarCloud...
.- Keep the pre-selected server
sonar.sopranium.de
and clickNext >
- Enter
de.uni_freiburg.informatik.ultimate:mavenparent
and clickFinish
.
- Keep the pre-selected server
You may want to deactivate sending anonymous data: Window
-> Preferences
-> SonarLint
-> Miscellaneous
-> Share anonymous SonarLint statistics
If you want to deactivate the automatic analysis of all files, you have to right-click a project in the Package/Project Explorer, go to SonarLint
, and uncheck Run SonarLint automatically.
This creates a folder .settings
in the respective project folder.
Instead of manually setting this option for all projects that you want to exclude, you can copy this folder to the respective project folders.
Linux users may want to use this script which creates the folder in all projects.
If you deactivate automatic analysis, you may want to set a shortcut key for manual analysis of the currently opened source file. See the description below for how to set shortcut keys - the name of the setting is Analyze.
- SonarLint automatically analyzes your files (during build, when you save, etc.) unless you deactivated it.
To manually run an analysis, right-click a project, package, or source file in the Package/Project Explorer and select
SonarLint
-> Analyze (or use the shortcut key if you have configured it). - The analysis results are shown in a separate view called SonarLint Report.
The view should open whenever an analysis terminates, but you can also find it under
Window
->Show View
-> Other... after typing SonarLint Report. - You can right-click a line in the SonarLint Report view and select Rule description. This opens another view with more explanations.
In certain cases, it may be necessary to tell SonarLint that it should ignore a rule because it is justified in this particular case.
You can use the annotation @SuppressWarnings("<ruleid>")
or @SuppressWarnings({"<ruleid1>", "<ruleid2>",...})
for this purpose.
The suppressed warning will still show up as violation of rule S1309, but this rule has just information level and serves as reminder for all the places where warnings were ignored.
Eclipse will per default also issue a warning about an unknown warning type.
To configure Eclipse to ignore those unknown warning types, go to Window
-> Preferences
-> Java
-> Compiler
-> Errors/Warnings
-> Annotations
and change Unhandled token in '@SuppressWarnings'
from Warning to Ignore.
Go to Window
-> Preferences
-> Checkstyle
- New -> External Configuration File -> Enter some name (e.g., Ultimate) and the location of this configuration file.
- Set the new configuration as default (Set as Default).
- Eclipse asks you to do a full rebuild afterward.
- You have to start the analysis manually.
Right-click a project, package, source file, or the currently opened source file and select
Checkstyle
-> Check Code with Checkstyle. - To see the results, go to
Window
->Show View
-> Other..., type Checkstyle violations, and select it. - You can double-click or right-click a violation type to see all occurrences.
- To clear the logs, right-click the respective files and select
Checkstyle
-> Clear Checkstyle violations.
Go to Window
-> Preferences
-> Java
-> FindBugs
-
Reporter Configuration:
Activate
Malicious code vulnerability
andSecurity
-
Plugins and misc. Settings:
Deactivate
FindBugs Communal ...
andFindBugs Cloud ...
- Detector configuration: Activate all detectors except CheckExpectedWarnings, EmptyZipFileEntry, and PublicSemaphores
- You have to start the analysis manually.
Right-click a project, package, source file, or the currently opened source file and select
Find Bugs
-> Find Bugs. - To see the results, go to
Window
->Show View
-> Other..., type Bug report, and select it. - You can right-click a bug report and select Show Bug Info for more information.
- To clear the logs, right-click the respective files and select
Find Bugs
-> Clear Bug Markers.
-
Use the Package Explorer instead of the Project Explorer. It allows you to select all projects at once and refresh (Ctrl+A, F5) even if you have closed projects in the selection. You find it under
Window
->Show View
. -
If you want to set the default user name that is predefined, e.g., when you create a new class documentation, edit your
eclipse.ini
file in the installation folder of Eclipse. Adapt the following line and insert it after -vmargs:-Duser.name=John Doe ([email protected])
You can also set the amount of memory dedicated to Eclipse in this file. The changes only apply after you restart Eclipse.
-
You may want to change or set shortcut keys. Go to
Window
->Preferences
->General
->Keys
, choose the respective action, click the free space next to Binding, and enter the key combination. Existing assignments have to be deleted first (Backspace). -
To activate Java source view (for built-in classes) you need to download the sources (e.g., under Linux there are usually packages called
java-1.8.0-openjdk-src
or similar). Then go toWindow
->Preferences
->Java
->Installed JREs
, double-click your Java version, select rt.jar, click Attach Sources, and choose the path to the source file src.zip. Under Linux this file is usually situated in /usr/lib/jvm/java-1.8.0-openjdk-***/. Eclipse may automatically find the file. -
To speed up the start, you can deactivate plugins in
Window
->Preferences
->General
->Startup & Shutdown
. There you can also set the option Refresh workspace on startup. -
To shrink package names in the Package Explorer, go to
Window
->Preferences
->Java
->Appearance
, check the option for Compress all ..., and enter some pattern, e.g.,2.
for two-letter abbreviations. -
Set the print margin to 120 symbols. Go to
Window
->Preferences
->General
->Editors
->Text Editors
, check Show print margin, and set the number to 120. -
If you want to use a dictionary, go to
Window
->Preferences
->General
->Editors
->Text Editors
->Spelling
and choose the path. -
If you want to change code annotations (e.g., yellow underlining of warnings), go to
Window
->Preferences
->General
->Editors
->Text Editors
->Annotations
and choose your settings.
- Home
- Ultimate Development
- Ultimate Build System
- Documentation
- Project Topics