Skip to content

Commit c9caa61

Browse files
authored
Update project_and_code_guidelines.md
Fixes ribot#31 - number issues within 2.2.x
1 parent c2f28b2 commit c9caa61

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

project_and_code_guidelines.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class MyClass {
153153
}
154154
```
155155

156-
### 2.2.3 Treat acronyms as words
156+
### 2.2.2 Treat acronyms as words
157157

158158
| Good | Bad |
159159
| -------------- | -------------- |
@@ -162,7 +162,7 @@ public class MyClass {
162162
| `String url` | `String URL` |
163163
| `long id` | `long ID` |
164164

165-
### 2.2.4 Use spaces for indentation
165+
### 2.2.3 Use spaces for indentation
166166

167167
Use __4 space__ indents for blocks:
168168

@@ -179,7 +179,7 @@ Instrument i =
179179
someLongExpression(that, wouldNotFit, on, one, line);
180180
```
181181

182-
### 2.2.5 Use standard brace style
182+
### 2.2.4 Use standard brace style
183183

184184
Braces go on the same line as the code before them.
185185

@@ -212,9 +212,9 @@ if (condition)
212212
body(); // bad!
213213
```
214214

215-
### 2.2.6 Annotations
215+
### 2.2.5 Annotations
216216

217-
#### 2.2.6.1 Annotations practices
217+
#### 2.2.5.1 Annotations practices
218218

219219
According to the Android code style guide, the standard practices for some of the predefined annotations in Java are:
220220

@@ -224,7 +224,7 @@ According to the Android code style guide, the standard practices for some of th
224224

225225
More information about annotation guidelines can be found [here](http://source.android.com/source/code-style.html#use-standard-java-annotations).
226226

227-
#### 2.2.6.2 Annotations style
227+
#### 2.2.5.2 Annotations style
228228

229229
__Classes, Methods and Constructors__
230230

@@ -245,13 +245,13 @@ Annotations applying to fields should be listed __on the same line__, unless the
245245
@Nullable @Mock DataManager mDataManager;
246246
```
247247

248-
### 2.2.7 Limit variable scope
248+
### 2.2.6 Limit variable scope
249249

250250
_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._
251251

252252
_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))
253253

254-
### 2.2.8 Order import statements
254+
### 2.2.7 Order import statements
255255

256256
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.
257257

@@ -269,7 +269,7 @@ To exactly match the IDE settings, the imports should be:
269269

270270
More info [here](https://source.android.com/source/code-style.html#limit-variable-scope)
271271

272-
### 2.2.9 Logging guidelines
272+
### 2.2.8 Logging guidelines
273273

274274
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:
275275

@@ -299,7 +299,7 @@ To only show logs on debug builds:
299299
if (BuildConfig.DEBUG) Log.d(TAG, "The value of x is " + x);
300300
```
301301

302-
### 2.2.10 Class member ordering
302+
### 2.2.9 Class member ordering
303303

304304
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:
305305

@@ -362,7 +362,7 @@ public class MainActivity extends Activity {
362362
}
363363
```
364364

365-
### 2.2.11 Parameter ordering in methods
365+
### 2.2.10 Parameter ordering in methods
366366

367367
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.
368368

@@ -378,7 +378,7 @@ public User loadUser(Context context, int userId);
378378
public void loadUserAsync(Context context, int userId, UserCallback callback);
379379
```
380380

381-
### 2.2.13 String constants, naming, and values
381+
### 2.2.11 String constants, naming, and values
382382

383383
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.
384384

@@ -407,7 +407,7 @@ static final String EXTRA_SURNAME = "com.myapp.extras.EXTRA_SURNAME";
407407
static final String ACTION_OPEN_USER = "com.myapp.action.ACTION_OPEN_USER";
408408
```
409409

410-
### 2.2.14 Arguments in Fragments and Activities
410+
### 2.2.12 Arguments in Fragments and Activities
411411

412412
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.
413413

@@ -439,7 +439,7 @@ __Note 1__: These methods should go at the top of the class before `onCreate()`.
439439

440440
__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.
441441

442-
### 2.2.15 Line length limit
442+
### 2.2.13 Line length limit
443443

444444
Code lines should not exceed __100 characters__. If the line is longer than this limit there are usually two options to reduce its length:
445445

@@ -451,7 +451,7 @@ There are two __exceptions__ where it is possible to have lines longer than 100:
451451
* Lines that are not possible to split, e.g. long URLs in comments.
452452
* `package` and `import` statements.
453453

454-
#### 2.2.15.1 Line-wrapping strategies
454+
#### 2.2.13.1 Line-wrapping strategies
455455

456456
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.
457457

@@ -503,7 +503,7 @@ loadPicture(context,
503503
"Title of the picture");
504504
```
505505

506-
### 2.2.16 RxJava chains styling
506+
### 2.2.14 RxJava chains styling
507507

508508
Rx chains of operators require line-wrapping. Every operator must go in a new line and the line should be broken before the `.`
509509

0 commit comments

Comments
 (0)