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

AStyle: Fix astyle indentation #7007

Merged
merged 2 commits into from
Jun 1, 2018

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented May 24, 2018

Description

This PR fixes the indentation we identified (thanks @kjbracey-arm @hasnainvirk) in Lorawan PR - lorawan codebase tested astyle to the point where we found that the code astyle was fixing was not correct (see the commit messages with examples how it was and with this config how is it). You will spot the differences.

This PR is vital for astyle applying to our bigger codebase.

Pull request type

[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

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).
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.
@0xc0170 0xc0170 requested review from geky, hasnainvirk and a team May 24, 2018 13:21
Copy link
Contributor

@hasnainvirk hasnainvirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@0xc0170
Copy link
Contributor Author

0xc0170 commented May 24, 2018

To bring bigger picture here, with these 2 options, using AStyle 3.1 as recommended this is the outcome to have astyle run for lorawan codebase: https://github.com/ARMmbed/mbed-os/compare/master...0xc0170:test?expand=1 (please review if all is good). It seems to me 👍

@cmonr
Copy link
Contributor

cmonr commented May 31, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented May 31, 2018

Build : SUCCESS

Build number : 2207
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7007/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 1, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 1, 2018

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

Successfully merging this pull request may close these issues.

6 participants