-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Remove all empty lines from the start of blocks defined with braces #38812
Remove all empty lines from the start of blocks defined with braces #38812
Conversation
@@ -27,7 +27,6 @@ def generate_compressed_config(config_src, output_dir): | |||
|
|||
|
|||
namespace { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No empty new line allowed after namespaces either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion about it, but if we want to keep allowing them, I guess @aaronfranke's script could be improved to leave out cases starting with ^namespace {
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for sed
to modify newlines, we have to use the -z
option, which treats the whole file as a single line, and newline characters as normal characters (technically lines are delimited by null
). So it would be tricky to make a script that excludes namespace
. One easy idea is to just use the script as-is and manually revert changes to namespace
blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sed
is indeed too limited for multiple line matching, but perl -pi -e
works well: 07bc4e2
I guess you just needed to use the
|
core/io/file_access_zip.cpp
Outdated
@@ -38,7 +38,6 @@ | |||
ZipArchive *ZipArchive::instance = nullptr; | |||
|
|||
extern "C" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like for namespace {
, that's something where we might want to preserve the spacing for readability.
@@ -116,7 +115,6 @@ class HTTPClient : public Reference { | |||
}; | |||
|
|||
enum Method { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also empty lines before the closing };
for some enums. It would be great if we managed to fix those with a script too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work for closing braces at the start of lines, but not for indented closing braces.
sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f"
core/make_binders.py
Outdated
@@ -33,7 +33,6 @@ class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind { | |||
} | |||
|
|||
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Callable::CallError& r_error) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .py
files likely need a manual clang-formatting overall, there are lots of style issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(By manual I mean it should be done by a contributor visually, we can't run clang-format on Python files (one could trick it by copying the content in a .cpp
file, format it, and then copy back).
core/os/os.cpp
Outdated
@@ -95,7 +95,6 @@ uint64_t OS::get_system_time_msecs() const { | |||
} | |||
|
|||
void OS::debug_break(){ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format
does this weird thing on method definitions which end with an unnecessary semicolon, it's pretty messed up. It would be good to fix all occurrences of this (in a different PR):
$ rg "\(\)\{" -g'!thirdparty'
servers/audio/audio_driver_dummy.cpp
134:AudioDriverDummy::~AudioDriverDummy(){
core/command_queue_mt.h
287: virtual void post(){};
288: virtual ~CommandBase(){};
core/os/os.h
521: virtual void force_process_input(){};
core/os/thread_dummy.h
54: virtual void lock(){};
55: virtual void unlock(){};
core/os/os.cpp
96:void OS::debug_break(){
520:void OS::native_video_pause(){
524:void OS::native_video_unpause(){
528:void OS::native_video_stop(){
core/ring_buffer.h
221: ~RingBuffer<T>(){};
servers/physics/physics_server_sw.cpp
1445:void PhysicsServerSW::sync(){
1586:PhysicsServerSW::~PhysicsServerSW(){
servers/physics_2d/physics_2d_server_sw.cpp
1461:Physics2DServerSW::~Physics2DServerSW(){
core/io/file_access_buffered_fa.h
154: FileAccessBufferedFA(){
servers/physics/joints/jacobian_entry_sw.h
57: JacobianEntrySW(){};
drivers/coreaudio/audio_driver_coreaudio.cpp
704:AudioDriverCoreAudio::~AudioDriverCoreAudio(){};
core/vmap.h
205: _FORCE_INLINE_ VMap(){};
servers/arvr/arvr_interface.cpp
125:ARVRInterface::~ARVRInterface(){};
servers/arvr/arvr_positional_tracker.cpp
235:ARVRPositionalTracker::~ARVRPositionalTracker(){
core/object.h
581: _FORCE_INLINE_ static void register_custom_data_to_otdb(){};
drivers/dummy/rasterizer_dummy.h
754: RasterizerStorageDummy(){};
764: void canvas_begin(){};
765: void canvas_end(){};
platform/windows/key_mapping_windows.h
42: KeyMappingWindows(){};
platform/x11/key_mapping_x11.h
44: KeyMappingX11(){};
platform/uwp/thread_uwp.cpp
67:ThreadUWP::ThreadUWP(){
71:ThreadUWP::~ThreadUWP(){
platform/iphone/ios.mm
84:iOS::iOS(){};
platform/iphone/in_app_store.mm
337:InAppStore::~InAppStore(){};
platform/iphone/icloud.mm
357:ICloud::~ICloud(){};
platform/iphone/game_center.mm
398:GameCenter::~GameCenter(){};
platform/haiku/key_mapping_haiku.h
35: KeyMappingHaiku(){};
modules/gdscript/gdscript_tokenizer.h
180: virtual ~GDScriptTokenizer(){};
editor/rename_dialog.h
51: void _cancel_pressed(){};
115: ~RenameDialog(){};
modules/camera/camera_win.cpp
56:CameraFeedWindows::CameraFeedWindows(){
78:void CameraFeedWindows::deactivate_feed(){
85:void CameraWindows::add_active_cameras(){
96:CameraWindows::~CameraWindows(){
scene/main/viewport.cpp
177: TooltipPanel(){};
185: TooltipLabel(){};
scene/3d/vehicle_body.cpp
47: btVehicleJacobianEntry(){};
scene/3d/arvr_nodes.cpp
170:ARVRCamera::ARVRCamera(){
174:ARVRCamera::~ARVRCamera(){
389:ARVRController::~ARVRController(){
528:ARVRAnchor::~ARVRAnchor(){
619:ARVROrigin::~ARVROrigin(){
scene/3d/proximity_group.cpp
212:ProximityGroup::~ProximityGroup(){
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, should we also add the missing space between ()
and {
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(The above was from the 3.2
branch. I'm now working on fixing them.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Calinou That's what I was commenting about yes :)
core/safe_refcount.cpp
Outdated
@@ -58,7 +58,6 @@ | |||
} | |||
|
|||
_ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(volatile uint32_t *pw){ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's another case of weird formatting where the prototype ends with ){
, not sure why. The macros also need fixing for the missing braces on single-line statement (commenting here as I see it, but it doesn't have to be handled in this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like those happen because the macro call doesn't end with ;
. I'll fix that.
eb43be8
to
c211dfd
Compare
c211dfd
to
cabf916
Compare
cabf916
to
42ca4bb
Compare
42ca4bb
to
c4e77ca
Compare
c4e77ca
to
c367c9f
Compare
@akien-mga When you get a chance to review this again, I re-created the PR and modified the script to only remove newlines from the start of blocks when their contents are indented. This way, blocks for namespaces and Also, I tried replacing |
c367c9f
to
bc66239
Compare
Needs a rebase (possibly re-run), otherwise seems good. |
c9c3a61
to
97d4d1e
Compare
97d4d1e
to
306cb34
Compare
306cb34
to
41469ad
Compare
408e79f
to
0e7f3ec
Compare
0e7f3ec
to
a4114ff
Compare
a4114ff
to
7b662c1
Compare
7b662c1
to
02161aa
Compare
Thanks! |
New
|
There's a |
@bruvzg That's why there is the |
I did not noticed it. Condition probably works fine. Script did not removed lines from my PRs and I have tested sed commands manually to see what's wrong, script itself do not print any errors. |
Using |
Continuation of #38738, part of #33027.
To make this PR, I added these lines to the file formatting script:
These changes weren't made by clang-format for various reasons. Some of them are in comments, or aren't in C++ files. Some of them are enums, and for some reason clang-format doesn't change those. For some others, I don't know why clang-format hasn't changed them.
Unlike other PRs I make, I haven't looked over this line-by-line.