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

Fix #1161, #1130 Apply and check standard code format #1219

Merged
merged 7 commits into from
Mar 16, 2021

Conversation

astrogeco
Copy link
Contributor

@astrogeco astrogeco commented Mar 11, 2021

Describe the contribution
Fix #1161
Fix #1130

Testing performed
See checks tab https://github.com/nasa/cFE/pull/1219/checks
Bundle (fork) test: https://github.com/astrogeco/cFS/pull/8/checks

Expected behavior changes
Adds new github actions workflow that checks format. This workflow runs on both "push" and "pull_request" for all branches so at the moment it will trigger twice for any branch that is part of a pull request

System(s) tested on
Ubuntu 18.04

Additional context
Will create a tag after merge

Third party code
None

astrogeco added a commit to astrogeco/cFS that referenced this pull request Mar 11, 2021
Copy link
Contributor

@skliper skliper left a comment

Choose a reason for hiding this comment

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

Many splits should be cleaned up... Stopped after identifying 10

** \arg #CFE_PSP_RST_TYPE_PROCESSOR - Attempts to retain volatile disk, critical data store and user reserved memory.
** \arg #CFE_PSP_RST_TYPE_POWERON - Causes all memory to be cleared
** \arg #CFE_PSP_RST_TYPE_PROCESSOR - Attempts to retain volatile disk, critical data store
*and user reserved memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 495 to 498
** The caller can set this pointer to NULL if the Sub-Type is of no interest. \n
**ResetSubtypePtr If the provided pointer was not \c NULL, the Reset Sub-Type is stored at the given address.
** For a list of possible Sub-Type values, see \link #CFE_PSP_RST_SUBTYPE_POWER_CYCLE
*"Reset Sub-Types" \endlink.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line splits

Comment on lines 706 to 709
** \param[out] TaskInfo Pointer to a \c CFE_ES_TaskInfo_t structure that holds the specific
** task information. *TaskInfo is the filled out \c CFE_ES_TaskInfo_t structure containing
*the
** Task Name, Parent App Name, Parent App ID among other fields.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 827 to 828
** \param[in, out] TaskIdPtr A pointer to a variable that will be filled in with the new task's ID. *TaskIdPtr is
*the Task ID of the newly created child task.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

** \param[in] TaskId The task ID previously obtained when the Child Task was created with the
*#CFE_ES_CreateChildTask API.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 1075 to 1076
** \param[in, out] HandlePtr Pointer Application's variable that will contain the CDS Memory Block Handle.
**HandlePtr is the handle of the CDS block that can be used in
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 1195 to 1196
** \param[in, out] RestoreToMemory A Pointer to the block of memory that is to be restored with the contents of the
*CDS. *RestoreToMemory is the contents of the specified CDS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 1226 to 1227
** \param[in, out] PoolID A pointer to the variable the caller wishes to have the memory pool handle kept in.
**PoolID is the memory pool handle.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 1285 to 1286
** \param[in, out] PoolID A pointer to the variable the caller wishes to have the memory pool handle kept in.
**PoolID is the memory pool handle.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line split

Comment on lines 1291 to 1303
** \param[in] Size The size of the pool of memory. Note that this must be an integral number of 32 bit
*words.
**
** \param[in] NumBlockSizes The number of different block sizes specified in the \c BlockSizes array. If set equal to
** zero or if greater than 17, then default block sizes are used.
**
** \param[in] BlockSizes Pointer to an array of sizes to be used instead of the default block sizes specified by
** #CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 through #CFE_PLATFORM_ES_MAX_BLOCK_SIZE. If the pointer is equal to NULL,
** #CFE_PLATFORM_ES_MEM_BLOCK_SIZE_01 through #CFE_PLATFORM_ES_MAX_BLOCK_SIZE. If the
*pointer is equal to NULL,
** the default block sizes are used.
**
** \param[in] UseMutex Flag indicating whether the new memory pool will be processing with mutex handling or not.
** \param[in] UseMutex Flag indicating whether the new memory pool will be processing with mutex handling or
*not.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix line splits

@skliper
Copy link
Contributor

skliper commented Mar 11, 2021

Note - could just merge as-is and clean up in follow-on. This is all due to the original having violated the 120 character rule, so it was bad then and it's bad now. The critical point is to get the bulk format in since in general it's a huge consistency improvement.

@astrogeco
Copy link
Contributor Author

astrogeco commented Mar 11, 2021

