9
66
Fork
You've already forked Bolt
11

Ran clang-tidy -fix for all the cxx/hxx files in src and app. #20

Open
smithcol11 wants to merge 2 commits from smithcol11/Bolt:lint-clang-tidy-fix into master
pull from: smithcol11/Bolt:lint-clang-tidy-fix
merge into: Adamcake:master
Adamcake:master
Adamcake:zigify
Contributor
Copy link

Apologies in advance for the monster PR here. It consists entirely of clang-tidy fixes; avoiding any functional change.

After all the auto fixes were applied, I spent some time doing a few more linter suggestions. The goal was to fix items that didn't change functionality.

  • Change a few reinterpret casts
  • Give function declarations named variables
  • More liberally use const references
  • Cleanup some pointer arithmetic (although there are more to fix)
  • Change some typedefs and defines to their cpp counterparts
  • Replace deprecated macros
  • Narrowing (there are more though)
  • More I am forgetting

There are still plenty clang tidy warnings, but some require delicate refactors, type changes, and more cpp idomatic code.

As a result of touching many lines, I thought it fitting to also give the .clang-format some reasonable rules. I gave it rules similar to the .editorconfig. Then I allowed the formatter to modify only lines that I touched. It may be worth doing a larger format over the whole codebase, but I didn't want to own all of those changes. I think some checkin rules or git action can do that without changing the line owner.

Final note, I did not test this on Windows but didn't see any lines that would have effected a Win build. Worth checking for sure.

Let me know what you think, cheers.

Apologies in advance for the monster PR here. It consists entirely of `clang-tidy` fixes; avoiding any functional change. After all the auto fixes were applied, I spent some time doing a few more linter suggestions. The goal was to fix items that didn't change functionality. - Change a few reinterpret casts - Give function declarations named variables - More liberally use const references - Cleanup some pointer arithmetic (although there are more to fix) - Change some typedefs and defines to their cpp counterparts - Replace deprecated macros - Narrowing (there are more though) - More I am forgetting There are still plenty clang tidy warnings, but some require delicate refactors, type changes, and more cpp idomatic code. As a result of touching many lines, I thought it fitting to also give the `.clang-format` some reasonable rules. I gave it rules similar to the `.editorconfig`. Then I allowed the formatter to modify only lines that I touched. It may be worth doing a larger format over the whole codebase, but I didn't want to own all of those changes. I think some checkin rules or git action can do that without changing the line owner. **Final note, I did not test this on Windows but didn't see any lines that would have effected a Win build. Worth checking for sure.** Let me know what you think, cheers.

There are some instances of spaces being replaced by tabs, but only for the lines of code that were actually changed by clang.

Come to think of it, is there a way for it to actively replace tabs with 4x spaces?

There are some instances of spaces being replaced by tabs, but only for the lines of code that were actually changed by clang. Come to think of it, is there a way for it to actively replace tabs with 4x spaces?

Not sure why it has replaced all instances of std::endl with '\n'. This wouldn't be a correct change on Windows, although I don't think there are any cases in this PR where it the incorrectness would actually affect anything.

Not sure why it has replaced all instances of `std::endl` with `'\n'`. This wouldn't be a correct change on Windows, although I don't think there are any cases in this PR where it the incorrectness would actually affect anything.

PointerAlignment=Left please. I know it's divisive, but it's how I write pointers and it's also how CEF writes them.

[PointerAlignment=Left](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#pointeralignment) please. I know it's divisive, but it's how I write pointers and it's also how CEF writes them.
Author
Contributor
Copy link

Hey, thanks for taking a look. Addressing your comments:

  1. Yeah your editor config mentioned tabs, so I had clang-format do all indentation in tabs. This can be changed to spaces if you would like?
  2. Perhaps it is a performance thing? My understanding of std::endl vs \n is that the endl will flush the buffer, which isn't always necessary (but is that performance even a concern here; we could remove that rule from clang-tidy). A second thing to note, '\n' should be fine on Windows; I think it is cross platform safe and gets converted to the the proper end line sequence for the target.
  3. Sure I will change that. I actually agree with you and prefer the left aligned pointer. I didn't want to make too many assumptions / bloat the format file unless it was something you really wanted; I will add that.
Hey, thanks for taking a look. Addressing your comments: 1. Yeah your editor config mentioned tabs, so I had clang-format do all indentation in tabs. This can be changed to spaces if you would like? 2. Perhaps it is a performance thing? My understanding of std::endl vs \n is that the endl will flush the buffer, which isn't always necessary (but is that performance even a concern here; we could remove that rule from clang-tidy). A second thing to note, '\n' should be fine on Windows; I think it is cross platform safe and gets converted to the the proper end line sequence for the target. 3. Sure I will change that. I actually agree with you and prefer the left aligned pointer. I didn't want to make too many assumptions / bloat the format file unless it was something you really wanted; I will add that.
smithcol11 force-pushed lint-clang-tidy-fix from c54016479e to c53aa80e0b 2026年01月24日 17:36:57 +01:00 Compare
Author
Contributor
Copy link

@Adamcake I changed the clang-format style to be Chromium based, with the modifications to tabs and pointer alignment.
Then I reset back one commit and redid the formatting on just my changes.

Let me know what you think, cheers.

@Adamcake I changed the clang-format style to be Chromium based, with the modifications to tabs and pointer alignment. Then I reset back one commit and redid the formatting on just my changes. Let me know what you think, cheers.
Author
Contributor
Copy link

@Adamcake Wanted to follow up with this. I noticed since opening this, some clang-tidy checks have been added, and the formatting is still disabled. If you aren't interested in the auto formats and lint fixes I made, let me know and I can close this!

@Adamcake Wanted to follow up with this. I noticed since opening this, some clang-tidy checks have been added, and the formatting is still disabled. If you aren't interested in the auto formats and lint fixes I made, let me know and I can close this!
This pull request has changes conflicting with the target branch.
  • .clang-tidy
  • src/browser.cxx
  • src/browser.hxx
  • src/browser/app.cxx
  • src/browser/client.cxx
  • src/browser/client.hxx
  • src/browser/request.hxx
  • src/browser/resource_handler.cxx
  • src/browser/resource_handler.hxx
  • src/browser/window_launcher.cxx
  • src/browser/window_launcher.hxx
  • src/browser/window_launcher_posix.cxx
  • src/browser/window_plugin.hxx
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u lint-clang-tidy-fix:smithcol11-lint-clang-tidy-fix
git switch smithcol11-lint-clang-tidy-fix

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff smithcol11-lint-clang-tidy-fix
git switch smithcol11-lint-clang-tidy-fix
git rebase master
git switch master
git merge --ff-only smithcol11-lint-clang-tidy-fix
git switch smithcol11-lint-clang-tidy-fix
git rebase master
git switch master
git merge --no-ff smithcol11-lint-clang-tidy-fix
git switch master
git merge --squash smithcol11-lint-clang-tidy-fix
git switch master
git merge --ff-only smithcol11-lint-clang-tidy-fix
git switch master
git merge smithcol11-lint-clang-tidy-fix
git push origin master
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Adamcake/Bolt!20
Reference in a new issue
Adamcake/Bolt
No description provided.
Delete branch "smithcol11/Bolt:lint-clang-tidy-fix"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?