EditorConfig
The EditorConfig file (.editorconfig) defines the basic code formatting rules for the TNB project.
Key configuration rules
The TNB EditorConfig enforces the following standards:General settings (all files)
General settings (all files)
- Charset: UTF-8
- Line endings: LF (Unix-style)
- Indent style: Spaces
- Indent size: 4 spaces
- Max line length: 150 characters
- Final newline: Required
- Tab width: 4
Java files
Java files
- Indent style: Space
- Continuation indent: 4 spaces
- Brace style: End of line
- Line wrapping: Enabled for long lines
- Import organization: Single class imports (no wildcards)
- Blank lines: 1 after imports and package declaration
Other file types
Other file types
- JSON/YAML: 2-space indentation
- Shell scripts: 2-space indentation
- Feature files: 2-space indentation
- Markdown: Space indentation
IntelliJ IDEA setup
Enable EditorConfig plugin
The EditorConfig plugin is typically enabled by default in modern IntelliJ IDEA versions. If not, enable it in Settings → Plugins.
Configure code style settings
- Go to Settings → Editor → Code Style
- Check Enable EditorConfig support (if not already enabled)
- In Formatter Control, check Enable formatter markers in comments
Optional: Automatic formatting on save
Install the Save Actions plugin to automatically reformat code and organize imports on each save.
CheckStyle
CheckStyle enforces Java-specific coding standards beyond basic formatting.Key checks enforced
The TNB CheckStyle configuration (checkstyle/checkstyle.xml) includes:
Whitespace and formatting
Whitespace and formatting
- No tab characters in source files
- Proper spacing around operators, parentheses, and type casts
- Empty line separator between class members (no multiple empty lines)
- Generic whitespace rules for
<and>tokens
Naming conventions
Naming conventions
- Class names: PascalCase
- Method names: camelCase (format:
^[a-z][a-zA-Z0-9_]*$) - Variable names: camelCase (format:
^[a-z][a-zA-Z0-9_]*$) - Constants: UPPER_CASE
- Type parameters: Single uppercase letters
Import rules
Import rules
- No wildcard imports (
*) - No unused imports
- No redundant imports
- Specific import order with groups:
software.tnborg.jboss.fuse.tnborg.junitorgcomjavaxjava
- Static imports at the top
- Groups separated by blank lines
Code structure
Code structure
- Maximum line length: 150 characters
- Maximum anonymous inner class length: 50 lines
- Braces required for all control statements
- Left curly brace at end of line
- Switch statements must have
defaultclause - TODOs must be named:
TODO(username): description
Best practices
Best practices
- String literals on left side of
equals()comparisons - No direct instantiation of
java.lang.Boolean - Simplified boolean expressions and returns
- Utility classes must have private constructors
- Proper use of
@Overrideand@Deprecatedannotations
IntelliJ IDEA setup
Install CheckStyle plugin
- Go to Settings → Plugins
- Search for CheckStyle-IDEA
- Install the plugin and restart IntelliJ IDEA
Configure CheckStyle version
- Go to Settings → Tools → Checkstyle
- Set Checkstyle version to any version from
8.24to8.43 - If the configuration file loads successfully after selection, you’re good to go
Set error handling preference
Set Treat Checkstyle errors as warnings according to your personal preference.
Add configuration file
- In the Configuration File section, click the + button
- Select Use a local Checkstyle file
- Browse to the
checkstyle/checkstyle.xmlfile in the TNB repository - Add a description (e.g., “TNB configuration”)
- Click OK
After completing the setup, CheckStyle will automatically validate your code as you work. Pay attention to warnings and errors to ensure your code meets the project standards.
Formatter control
You can temporarily disable the formatter in specific code sections using special comments:Use formatter control comments sparingly and only when absolutely necessary. In most cases, it’s better to follow the standard formatting rules.