Note - could just merge as-is and clean up in follow-on. This is all due to the original having violated the 120 character rule, so it was bad then and it's bad now. The critical point is to get the bulk format in since in general it's a huge consistency improvement.

Is the problem is mainly ensuring the two ** and a space after them?

So we'd like this "bad" example

** \param[in, out]   PoolID      A pointer to the variable the caller wishes to have the memory pool handle kept in.
**PoolID is the memory pool handle.

to look like this (at the very least)

** \param[in, out]   PoolID      A pointer to the variable the caller wishes to have the memory pool handle kept in.
** PoolID is the memory pool handle.

or in a perfect world look like

** \param[in, out]   PoolID      A pointer to the variable the caller wishes to have the memory pool handle kept in.
**                               PoolID is the memory pool handle.

@jphickey
Copy link
Contributor

This is where I recommend (and have recommended in the past) going to a single "*" char rather than "**" on the block comments. I think most tools/auto-formatters work better with this pattern, the double * is a little unusual.... (Might be possible to fix this with a sed script)

@astrogeco
Copy link
Contributor Author

What's the history and reasoning behind the ** style?

@jphickey
Copy link
Contributor

No reason AFAIK, someone used it at one time, and others copied. In most IDEs I've used it defaults to just a single *, and I think in this case its confusing clang-format and causing the weird breaks you are seeing.

@skliper
Copy link
Contributor

skliper commented Mar 11, 2021

The GSFC coding standard uses ** in all the examples. The development guide also.

@astrogeco
Copy link
Contributor Author

That coding standard keeps haunting us!

@jphickey
Copy link
Contributor

Is it really part of the coding standard or did they just happen to use ** in the examples?

There's a difference - in a standards document unless they use "shall"/"must" statements - then they are just examples, not requirements. As a contributing author to some standards document, its frustrating when readers misinterpret examples as requirements.

Either way - its a case where we should really consider weighing compatibility with current industry standards vs. compatibility with some examples in a document written many years ago that may not have a real reason behind it other than being what was frequently used in code in that organization at that time (which itself I assume was nothing more than the personal preference of some original authors).

Not that I have a strong preference - from my POV it is simply a question of how much time will be spent manually fixing up the statements - neither Eclipse nor VS Code nor clang-format seem to work well with ** comment blocks, requiring manual intervention to fix them all the time, yet they all generally work OK with auto-formatting the * comment blocks and require no manual fixups.

We can certainly keep the ** - but it will cost more in terms of time and effort, vs. using the industry standard, that's all.

@astrogeco
Copy link
Contributor Author

Random question, how does doxygen deal with the **?

@jphickey
Copy link
Contributor

Doxygen seems generally OK with it, as long as the opening comment block starts with the correct flag (e.g. /**) then it seems to just ignore whatever chars are repeating on the left side of every line of the block.

@astrogeco astrogeco force-pushed the format-checks branch 3 times, most recently from d30accd to 135f52a Compare March 11, 2021 23:33
@astrogeco astrogeco marked this pull request as ready for review March 12, 2021 14:50
@skliper
Copy link
Contributor

skliper commented Mar 12, 2021

Is it really part of the coding standard or did they just happen to use ** in the examples?

There is no requirement to use the ** style. I'm definitely in favor of the more tool-friendly comment style, *.

@jphickey
Copy link
Contributor

It would be nice to also check for superfluous whitespace in the CMakeLists.txt files too - these currently have many lines with trailing whitespaces. A simple sed/awk script applied to these files can strip this out.

@astrogeco
Copy link
Contributor Author

It would be nice to also check for superfluous whitespace in the CMakeLists.txt files too - these currently have many lines with trailing whitespaces. A simple sed/awk script applied to these files can strip this out.

Did a check in a bunch of files while I was at it.

Applies standard format using the .clang-format configuration from the cFS bundle
Hand edits some files to account for comment splits
Adds a continuous integration check to ensure new commits adhere to standard format.
Some minor format fix
@astrogeco astrogeco force-pushed the format-checks branch 5 times, most recently from 48f2610 to d882a61 Compare March 16, 2021 14:43
Removes trailing whitespace in:

- CMakeLists.txt
- *.cmake
@astrogeco astrogeco merged commit 7f8e475 into nasa:main Mar 16, 2021
@astrogeco astrogeco deleted the format-checks branch April 7, 2021 18:03
@skliper skliper added this to the 7.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add format check to workflow Apply style formatting (release candidate prep)
3 participants