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

Add style check to workflow #2062

Merged
merged 2 commits into from
Feb 17, 2025
Merged

Conversation

falbrechtskirchinger
Copy link
Contributor

Add a non-fatal check to see if sources have been formatted. Unfortunately, there are minor version differences. Version 18 (the default in ubuntu-latest) formats differently than versions 19 and 20.
I'm not including the examples for now to not make too much noise.

@yhirose
Copy link
Owner

yhirose commented Feb 16, 2025

@falbrechtskirchinger thanks for the nice tool. 👍

Instead of using the clang-format-19, could you please try to use the version in the latest-ubuntu by adjusting .clang-format file in the repo?

Could you also exclude /test/httplib.h and /test/httplib.cc from the style check since they are automatically generated?

Also could you make an adjustment to clean: section to remove files generated by the style check like *.formatted?

Thanks!

@falbrechtskirchinger
Copy link
Contributor Author

@falbrechtskirchinger thanks for the nice tool. 👍

Instead of using the clang-format-19, could you please try to use the version in the latest-ubuntu by adjusting .clang-format file in the repo?

The problem is two lines, where an initialization of a struct is mistaken for a definition of one and a space is inserted, where it doesn't belong. Changing the style of the initialization will probably fix that and simplify the workflow.

Could you also exclude /test/httplib.h and /test/httplib.cc from the style check since they are automatically generated?

Sure.

Also could you make an adjustment to clean: section to remove files generated by the style check like *.formatted?

.formatted files are removed via this line:

rm -f $$file.formatted; \

Do you want it in clean anyway?

@yhirose
Copy link
Owner

yhirose commented Feb 16, 2025

Do you want it in clean anyway?

Oh, I missed that... You don't have to change clean: 😃

@falbrechtskirchinger
Copy link
Contributor Author

falbrechtskirchinger commented Feb 16, 2025

You'll notice these lines in the diff of httplib.h (in the style check output):

-  struct in6_addr addr6{};
-  struct in_addr addr{};
+  struct in6_addr addr6 {};
+  struct in_addr addr {};

Changing these initializations to = {}; will make them format consistently across versions 18, 19, and 20.

@yhirose
Copy link
Owner

yhirose commented Feb 16, 2025

You'll notice these lines in the diff of httplib.h (in the style check output):

-  struct in6_addr addr6{};
-  struct in_addr addr{};
+  struct in6_addr addr6 {};
+  struct in_addr addr {};

Changing these initializations to = {}; will make them format consistently across versions 18, 19, and 20.

Sounds good to me. Please go ahead to make the change = {}; in httplib.h, as well as other format errors. Thanks!

@falbrechtskirchinger
Copy link
Contributor Author

Sounds good to me. Please go ahead to make the change = {}; in httplib.h, as well as other format errors. Thanks!

Done. #2063

I've also added the example files, as it only affected one file.

@yhirose
Copy link
Owner

yhirose commented Feb 17, 2025

Thanks for the adjustments!

@yhirose yhirose merged commit 574f5ce into yhirose:master Feb 17, 2025
5 of 6 checks passed
@falbrechtskirchinger falbrechtskirchinger deleted the style-check branch February 17, 2025 19:06
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.

2 participants