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

Format with uncrustify #3388

Merged
merged 11 commits into from
Aug 7, 2021
Merged

Format with uncrustify #3388

merged 11 commits into from
Aug 7, 2021

Conversation

pfultz2
Copy link
Contributor

@pfultz2 pfultz2 commented Aug 7, 2021

No description provided.

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

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

uncrustify looks promising

lib/checkio.h Outdated
@@ -75,7 +73,7 @@ class CPPCHECKLIB CheckIO : public Check {

private:
class ArgumentInfo {
public:
public:
Copy link
Owner

Choose a reason for hiding this comment

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

hmm this indentation looks very strange. fixable?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes! It was fixable with:

indent_access_spec              = -4

@danmar
Copy link
Owner

danmar commented Aug 7, 2021

as far as I see uncrustify is lightweight and easy to build. and the formatting looks acceptable. It is totally acceptable for me.

However I do not understand the problem with astyle. I do not get any compilation error when I build for instance astyle-3.0.1 with g++ 8.3.0. cd astyle/build/gcc && make.. can you clarify .. this is not working for you?

The formatting is not perfect with astyle-3.0.1 but it's something at least I can accept. I do not believe formatting will be perfect with any tool. As you said somewhere it's not a good idea to clutter the code with INDENT-* comments.

cli/main.cpp Outdated
std::cout << "Unknown exception" << std::endl;
}
return EXIT_FAILURE;
}
Copy link
Owner

Choose a reason for hiding this comment

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

this is unfortunate. astyle handled this piece of code better. but I guess it's a rare case and can accept it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea uncrustify can't match up the braces, it throws this error on this file:

flag_parens(22): no match for '{' at [93:9] [CallStack:-DEBUG NOT SET-]

@pfultz2
Copy link
Contributor Author

pfultz2 commented Aug 7, 2021

However I do not understand the problem with astyle. I do not get any compilation error when I build for instance astyle-3.0.1 with g++ 8.3.0. cd astyle/build/gcc && make.. can you clarify .. this is not working for you?

Doing make install PREFIX=$SOME_PATH doesn't work at the top-level. I dont want to figure out which directory I need to jump into if I am using clang or gcc or mac or linux. Astyle 3.1 does provide a top-level cmake file but it hardcodes /usr as the install path. Although, most package managers provide astyle 3.1 so it is easier to install(but it doesn't provide astyle 3.0.1).

The formatting is not perfect with astyle-3.0.1 but it's something at least I can accept.

The syntax errors are unacceptable. Also, I find the readability to be unacceptable(like here), which is why I use INDENT-OFF so it wont mess up the formatting and will maintain readability.

I do not believe formatting will be perfect with any tool.

Well tools like uncrustify and astyle are definitely not perfect as they only consider one way to format whereas as clang-format will try to choose the best formatting among different possibilities.

Since you dont want to use clang-format due to slow internet connection, I think uncrustify is a much better option. It has more settings that can be tweaked and is being actively developed so the issues that we find may be fixed in a future version.

, mExitAfterPrint(false)
{
}
, mShowHelp(false)
Copy link
Owner

Choose a reason for hiding this comment

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

hmm.. can this comma have the same indentation as the colon?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but if we use trailing commas then the variables will be aligned to the : instead of variable name.

Copy link
Owner

Choose a reason for hiding this comment

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

ok that is unfortunate.. but maybe we can adjust the source files..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I changed the indent_constr_colon setting to false to get it to align with leading commas. You can tweak this and the source files to get the style you want. There might be a way to enforce trailing commas, but I am not sure.

@danmar
Copy link
Owner

danmar commented Aug 7, 2021

ok let's switch to uncrustify..

@danmar
Copy link
Owner

danmar commented Aug 7, 2021

I hope you are happy.. I merge this.

@danmar danmar merged commit 7f358b2 into danmar:main Aug 7, 2021
@pfultz2
Copy link
Contributor Author

pfultz2 commented Aug 7, 2021

Thanks!

@pfultz2 pfultz2 deleted the uncrustify-format branch August 7, 2021 20:55
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