Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improves imglib2 coding style#7

Merged
maarzt merged 7 commits intomaster from
add-mastodon-style
Feb 9, 2023
Merged

Improves imglib2 coding style #7
maarzt merged 7 commits intomaster from
add-mastodon-style

Conversation

@maarzt
Copy link
Collaborator

@maarzt maarzt commented Jan 23, 2023
edited
Loading

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:

  1. Many intentionally set line breaks where removed leading to long lines:
 	private final RefBimap< E, WE > edgeMap;
 
-	public NavigationListenerAdapter(
-			final NavigationListener< WV, WE > listener,
-			final RefBimap< V, WV > vertexMap,
-			final RefBimap< E, WE > edgeMap )
+	public NavigationListenerAdapter( final NavigationListener< WV, WE > listener, final RefBimap< V, WV > vertexMap, final RefBimap< E, WE > edgeMap )
 	{
  1. Comments at the end of a line are sometimes broken in a very annoying way:
 {
-	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:

  1. It doesn't remove intentionally set line breaks.
  2. It does not mess up javadoc comments and normal comments.
  3. Line width was increased, to avoid poorly placed automatic line breaks.

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.

Copy link
Collaborator Author

maarzt commented Jan 23, 2023
edited
Loading

@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.

Copy link
Collaborator Author

maarzt commented Jan 23, 2023

This pull request is related to: mastodon-sc/mastodon#224

@maarzt maarzt mentioned this pull request Jan 23, 2023
@maarzt maarzt changed the title (削除) Add improves imglib2 coding style (mastodon style) (削除ここまで) (追記) Improves imglib2 coding style (add mastodon style) (追記ここまで) Jan 23, 2023
Copy link
Member

ctrueden commented Jan 23, 2023
edited
Loading

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!

imagejan reacted with thumbs up emoji

Copy link
Collaborator Author

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.

Copy link
Member

👍 I'm absolutely fine with replacing. The TrackMate-TrackAnalysis repository is archived and deprecated, as the functionality moved into TrackMate core.

maarzt and others added 7 commits February 9, 2023 11:53
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.
@maarzt maarzt changed the title (削除) Improves imglib2 coding style (add mastodon style) (削除ここまで) (追記) Improves imglib2 coding style (追記ここまで) Feb 9, 2023
@maarzt maarzt marked this pull request as ready for review February 9, 2023 11:31
@maarzt maarzt merged commit 58ae64e into master Feb 9, 2023
Copy link
Collaborator Author

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 reacted with thumbs up emoji

@ctrueden ctrueden deleted the add-mastodon-style branch February 9, 2023 13:08
Copy link
Member

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 and imagejan reacted with thumbs up emoji maarzt reacted with hooray emoji

Copy link
Collaborator Author

maarzt commented Feb 9, 2023

Sounds perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /