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

uncrustify: change en/disable markers #10865

Merged
merged 3 commits into from
Jan 25, 2019

Conversation

kaspar030
Copy link
Contributor

Contribution description

Default uncrustify uses *INDENT-OFF* as marker for disabling all formatting processing.
As a lot more than indenting is disabled, I find that misleading. Also it kinda screams at me using all-caps.

boards/hifive1/board.c is currently the only non-vendor file in the repository that made use of the markers. Previously, it used a speaking comment à la /* disable uncrustify *INDENT-OFF* */ .

I'd like to change the marker to speak for itself, but allows changing of the used tool.

This PR changes uncrustify's markers to *auto-format-off* and auto-format-on.

What do you think?

Testing procedure

See uncrustify output for boards/hifive1/board.c with / without PR.

Issues/PRs references

none

@kaspar030 kaspar030 added Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Area: tools Area: Supplementary tools labels Jan 25, 2019
@kaspar030 kaspar030 requested a review from miri64 January 25, 2019 10:32
@jia200x
Copy link
Member

jia200x commented Jan 25, 2019

+1 to the change to uncrustify markers

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

I'm aware this is very much a question of taste, but

  1. why keep the asterisks?

  2. why not a more environment-like thing. It feels unintuitive to me that to enter a certain region of code you say "off" and to leave it you say "on". I'd rather expect something like

    /* begin{code-style-ignore} */
    some* dirty=code;
    /* end{code-style-ignore} */

    (totally inspired by Latex ;P).

@kaspar030
Copy link
Contributor Author

2\. It feels unintuitive to me that to enter a certain region of code you say "off" and to leave it you say "on".

Yeah, that captures my feelings, too. Are we fine with having a begin but no end, e.g., when disabling uncrustify for the whole file?

@miri64
Copy link
Member

miri64 commented Jan 25, 2019

Yeah, that captures my feelings, too. Are we fine with having a begin but no end, e.g., when disabling uncrustify for the whole file?

If SGML is allowed to do that then we are as well... ;-P.

@miri64
Copy link
Member

miri64 commented Jan 25, 2019

One word on portability: My current workplace setup (Ubuntu 16.04) isn't able to read the uncrustify-riot.cfg correctly

$ uncrustify -v
uncrustify 0.59
$ uncrustify --no-backup -c uncrustify-riot.cfg boards/hifive1/board.c 
uncrustify-riot.cfg:11 Unknown symbol 'indent_ternary_operator'
uncrustify-riot.cfg:87 unknown type 'PROTO_WRAP':uncrustify-riot.cfg:93 Unknown symbol 'disable_processing_cmt'
uncrustify-riot.cfg:94 Unknown symbol 'enable_processing_cmt'
Parsing: boards/hifive1/board.c as language C

But that is already the case in master so I don't mind, but Ubuntu 16.04 is still officially supported so our users might still use it so we should pay attention to not lose support for it. I also tested on a somewhat current Debian (docker image debian/stretch-slim with just uncrustify (0.64) and git installed manually). There only the indent_ternary_operator isn't recognized, so this PR is not affected.

@miri64
Copy link
Member

miri64 commented Jan 25, 2019

@jia200x what do you think about the new marker style?

@jia200x
Copy link
Member

jia200x commented Jan 25, 2019

@jia200x what do you think about the new marker style?

Much better now :)

@kaspar030
Copy link
Contributor Author

One word on portability: My current workplace setup (Ubuntu 16.04) isn't able to read the uncrustify-riot.cfg correctly

$ uncrustify -v
uncrustify 0.59

Shit, 0.59 is seven years old. It was superceded by two new releases at the end of 2014. I hope we can just let user's know they'll need to upgrade... Isn't the latest Ubuntu LTS our "officially supported platform"?

@kaspar030
Copy link
Contributor Author

@miri64 @jia200x happy enough so I can squash? 😉

@jia200x
Copy link
Member

jia200x commented Jan 25, 2019

I'm fine with it ;)

@miri64
Copy link
Member

miri64 commented Jan 25, 2019

Shit, 0.59 is seven years old. It was superceded by two new releases at the end of 2014. I hope we can just let user's know they'll need to upgrade... Isn't the latest Ubuntu LTS our "officially supported platform"?

In general, you shouldn't expect users to require their OS to update everytime the newest version pops up just because it is inconvenient to you. Even for stable or LTS. There are valid reasons not to (e.g. no administrative rights on their machine or because people choose a stable OS because they don't want to update that often). There should always be a grace period and IMHO that should be until the official EOL of that OS release. For 16.04 that is 2021.

However, in specific I don't mind this minor inconvenience for our code beautifier...

@miri64
Copy link
Member

miri64 commented Jan 25, 2019

@miri64 @jia200x happy enough so I can squash?

Yes, sorry.. This somehow got lost in my ramblings about portability 👼

@kaspar030 kaspar030 force-pushed the uncrustify_change_disable_hint branch from b2df670 to 674128e Compare January 25, 2019 16:21
@kaspar030 kaspar030 changed the title uncrustify: change en/disable markers to "*auto-format-[on|off]*" uncrustify: change en/disable markers Jan 25, 2019
@kaspar030 kaspar030 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Jan 25, 2019
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Ran it on an Arch machine again. Works like a charm. As a general rule we should however add reasonings to these blocks as you did in #10867.

@@ -96,7 +96,7 @@ void board_init_clock(void)
/* Note: The range is limited to ~100MHz and depends on PLL settings */
PRCI_set_hfrosctrim_for_f_cpu(CPU_DESIRED_FREQ, PRCI_FREQ_UNDERSHOOT);

/* disable uncrustify *INDENT-OFF* */
/* begin{code-style-ignore} */
Copy link
Member

Choose a reason for hiding this comment

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

Uncrustify moves this comment one space to the left. Why not fix it ;-)? (the code below probably needs to be moved as well though :-/)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not fix it ;-)?

unrelated! ;)

@kaspar030 kaspar030 merged commit 6cd81db into RIOT-OS:master Jan 25, 2019
@kaspar030 kaspar030 deleted the uncrustify_change_disable_hint branch January 25, 2019 21:40
@danpetry danpetry modified the milestone: Release 2019.04 Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants