Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Wrap line behavior #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nahuel-soldevilla
Copy link
Member

Change all "Wrap when necessary" settings to "Wrap all".
With this change, the user is responsible for wrapping when it deems necessary.

Example:

Before:

/**
 * Parameters
 */
class Example {

	// line width > 140 will wrap exceeding text
	Example(int arg1, int arg2,
			int arg3, int arg4,
			int arg5, int arg6) {
		this();
	}

	Example() {
	}
}

After:

/**
 * Parameters
 */
class Example {

	// Manually formatted
	// If one argument is wrapped, all the other ones are wrapped
	Example(
		int arg1,
		int arg2,
		int arg3,
		int arg4,
		int arg5,
		int arg6) {
		this();
	}

	Example() {
	}
}

Wrapped and non-wrapped code can be mixed, as long as the same group are
in the same line. Example:

final List<List<String>> data = ImmutableList
	.<List<String>>builder()
	.add(ImmutableList.<String>builder().add(randomAlphabetic(5)).build())
	.build();

Right now Maximum length width is set to 140 and only the exceeding code will wrap to the next line. With this change, Method chaining is more clear. Example:
Before:

StudyDetailDto studyDetailDto = new StudyDetailDto().setStudyDbId(trialDbId).setObservationVariableDbIds(observationVariablesId)
		.setObservationVariableNames(observationVariableName).setData(data);

After:

StudyDetailDto studyDetailDto = new StudyDetailDto()
	.setStudyDbId(trialDbId)
	.setObservationVariableDbIds(observationVariablesId)
	.setObservationVariableNames(observationVariableName)
	.setData(data);

Change all "Wrap when necessary" to "Wrap all". Also add "never join
already wrapped lines" to give the possibility to manually format
specific lines to never wrap.
With this change, the user is responsible for wrapping when it deems
necessary.

Example:

Before:

/**
 * Parameters
 */
class Example {

	// line width > 140 will wrap exceeding text
	Example(int arg1, int arg2,
			int arg3, int arg4,
			int arg5, int arg6) {
		this();
	}

	Example() {
	}
}

After:

/**
 * Parameters
 */
class Example {

	// Manually formatted
	// If one argument is wrapped, all the other ones are wrapped
	Example(
		int arg1,
		int arg2,
		int arg3,
		int arg4,
		int arg5,
		int arg6) {
		this();
	}

	Example() {
	}
}

Wrapped and non-wrapped code can be mixed, as long as the same group are
in the same line. Example:

final List<List<String>> data = ImmutableList
	.<List<String>>builder()
	.add(ImmutableList.<String>builder().add(randomAlphabetic(5)).build())
	.build();
@nahuel-soldevilla
Copy link
Member Author

@darla-leafnode
Copy link
Contributor

Hello @nahuelsoldevilla-droptek,
Personally, I like this formatting as it makes the code much more readable. 👍
A suggestion on implementing this is to include running the formatter across our codebase and committing changes so that we won't have so many formatting commits later on after this merge. We just have to think about the timing as I believe there are several pending PR merges coming from code freeze.

@nahuel-soldevilla
Copy link
Member Author

Thanks for the feedback @darla-leafnode!
I'm still need to figure it out out to implement this with intellij since the example with wrapped and non-wrapped code won't work.
Let's shelve this idea for now until we have more time to shape it better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants