# Configure
# IntelliJ
# Import source code
- Open IntelliJ. If you have not used IntelliJ before, it should open the welcome screen. If you already opened a project, you can go to the welcome screen by closing the project. From the main menu, choose File > Close Project.
- In the welcome screen, on the left, select Customize.
- Select your preferred color theme.
- On the left, select Projects.
- Click Open.
- Open
<GITDIR>\senseeact
. - You may see a warning whether you trust the project. Check Trust projects in ... and then click Trust Project.
The project is now opened and built. You can see the progress at the bottom of the window.
# Recommended settings
We recommend to adjust some settings to match our source code.
- From the menu, choose File > Settings...
IntelliJ uses code folding where excerpts of code are replaced in the editor with some collapsed code. We recommend to disable this because it prevents you from seeing what is actually in the file.
- Select Editor > General > Code Folding.
- The options File header and Imports just collapse some code at the top of a file, so you can keep these, but we recommend to disable all other options.
IntelliJ reformats code when you paste something, which may mess up your formatting, so we recommend to disable this.
- Select Editor > General > Smart Keys.
- At Reformat on paste choose None.
Our source code uses a line length of 80 characters, which is comfortable to read and makes it possible to view two files side-by-side on most monitors.
- Select Editor > Code Style
- At Scheme, select the desired scheme. If you want to use our recommended settings as the default for all projects, you can select Default. Otherwise select Project or create a custom scheme with the settings icon.
- At Hard wrap at and Visual guides, enter 80.
Our source code uses Tab characters for indentation. IntelliJ uses spaces as a default, so we recommend to change it.
- Expand Editor > Code Style.
- Go through the file types Java, Groovy, HTML, JSON,
Kotlin, XML and Other File Types. For each type enable Tab
characters:
- Select the tab Tabs and Indents.
- Check Use tab character.
- Set Tab size and Indent to the same value of your preference (for example 4).
- Set Continuation indent to twice that value (for example 8).
IntelliJ uses inlay hints that are injected in your code, so your view does not reflect the file content and it can mess up your preferred line length and alignment. You can disable these inlay hints.
- Select Editor > Inlay Hints.
- Disable all inlay hints.
# Java settings
For the Java code we have some additional recommended settings, so keep the settings window open.
Our code does not use alignment of multiline code to prevent excessive indentation and mixing of tabs and spaces.
- Select Editor > Code Style > Java.
- Select the tab Wrapping and Braces.
- Disable all Align when multiline options.
- Select the tab JavaDoc.
- Disable Align parameter descriptions and Align thrown exception descriptions.
We disable some inspections that give unnecessary warnings for our code or that impact performance.
- Select Editor > Inspections.
- At Profile, select the desired profile. If you want to use our recommended settings as the default for all projects, you can select Default. Otherwise select Project Default or create a custom profile with the settings icon.
Disable the following inspections:
- Java > Code style issues > Field may be 'final'
Java > Declaration redundancy > Declaration can have 'final' modifier
We do not addfinal
to every declaration whose value doesn’t happen to change and often isn’t meant to be a constant. - Java > Code style issues > Reassigned variable
It often makes absolute sense to reassign a variable. Basically that’s what a variable is for. - Java > Control flow issues > Redundant 'if' statement
The suggested simplified statements often result in less clean and readable code. - Java > Data flow > Boolean method is always inverted
The reported methods are often more understandable the way they are, even if in the current use their result is always inverted. - Java > Declaration redundancy > Duplicate throws
Some methods can throw a generalException
as well as a meaningful more specific exception, so it makes sense to list the more specific exception in the throws clause. - Java > Declaration redundancy > Method always returns the same value
Methods are usually written this way so their signature is consistent with their context. - Java > Declaration redundancy > Method can be made 'void'
Java > Declaration redundancy > Method parameter is always the same value
Often the parameter or returned value is meaningful and just doesn’t happen to be used in this project. - Java > Declaration redundancy > Redundant 'throws' clause
This happens in subclasses where we keep a throws clause from the superclass just to show that a method is allowed to throw an exception, even if the current implementation does not throw it. - Java > Performance > String concatenation as argument to
'StringBuilder.append()' call
The concatenated arguments often make the code more clean and readable. - Java > Probable bugs > Nullability problems
The Java language intrinsically does not have a mechanism to avoid NullPointerExceptions. Solving this with annotations makes the source code overly verbose. - Proofreading
This impacts performance and gives many false warnings because of spell checking of code. - RegExp > Redundant character escape
This inspection often erroneously reports supposedly redundant character escapes that are however required.
Change this inspection:
- Java > Declaration redundancy > Unused declaration
Keep this enabled but at the options change everything from Public to Package-private. It doesn’t make sense to report public methods that we provide in a library but don’t happen to use in this project.
Finally click OK at the bottom.
# Visual Studio Code
# Settings
When you first open Visual Studio Code, you will see the Get Started screen where you can choose a color theme and set up additional things as you desire. When you’re done, click Mark Done.
Then we have some suggested settings for our source code. We use a maximum line length of 80 characters and we use Tab characters for indentation.
- From the menu, choose File > Preferences > Settings.
- In the search box, type “tab size”.
- Set Editor: Tab Size to your preference.
- In the search box, type “insert spaces”.
- At Editor: Insert Spaces, disable Insert spaces when pressing Tab.
- In the search box, type “render whitespace”.
- At Editor: Render Whitespace, select all. This way you can see Tabs and spaces and avoid that they are mixed up in your files.
- In the search box, type “rulers”.
- Under Editor: Rulers, click Edit in settings.json.
- Create this line:
"editor.rulers": [80]
- Save the file
settings.json
and then close it.
Visual Studio Code includes Git integration, but since we already installed a Git client, you may disable it in Visual Studio Code.
- Still in the settings, in the search box, type “git enabled”.
- At Git: Enabled, disable Whether git is enabled.
- Close the Settings.
# Open source code
- From the menu, choose File > Open Folder...
- Open
<GITDIR>\senseeact
. - You may see a warning whether you trust the files. Check Trust the authors of all files and then click Yes, I trust the authors.
- At the right bottom, Visual Studio Code will suggest to install the “Extension
Pack for Java”.
Do not install this. Click the settings icon and choose Don’t Show Again.
Now you can access all files from the left-hand sidebar.
The file explorer in Visual Studio Code has very small indentation, making it hard to see the hierarchy. You can increase it in the settings.
- From the menu, choose File > Preferences > Settings.
- In the search box, type “tree indent”.
- At Workbench > Tree: Indent you can increase the number of pixels, for
example to 24.
You may need to close and reopen the window for this to become effective.