-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix number order in the 2.2 section. #31
Open
jobot0
wants to merge
1
commit into
ribot:master
Choose a base branch
from
jobot0:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+16
−16
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ public class MyClass { | |
} | ||
``` | ||
|
||
### 2.2.3 Treat acronyms as words | ||
### 2.2.2 Treat acronyms as words | ||
|
||
| Good | Bad | | ||
| -------------- | -------------- | | ||
|
@@ -162,7 +162,7 @@ public class MyClass { | |
| `String url` | `String URL` | | ||
| `long id` | `long ID` | | ||
|
||
### 2.2.4 Use spaces for indentation | ||
### 2.2.3 Use spaces for indentation | ||
|
||
Use __4 space__ indents for blocks: | ||
|
||
|
@@ -179,7 +179,7 @@ Instrument i = | |
someLongExpression(that, wouldNotFit, on, one, line); | ||
``` | ||
|
||
### 2.2.5 Use standard brace style | ||
### 2.2.4 Use standard brace style | ||
|
||
Braces go on the same line as the code before them. | ||
|
||
|
@@ -212,9 +212,9 @@ if (condition) | |
body(); // bad! | ||
``` | ||
|
||
### 2.2.6 Annotations | ||
### 2.2.5 Annotations | ||
|
||
#### 2.2.6.1 Annotations practices | ||
#### 2.2.5.1 Annotations practices | ||
|
||
According to the Android code style guide, the standard practices for some of the predefined annotations in Java are: | ||
|
||
|
@@ -224,7 +224,7 @@ According to the Android code style guide, the standard practices for some of th | |
|
||
More information about annotation guidelines can be found [here](http://source.android.com/source/code-style.html#use-standard-java-annotations). | ||
|
||
#### 2.2.6.2 Annotations style | ||
#### 2.2.5.2 Annotations style | ||
|
||
__Classes, Methods and Constructors__ | ||
|
||
|
@@ -245,13 +245,13 @@ Annotations applying to fields should be listed __on the same line__, unless the | |
@Nullable @Mock DataManager mDataManager; | ||
``` | ||
|
||
### 2.2.7 Limit variable scope | ||
### 2.2.6 Limit variable scope | ||
|
||
_The scope of local variables should be kept to a minimum (Effective Java Item 29). By doing so, you increase the readability and maintainability of your code and reduce the likelihood of error. Each variable should be declared in the innermost block that encloses all uses of the variable._ | ||
|
||
_Local variables should be declared at the point they are first used. Nearly every local variable declaration should contain an initializer. If you don't yet have enough information to initialize a variable sensibly, you should postpone the declaration until you do._ - ([Android code style guidelines](https://source.android.com/source/code-style.html#limit-variable-scope)) | ||
|
||
### 2.2.8 Order import statements | ||
### 2.2.7 Order import statements | ||
|
||
If you are using an IDE such as Android Studio, you don't have to worry about this because your IDE is already obeying these rules. If not, have a look below. | ||
|
||
|
@@ -269,7 +269,7 @@ To exactly match the IDE settings, the imports should be: | |
|
||
More info [here](https://source.android.com/source/code-style.html#limit-variable-scope) | ||
|
||
### 2.2.9 Logging guidelines | ||
### 2.2.8 Logging guidelines | ||
|
||
Use the logging methods provided by the `Log` class to print out error messages or other information that may be useful for developers to identify issues: | ||
|
||
|
@@ -299,7 +299,7 @@ To only show logs on debug builds: | |
if (BuildConfig.DEBUG) Log.d(TAG, "The value of x is " + x); | ||
``` | ||
|
||
### 2.2.10 Class member ordering | ||
### 2.2.9 Class member ordering | ||
|
||
There is no single correct solution for this but using a __logical__ and __consistent__ order will improve code learnability and readability. It is recommendable to use the following order: | ||
|
||
|
@@ -360,7 +360,7 @@ public class MainActivity extends Activity { | |
} | ||
``` | ||
|
||
### 2.2.11 Parameter ordering in methods | ||
### 2.2.10 Parameter ordering in methods | ||
|
||
When programming for Android, it is quite common to define methods that take a `Context`. If you are writing a method like this, then the __Context__ must be the __first__ parameter. | ||
|
||
|
@@ -376,7 +376,7 @@ public User loadUser(Context context, int userId); | |
public void loadUserAsync(Context context, int userId, UserCallback callback); | ||
``` | ||
|
||
### 2.2.13 String constants, naming, and values | ||
### 2.2.11 String constants, naming, and values | ||
|
||
Many elements of the Android SDK such as `SharedPreferences`, `Bundle`, or `Intent` use a key-value pair approach so it's very likely that even for a small app you end up having to write a lot of String constants. | ||
|
||
|
@@ -405,7 +405,7 @@ static final String EXTRA_SURNAME = "com.myapp.extras.EXTRA_SURNAME"; | |
static final String ACTION_OPEN_USER = "com.myapp.action.ACTION_OPEN_USER"; | ||
``` | ||
|
||
### 2.2.14 Arguments in Fragments and Activities | ||
### 2.2.12 Arguments in Fragments and Activities | ||
|
||
When data is passed into an `Activity `or `Fragment` via an `Intent` or a `Bundle`, the keys for the different values __must__ follow the rules described in the section above. | ||
|
||
|
@@ -437,7 +437,7 @@ __Note 1__: These methods should go at the top of the class before `onCreate()`. | |
|
||
__Note 2__: If we provide the methods described above, the keys for extras and arguments should be `private` because there is not need for them to be exposed outside the class. | ||
|
||
### 2.2.15 Line length limit | ||
### 2.2.13 Line length limit | ||
|
||
Code lines should not exceed __100 characters__. If the line is longer than this limit there are usually two options to reduce its length: | ||
|
||
|
@@ -449,7 +449,7 @@ There are two __exceptions__ where it is possible to have lines longer than 100: | |
* Lines that are not possible to split, e.g. long URLs in comments. | ||
* `package` and `import` statements. | ||
|
||
#### 2.2.15.1 Line-wrapping strategies | ||
#### 2.2.14.1 Line-wrapping strategies | ||
|
||
There isn't an exact formula that explains how to line-wrap and quite often different solutions are valid. However there are a few rules that can be applied to common cases. | ||
|
||
|
@@ -501,7 +501,7 @@ loadPicture(context, | |
"Title of the picture"); | ||
``` | ||
|
||
### 2.2.16 RxJava chains styling | ||
### 2.2.15 RxJava chains styling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this should be 2.2.14 |
||
|
||
Rx chains of operators require line-wrapping. Every operator must go in a new line and the line should be broken before the `.` | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now be 2.2.13.1