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

Pass clang-format on various cpp/header files #5559

Merged
merged 1 commit into from
Apr 23, 2017

Conversation

nerzhul
Copy link
Member

@nerzhul nerzhul commented Apr 10, 2017

I ran clang-format on all my header files and choose an interesting compliant subset. Please review and we merge, those headers are not heavily modified in PR.

@nerzhul nerzhul added the Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements label Apr 10, 2017
@nerzhul
Copy link
Member Author

nerzhul commented Apr 10, 2017

Please tell me if some files are not good and why, and i will remove them from the changeset permitting others to merge

@nerzhul
Copy link
Member Author

nerzhul commented Apr 10, 2017

I passed it on various cpp trivial files to fix too. This permits to cover ~12% of our files with clang-format LINT check

src/chat.h Outdated
name(a_name),
text(a_text)
ChatLine(EnrichedString a_name, EnrichedString a_text)
: age(0.0), name(a_name), text(a_text)
Copy link
Member

Choose a reason for hiding this comment

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

Spaces? Nope.

CavesRandomWalk(INodeDefManager *ndef, GenerateNotifier *gennotify = NULL,
s32 seed = 0, int water_level = 1,
content_t water_source = CONTENT_IGNORE,
content_t lava_source = CONTENT_IGNORE);
Copy link
Member

Choose a reason for hiding this comment

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

1-tab is fine according to our code style guidelines.

Copy link
Member

Choose a reason for hiding this comment

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

2-tab too?
The problem here is that we have to tell the formatter one of them...

@SmallJoker
Copy link
Member

The other code looks good. Feels like this is going to be a long way until everything's styled correctly.

@nerzhul
Copy link
Member Author

nerzhul commented Apr 10, 2017

@SmallJoker yeah i ran clang-format on all files, 60k modifications if i remember. I remove chat.h from this changeset

@nerzhul nerzhul changed the title Pass clang-format on various header files Pass clang-format on various cpp/header files Apr 10, 2017
@nerzhul
Copy link
Member Author

nerzhul commented Apr 10, 2017

i squashed the commits to have a full build with the current changeset

@nerzhul nerzhul closed this Apr 10, 2017
@nerzhul nerzhul reopened this Apr 10, 2017
@nerzhul
Copy link
Member Author

nerzhul commented Apr 10, 2017

@SmallJoker i rebased & squashed, please tell me if it's okay for you, i will merge when build was successful

src/httpfetch.h Outdated
void httpfetch_sync(const HTTPFetchRequest &fetch_request,
HTTPFetchResult &fetch_result);

void httpfetch_sync(const HTTPFetchRequest &fetch_request, HTTPFetchResult &fetch_result);
Copy link
Member

Choose a reason for hiding this comment

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

Length: 91, over the limits.

Copy link
Member Author

@nerzhul nerzhul Apr 10, 2017

Choose a reason for hiding this comment

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

strange to see how clang-format count, because it is limited to 90 chars

Copy link
Member Author

Choose a reason for hiding this comment

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

using python interpreter it's good

>>> len("void httpfetch_sync(const HTTPFetchRequest &fetch_request, HTTPFetchResult &fetch_result);")
90

Copy link
Member

Choose a reason for hiding this comment

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

90 is the absolute maximum. Whatever, looks good.

@nerzhul
Copy link
Member Author

nerzhul commented Apr 11, 2017

@sfan5 can you look at this please ?

Note: with this commit 83 files are checked by clang-format over a total of 465 => ~17%

@nerzhul nerzhul added this to the 0.4.16 milestone Apr 11, 2017
src/drawscene.h Outdated
void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, Camera &camera,
Client &client, LocalPlayer *player, Hud &hud, Minimap &mapper,
gui::IGUIEnvironment *guienv, const v2u32 &screensize,
const video::SColor &skycolor, bool show_hud, bool show_minimap);
Copy link
Member

Choose a reason for hiding this comment

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

while it may be useful to compact this, i would prefer if it didn't do this...

Copy link
Member Author

Choose a reason for hiding this comment

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

both are compact, one respect 80 chars other 90 chars are you sure you want me to revert this change ?

{
static void receiverReceive(MtEvent *e, void *data)
{
MtEventReceiver *r = (MtEventReceiver*)data;
MtEventReceiver *r = (MtEventReceiver *)data;
Copy link
Member

Choose a reason for hiding this comment

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

why did it add a space here?

Copy link
Member Author

Choose a reason for hiding this comment

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

because the rule for pointers is to have * at the right, then casts are affected

@@ -34,16 +34,16 @@ class KeyPress
KeyPress();
KeyPress(const char *name);

KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character=false);
KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character = false);
Copy link
Member

Choose a reason for hiding this comment

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

is this part of our guidelines?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it's a choice of LLVM to have readable code when using equal, and i'm not afraid, i prefer having it it permit to view more easily default values

@@ -55,7 +56,7 @@ void TestNodeDef::testContentFeaturesSerialization()

std::ostringstream os(std::ios::binary);
f.serialize(os, LATEST_PROTOCOL_VERSION);
//verbosestream<<"Test ContentFeatures size: "<<os.str().size()<<std::endl;
// verbosestream<<"Test ContentFeatures size: "<<os.str().size()<<std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

I understand why its doing this but this is quite stupid nonetheless

Copy link
Member Author

Choose a reason for hiding this comment

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

it's a tool, it's not an IA, the change it just for respect the coding style

@nerzhul
Copy link
Member Author

nerzhul commented Apr 13, 2017

@sfan5 waiting for your update :)

@nerzhul
Copy link
Member Author

nerzhul commented Apr 22, 2017

rebased and i removed some files from PR as they are not very convenient, i think i will merge it tomorrow

@nerzhul nerzhul merged commit 91a9382 into minetest:master Apr 23, 2017
@nerzhul nerzhul added this to Done in Minetest 0.4.16 Apr 29, 2017
@nerzhul nerzhul deleted the clang_format_header_4 branch January 6, 2018 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants