Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Triquetrum/Coding Style"
(Formatter and Cleanup styles) |
(Added instructions about importing settings.) |
||
Line 5: | Line 5: | ||
CamelCase variable and method names are preferred over underscores. | CamelCase variable and method names are preferred over underscores. | ||
+ | |||
+ | As a Triquetrum workspace consists of many projects, we set up the style for the entire workspace as opposed to configuring each project. | ||
== Configuring Eclipse Formatter Preferences for Triquetrum == | == Configuring Eclipse Formatter Preferences for Triquetrum == | ||
If you intend to submit a pull request, please set your formatter preferences as follows: | If you intend to submit a pull request, please set your formatter preferences as follows: | ||
+ | # Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Formatter | ||
+ | # Click on Import | ||
+ | # Browse to org.eclipse.triquetrum.common/triquetrumFormatterSettings.xml and import it | ||
+ | |||
+ | === Configure the Formatter Preferences By Hand === | ||
+ | If you choose not to import the settings file above, then below are the steps necessary to configure the formatter: | ||
+ | |||
# Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Formatter | # Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Formatter | ||
# Click on New, then enter a name like "Triquetrum Code Style Formatter". Keep the default initialization on "Eclipse [built-in]". Click OK | # Click on New, then enter a name like "Triquetrum Code Style Formatter". Keep the default initialization on "Eclipse [built-in]". Click OK | ||
Line 23: | Line 32: | ||
## Then Click on OK | ## Then Click on OK | ||
− | == Configuring Eclipse | + | == Configuring Eclipse Clean Up Preferences for Triquetrum == |
+ | |||
Cleaning the code is a good idea. If you intend to clean the code, make the following changes: | Cleaning the code is a good idea. If you intend to clean the code, make the following changes: | ||
+ | # Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Clean Up | ||
+ | # Click on Import | ||
+ | # Browse to org.eclipse.triquetrum.common/triquetrumCleanUpSettings.xml and import it | ||
+ | |||
+ | === Configure the Clean Up Preferences By Hand === | ||
+ | If you choose not to import the settings file above, then below are the steps necessary to configure the clean up facility: | ||
+ | |||
# Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Clean Up | # Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Clean Up | ||
# Click on New, then enter a name like "Triquetrum Clean Up". Keep the default initialization on "Eclipse [built-in]". Click OK | # Click on New, then enter a name like "Triquetrum Clean Up". Keep the default initialization on "Eclipse [built-in]". Click OK | ||
Line 41: | Line 58: | ||
== See Also == | == See Also == | ||
+ | * [https://github.com/eclipse/triquetrum/blob/master/CONTRIBUTING.md Triquetrum/CONTRIBUTING.md] - How to contribute to Triquetrum. | ||
* [[Coding Conventions]] | * [[Coding Conventions]] | ||
− | * [https://dev.eclipse.org/mhonarc/lists/incubation/msg00142.html | + | * [https://dev.eclipse.org/mhonarc/lists/incubation/msg00142.html Eclipse Incubation Mailing List discussion about coding style] |
Revision as of 17:45, 28 June 2016
Contents
Coding Conventions
In general, we follow the Eclipse Coding Conventions, with the following changes:
- indentations are 2 spaces, no TABs
- longer lines (160 chars)
CamelCase variable and method names are preferred over underscores.
As a Triquetrum workspace consists of many projects, we set up the style for the entire workspace as opposed to configuring each project.
Configuring Eclipse Formatter Preferences for Triquetrum
If you intend to submit a pull request, please set your formatter preferences as follows:
- Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Formatter
- Click on Import
- Browse to org.eclipse.triquetrum.common/triquetrumFormatterSettings.xml and import it
Configure the Formatter Preferences By Hand
If you choose not to import the settings file above, then below are the steps necessary to configure the formatter:
- Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Formatter
- Click on New, then enter a name like "Triquetrum Code Style Formatter". Keep the default initialization on "Eclipse [built-in]". Click OK
- In the Profile window make the following changes
- In the Indentation tab (Erwin is the primary developer of Triquetrum and prefers two space indents):
- Tab Policy: select "Spaces Only"
- Indentation size: 2
- Tab size: 2
- In the New Lines tab (Christopher likes to run scripts on source files, so they need newlines):
- Click on "at end of file"
- In the Line Wrapping tab (Erwin likes long lines):
- Maximum line width: 160
- In the Comments tab:
- Maximum line width for comments: 160
- Then Click on OK
- In the Indentation tab (Erwin is the primary developer of Triquetrum and prefers two space indents):
Configuring Eclipse Clean Up Preferences for Triquetrum
Cleaning the code is a good idea. If you intend to clean the code, make the following changes:
- Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Clean Up
- Click on Import
- Browse to org.eclipse.triquetrum.common/triquetrumCleanUpSettings.xml and import it
Configure the Clean Up Preferences By Hand
If you choose not to import the settings file above, then below are the steps necessary to configure the clean up facility:
- Open the Formatter preferences: Under Mac OS X, Eclipse -> Preferences -> Java -> Code Style -> Clean Up
- Click on New, then enter a name like "Triquetrum Clean Up". Keep the default initialization on "Eclipse [built-in]". Click OK
- In the Profile window make the following changes:
- In the Code Organizing tab:
- Format source code: checked
- Remove trailing whitespace: checked
- Correct Indentation: checked
- Organize imports: checked
- Sort Members: not checked (this might change in the future)
- In the Code Style tab:
- Use blocks in if/while/for/do statements: checked (Blocks in if statements make it easier to avoid bugs that occur when a second line is added to just after the if statement)
- In Unnecessary Code tab:
- Remove unused private members: checked
- Remove unused local variables: checked
- In the Code Organizing tab:
See Also
- Triquetrum/CONTRIBUTING.md - How to contribute to Triquetrum.
- Coding Conventions
- Eclipse Incubation Mailing List discussion about coding style