[go: up one dir, main page]

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

RFC: added preliminary .clang-format file #1875

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

lynxlynxlynx
Copy link
Member
@lynxlynxlynx lynxlynxlynx commented Aug 4, 2023

Started working on #161. I've updated a previous draft to version 17 (just about to be released), but 16 is fine as well.

The rule file is in the commit, while the effect of clang-format -i gemrb/**/*.[ch] gemrb/**/*.cpp can be seen here: https://gist.github.com/lynxlynxlynx/87ca0bb6dec4633ef07d4b9a523078a6
As expected some things are not ideal (eg. when to inline functions), but in general it looks ok to me.

TODO:

  • .clang-format: set a max column width at all?
    • move some of the comments, so they don't cause silly wrapping
  • exclude fmt
  • pass --Wno-error=unknown so it doesn't choke if ran by older version
  • test the difference between 16 (currently available runners) and 17 (current rules)

Infra stuff mentioned in the bug

Docs:

  • update CONTRIBUTING
  • remove gemrb/docs/en/CodingStyle.txt
  • update website

@lynxlynxlynx lynxlynxlynx marked this pull request as draft August 4, 2023 09:57
@MarcelHB
Copy link
Collaborator
MarcelHB commented Aug 4, 2023

I scrolled through the diff and I like it :)

@lynxlynxlynx lynxlynxlynx linked an issue Aug 4, 2023 that may be closed by this pull request
@bradallred
Copy link
Member
bradallred commented Aug 4, 2023

The only thing that has caught my eye is the lack of space when using braced initialization eg:

-	std::vector<Ambient *> ambients;
-	std::atomic_bool active {false};
+	std::vector<Ambient*> ambients;
+	std::atomic_bool active{false};

I would have an easier time reading if the identifier was separated from the initialization like it was before.

@lynxlynxlynx
Copy link
Member Author

Pretty sure that can be changed, yeah. I went with the currently prevailing style.

@lynxlynxlynx
Copy link
Member Author

Yeah, it's SpaceBeforeCpp11BracedList. It also applies to cases like these, but that's fine by me:

-          Log(DEBUG, "FindPath", "Pathing failed for {}", fmt::WideToChar{caller->GetShortName()});
+          Log(DEBUG, "FindPath", "Pathing failed for {}", fmt::WideToChar {caller->GetShortName()});
-  auto key = std::string{tablename.c_str()};
+  auto key = std::string {tablename.c_str()};

@bradallred
Copy link
Member

yeah, that looks good

@sonarcloud
Copy link
sonarcloud bot commented Aug 15, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@lynxlynxlynx
Copy link
Member Author
lynxlynxlynx commented Aug 15, 2023

Ok, all seems to be working fine. The pre-commit hook gets installed and makes you comply before committing anything and if anyone circumvents that the PR style checker will catch it.

Made it use annotations instead of spamming comments like sonar:
d14014b ... and apparently they don't persist after new commits, nevermind

@lynxlynxlynx
Copy link
Member Author

I've cleaned up the history, but I'll wait with the big reformat stuff while all the other PRs are open. You can cherry-pick 9fc535d and a9eeeb7 (and move to .git/hooks) if you want it sooner.

This comment was marked as off-topic.

@MarcelHB
Copy link
Collaborator

Given I have so many different projects, or at least memories of them, and their presumable conventions, I'd be happy to get this at hands.

@lynxlynxlynx
Copy link
Member Author

I've been using it for the past year. Sometimes it seems to suggest wrong things when just looking at the changed diff or pulls in too many other changes, but this problem will go away once we reformat (--no-verify can be used when needed until then).

I suggest we merge it after #1876.

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.

define the C++ coding style
3 participants