Commit Graph

4 Commits (4e505f6b528689e855f55b8acdf04f1133c45da1)

Author SHA1 Message Date
Martin Kojtal f835c89729 AStyle: fix indentation for longer lines
Long lines like this would have parameters misaligned but shorter lines would be OK.

```
 void LoRaMac::check_frame_size(uint16_t size)
 {
     uint8_t value = _lora_phy.get_max_payload(_mcps_indication.rx_datarate,
-                                              _params.is_repeater_supported);
+                    _params.is_repeater_supported);
+
+    _lora_phy.a(_mcps_indication.b,
+                b.is_repeater_supported);
```

With this option (applied to the code above), we get

```
@@ -319,6 +319,9 @@ void LoRaMac::check_frame_size(uint16_t size)
     uint8_t value = _lora_phy.get_max_payload(_mcps_indication.rx_datarate,
                                               _params.is_repeater_supported);

+    _lora_phy.a(_mcps_indication.b,
+                b.is_repeater_supported);
```

Both are aligned the same. However there is a limit of astyle - 120 columns for this.
We do in most cases lines from 80 to 120 as suggested in our code lines thus this should
be good.
2018-05-24 14:15:52 +01:00
Martin Kojtal 1059c26e79 AStyle: don't indent cases
This was a bug in our configuration. Earlier versions of our style did not
specify this option. We found out for some code in our codebase that it was
changed because of the setting.

An example:

```
case: {
    // code here
}

//would be changed to

case: {
    // code here
   }
```

The first one is correct and do not need to be indented (it's enough switch is
indented).
2018-05-24 14:02:28 +01:00
Martin Kojtal 7ba0e90f02 AStyle: options update
This should reflect these rules that we have defined since mbed 2:

```
Indentation - 4 spaces. Please do not use tabs.
Braces - K&R (see the exception 1 TBS below)
1 TBS -use braces for statements if, else, while, for (exception from K&R) Reference: http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS
One line per statement
Preprocessor macro starts at the beginning of a new line, the code inside is indented accordingly the code above it
Cases within switch are indented (exception from K&R)
Space after statements if, while, for, switch, same applies to binary and ternary operators
Each line has preferably at most 120 characters
For pointers, '*' is adjacent to a data name (analogin_t *obj) or a function name (analog_t *get_analogin_object())
Don't leave trailing spaces at the end of lines
Empty lines should have no trailing spaces
Unix line endings are default option for files
Use capital letters for macros
A file should have an empty line at the end
```
2018-04-19 12:55:08 +01:00
Martin Kojtal f07cf4cf5d Add Astyle configuration file for mbed OS
This follows what is in the codebase in most cases (K&R with few exceptions).
This should follow also how online compiler formats the code.
2018-04-19 12:55:07 +01:00