Skip to content

Astyle deployement #377

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

Merged
merged 2 commits into from
Feb 13, 2019
Merged

Astyle deployement #377

merged 2 commits into from
Feb 13, 2019

Conversation

fpistm
Copy link
Member

@fpistm fpistm commented Nov 21, 2018

AStyle will be used for coding style checking.
Only sources files (*.h, *.hpp, *.c, *.cpp) from the following lists will be check:

  • cores
  • libraries
  • variants

.astyleignore file contains list of folder to ignore.

Hereafter the code style definition applied (.astylerc):

# STM32duino code style definition file for astyle

# Don't create backup files, let git handle it
suffix=none

# K&R style
style=kr

# 1 TBS addition to k&r, add braces to one liners
# Use -j as it was changed in astyle from brackets to braces, this way it is compatible with older astyle versions
-j

# 2 spaces, convert tabs to spaces
indent=spaces=2
convert-tabs

# Indent switches and cases
indent-classes
indent-switches
indent-cases
indent-col1-comments

# Remove spaces in and around parentheses
unpad-paren

# Insert a space after if, while, for, and around operators
pad-header
pad-oper

# Pointer/reference operators go next to the name (on the right)
align-pointer=name
align-reference=name

# Attach { for classes and namespaces
attach-namespaces
attach-classes

# Extend longer lines, define maximum 120 value. This results in aligned code,
# otherwise the lines are broken and not consistent 
max-continuation-indent=120

# if you like one-liners, keep them
keep-one-line-statements

Python script astyle.py is provided to ease use of AStyle:

usage: astyle.py [-h] [-d <code style definition file>]
                 [-g | -b <branch name>] [-i <ignore file>]
                 [-p <astyle install path>] [-r <source root path>]

Launch astyle on source files found at specified root path.

optional arguments:
  -h, --help            show this help message and exit
  -d <code style definition file>, --definition <code style definition file>
                        Code style definition file for Astyle. Default: <repo path>/Arduino_Core_S
                        TM32/CI/astyle/.astylerc
  -g, --gitdiff         Use changes files from git default branch. Default:
                        remotes/origin/master
  -b <branch name>, --branch <branch name>
                        Use changes files from git specified branch.
  -i <ignore file>, --ignore <ignore file>
                        File containing path to ignore. Default: <repo path>/Arduino_Core_STM32/CI
                        /astyle/.astyleignore
  -p <astyle install path>, --path <astyle install path>
                        Astyle installation path
  -r <source root path>, --root <source root path>
                        Source root path to use. Default: <repo path>/Arduino_Core_STM32

@fpistm fpistm force-pushed the astyle branch 7 times, most recently from 2cb773d to 11faa59 Compare November 22, 2018 15:37
@fpistm fpistm self-assigned this Nov 22, 2018
@fpistm fpistm added the enhancement New feature or request label Nov 22, 2018
@fpistm fpistm added this to the 1.5.0 milestone Nov 22, 2018
Add code style definition file for Astyle
Add python script to launch Astyle on desired sources
Add ignore path file

	http://astyle.sourceforge.net/

Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
@BennehBoy
Copy link
Contributor

@fpistm so, locally, we just run astyle.py against our local folder before commiting to see what needs fixing?

@fpistm
Copy link
Member Author

fpistm commented Feb 2, 2019

yes.
I will add some guidance in the contributing.md when I will release this.
This PR will add AStyle check to Travis CI build then if new code doesn't follow the coding style then this will be failed.
Not that Astyle will reformat automatically the code.

@BennehBoy
Copy link
Contributor

Are you using an IDE which has an Astyle plugin?

@fpistm
Copy link
Member Author

fpistm commented Feb 2, 2019

No, I mainly develop under Linux and use gvim. I do all using command lines 😄

@BennehBoy
Copy link
Contributor

Hmm, gvim has come on quite a way I may give it a try.

@fpistm fpistm merged commit 1221cb1 into stm32duino:master Feb 13, 2019
@fpistm fpistm deleted the astyle branch February 13, 2019 14:08
@BennehBoy
Copy link
Contributor

BennehBoy commented Feb 14, 2019

@fpistm need more docs on what the style items in the config above are, or a means to convert existing code... as it stands I'm clueless what Astyle's error report is actually saying, the output from it does not match the code I submitted.

@fpistm
Copy link
Member Author

fpistm commented Feb 14, 2019

The output is the code formatted. Simply apply astyle with the config provided then your code will be ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants