Unify code formatting
- Dominant language
- Kotlin
- Stars
- 5.6k
- Forks
- 2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 92
Description
As we get more and more contributions (:tada: :tada:) the variety of code formattings currently increase.
So I would like to agree on some basics and then add them to contributing.md and also try to get them into AndroidStudio.
- Annotations before parameter:
```
@ContributesAndroidInjector abstract ActivitiesActivity activitiesActivity();
```
- I would keep it this way
- Annotations before methods:
```
@Before
public void test() { … }
```
- line wrap at 120:
- this is best for reading without scrolling in gitHub
- can be set up in AndroidStudio (should already be in code-style)
- if statetement
- always with brackets
- whitespaces around
```
if (booleanValue == true) {
// do this
}
```
Parameters in methods / implement mulitple classes:
```
public class AuthenticatorActivity extends AccountAuthenticatorActivity
implements OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener, OnSslUntrustedCertListener,
AuthenticatorAsyncTask.OnAuthenticatorTaskListener, Injectable {
```
and
```
@Provides @Singleton
WhatsNewService whatsNewService(Resources resources, AppPreferences preferences,
CurrentAccountProvider accountProvider, AppInfo appInfo) {
return new WhatsNewService(resources, preferences, accountProvider, appInfo);
}
```
vs
```
public class AuthenticatorActivity extends AccountAuthenticatorActivity implements
OnRemoteOperationListener,
OnFocusChangeListener,
OnEditorActionListener,
OnSslUntrustedCertListener,
AuthenticatorAsyncTask.OnAuthenticatorTaskListener,
Injectable {
```
and
```
@Provides
@Singleton
WhatsNewService whatsNewService(
Resources resources,
AppPreferences preferences,
CurrentAccountProvider accountProvider,
AppInfo appInfo
) {
return new WhatsNewService(resources, preferences, accountProvider, appInfo);
}
```
Personally I do not like the last one, where parameters are each in one line, as the take too much space and the "floating" `) {` is kind of strange.
However this makes diffs way more easy.
All in all I have no hard feelings and can use everything :-)
@AndyScherzinger @ezaquarii
Maybe we can agree on something and then can adjust code-style within AndroidStudio according to it and also try (again) to have this in our project.
Contributor guide
Assessment
This issue has not been assessed yet.