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

Refactor identation and code style #27

Open
wants to merge 2 commits into
base: pre-release
Choose a base branch
from

Conversation

gustavosr8
Copy link
Contributor

In the current code style, there are some misleading indentation, which makes the code a little hard to understand, so I fixed some of this mistakes.
Changed the function headers to have the return type in the same line as the function name, and add a tab before the local variable declarations . Change the indentation style to use four spaces, and change the space usages in function calls, if-else statements, switch cases, and other specific situations.
I guess some of this code styles was a project choice, so it can be removed from this commit if you think it should be the way that it is!

@JJL772
Copy link
Contributor

JJL772 commented Jun 25, 2024

What tool did you use to format this? @marciodo perhaps we should add a .clang-format file to describe the intended style of the module and to allow automatic formatting. (See https://github.com/slaclab/epics-ek9000/blob/master/.clang-format for an example)

@marciodo
Copy link
Collaborator

I'm concerned that merging this pull request will potentially create a lot of conflicts with the other 2. Once we test everything, I think we could merge the other 2 pull requests and have this one rebased and resubmitted. @gustavosr8, Jeremy and I are interested in knowing more about the tool that you used.

@gustavosr8
Copy link
Contributor Author

Hi @marciodo and @JJL772! I've made some adjustments to the .clang-format file you provided to better match the formatting style I've used previously, and I've included it in the commit. The advantage of using this file is that you can customize it to better suit your style preferences and integrate it into your CI pipeline.

In order to apply the style to the files, you can use the following command:

find . -regex '.*\.\(cpp\|hpp\|c\|h\)' -exec clang-format -style=file -i {} \;

It will find all the .cpp, .hpp, .c, and .h files recursively from the current directory and apply the .clang-format file to it.

.clang-format Outdated Show resolved Hide resolved
@marciodo
Copy link
Collaborator

@gustavosr8, we are ready for this code-style pull request. Could you please see Jeremy's suggestions, apply your changes, and resubmit the pull request? See that we are basing all changes in the pre-release branch.
Once we approve this, we can create a new release.

@gustavosr8
Copy link
Contributor Author

Hey guys, sorry I took so long, I was on vacation.

@marciodo
Copy link
Collaborator

marciodo commented Aug 8, 2024

No problems, Gustavo! I believe we may need a few iterations until we get to a final result. I'm still beginning to look in detail at all the changes, so I'm not done with the review, yet.

Copy link
Collaborator

@marciodo marciodo left a comment

Choose a reason for hiding this comment

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

Gustavo, I followed a link on the e-mail that doesn't belong to a branch in this repository. I don't know what happened: f7b99bb

All my comments are in this commit above.

Once you are ready, please apply your changes to the pre-release branch, not main.

@gustavosr8 gustavosr8 changed the base branch from main to pre-release August 12, 2024 16:50
Copy link
Contributor

@JJL772 JJL772 left a comment

Choose a reason for hiding this comment

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

Just one little comment/question from me, but otherwise looks good

Comment on lines +275 to +280
MCH_DEV_SUP_SET devStringinFru = {
6, NULL, init_fru_stringin, init_fru_stringin_record, stringin_fru_ioint_info, read_fru_stringin, NULL};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is caused by the ColumnLimit. I'm thinking we should disable the ColumnLimit entirely by setting it to 0. @marciodo thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The ColumLimit is useful, for example, in functions that have several parameters or parameters with several characters. In this case, clang-format will split the arguments into more lines, making the code easier to read.

But for the case above, it would be better if clang-format could do something like:

MCH_DEV_SUP_SET devStringinFru = {6, NULL, init_fru_stringin, init_fru_stringin_record,
                                                                   stringin_fru_ioint_info, read_fru_stringin, NULL};

respecting the column limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi guys, I couldn't find a way to achieve this. Do you have any idea how to do it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this is not possible. I'll try a few things, although I'm not sure when.

@marciodo
Copy link
Collaborator

There are conflicts in 4 files. I believe that you applied clang-format in the main branch, not pre-release, and when you modified the base branch for the pull request the conflicts showed up. Would you mind running clang-format in the pre-release branch instead of main?

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.

3 participants