-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
@ctrueden I wonder. Since the mastodon-coding-style is an "improved" version of the imglib2-coding-style. Should we just replace it? Or is adding a new coding style the better option.
Site note: I would consider imglib2-coding-style as broken. Since it removes many line breaks that actually should be there and but also introduces many annoying line breaks due to the very short line length. So I would say mastodon-code-style is the fix, that makes imglib2-coding-style pratically useful. So I would be in favor of replacing the imglib2-coding-style.
maarzt
commented
Jan 23, 2023
This pull request is related to: mastodon-sc/mastodon#224
Since the mastodon-coding-style is an "improved" version of the imglib2-coding-style. Should we just replace it?
@maarzt I would vote to replace it, yeah. But the decision is really up to @tpietzsch and @axtimwalde and @StephanPreibisch!
maarzt
commented
Jan 25, 2023
Since the mastodon-coding-style is an "improved" version of the imglib2-coding-style. Should we just replace it?
Non of the imglib2 repos actively use the "scijava.coding-style" property. So they are not directly affected.
I could only find one repo on github that uses the "scijava.coding-style" property and sets the value to "imglib2". The repo is TrackMate-TrackAnalysis and @imagejan did introduce the scijava.coding-style property. That is why I'm particularly keen to know your opinion @imagejan on the question above.
imagejan
commented
Jan 25, 2023
👍 I'm absolutely fine with replacing. The TrackMate-TrackAnalysis repository is archived and deprecated, as the functionality moved into TrackMate core.
Update "CodeFormatterProfile" to version="22". The formatter settings XML was simply imported into Eclipse and exported again. (Eclipse version 4.26.0)
The changes have the following effects: * Manually placed line brakes are preserved. (If there a very long expression. The programmer may add line breaks to organize the expression logically into multiple lines. The formatter will keep those line breaks.) * Method headers, etc. are no longer forced to be in one line. The formatter breaks them if they are longer than 140 character. * Don't format comments.
This change is made in order to better support the long class names that are part of imglib2 like "RandomAccessibleInterval" . The long class names easily produces long lines of code. Breaking these long lines with a code formatter leads to less readable code. The line width is increased here in order to avoid a fight between developers and code autoformatting :)
This is how an if statement will be formatted:
if ( a == 0 ) {
return null;
}
Instead of:
if ( a == 0 )
{ return null; }
This commit configures the formatter on/off tags. Previously the setting seemed to have been ignored. With the new version of the formatter settings XML we need to set the values properly, to make the formatter:on/off tags work. A comment like this in the java source code, turns off the formatting off for the following lines: // @Formatter:off Formatting can be turned on again with: // @Formatter:on
A comment is not indented if the comment starts at the beginning of the line. The main impact of this is that the code formatter no longer changed the indentation of uncommented code.
The IntelliJ code formatter settings a similar to the settings for the Eclipse code formatter. Dispite our best afforts IntelliJ will still produce differently formatted code that Eclipse. It is therefore recommented to use the eclipse formatter plugin for intellij.
c5b7686 to
181371c
Compare
maarzt
commented
Feb 9, 2023
I rewrote the PR. It now updates the imglib2 coding style directly. The commit messages detail the changes made to the coding style.
@ctrueden What are the next steps for the changes to become available via mvn formatter:format?
ctrueden
commented
Feb 9, 2023
@maarzt I have now taken the following actions:
- released scijava-coding-style 2.1.0
- updated pom-scijava-base to use it
- released pom-scijava-base 17.1.0
- updated pom-scijava to inherit from it
I have not yet released pom-scijava 34.0.0, since I am still reconciling some bill-of-materials incompatibilities. Hopefully soon.
maarzt
commented
Feb 9, 2023
Sounds perfect!
Uh oh!
There was an error while loading. Please reload this page.
The imglib2 coding style is used in the github.com/mastodon-sc project. But it's not really enforced. An attempt to reformat the entire source code revealed some problems with it:
{ - private static final boolean USE_ACCELERATORS = MastodonDebugSettings.getInstance().isUseMenuAccelerators(); // TODO: remove, once Fiji ships at least jdk1.8.0_162 + private static final boolean USE_ACCELERATORS = MastodonDebugSettings.getInstance().isUseMenuAccelerators(); // TODO: + // remove, + // once + // Fiji + // ships + // at + // least + // jdk1.8.0_162 private MastodonFrameView< ?, ?, ?, ?, ?, ? > view;The mastodon-coding-style.xml is the result of modifying the imglib2-coding-style.xml in a way that:
In short mastodon-coding-style.xml is a variant of the imglib2-coding-style.xml that allows the developer to more freely put line breaks, but keeps the other aspects of the coding style.