Conversation
|
This will need all the code correctly formatted before merging Anyway seems nice to me! |
|
@TheZ3ro we could do the formatting of all the code just before the next major, to avoid conflicts when backporting / upporting changes. |
.travis.yml
Outdated
|
|
||
| script: | ||
| - cmake -DCMAKE_BUILD_TYPE=${CONFIG} -DWITH_GUI_TESTS=ON -DWITH_ASAN=ON -DWITH_XC_HTTP=ON -DWITH_XC_AUTOTYPE=ON -DWITH_XC_YUBIKEY=ON $CMAKE_ARGS .. | ||
| - make format; git diff --exit-code |
|
@louib Nice work! |
I would like to propose the use of clang-tidy when making this one-time refactoring, as it could help fix some cases of missing readability braces around statements. Other checks could also be used, like the modernize-* ones. |
|
|
||
| This project follows the [Qt Coding Style](https://wiki.qt.io/Qt_Coding_Style). All submissions are expected to follow this style. | ||
| The coding style of the project is enforced using llvm's `clang-format` formatting tool. A thorough description | ||
| of the coding style can be found in the `.clang-format` file, but the main conventions are presented here. |
There was a problem hiding this comment.
Would it be useful to mention here the use of //clang-format off and //clang-format on for having ClangFormat ignore certain sections of the code? To illustrate the possible use-cases, an example could also be provided. I'm thinking on something like:
When deemed necessary, you can use //clang-format off and //clang-format on to have ClangFormat ignore certain parts of the code. For instance, from project's code-base:
// clang-format off
int binary =
((hmac[offset] & 0x7f) << 24)
| ((hmac[offset + 1] & 0xff) << 16)
| ((hmac[offset + 2] & 0xff) << 8)
| (hmac[offset + 3] & 0xff);
// clang-format onIn the example above, the manual formatting resulted in more readable code than the ClangFormat changes, hence the need for using the special comment lines.
|
@louib After trying this branch, I have another observation: The steps I followed:git clone https://github.com/louib/keepassxc.git
cd keepassxc
git checkout code_formatting
mkdir build && cd build
cmake ..
make formatThe error I got:Configuration file(s) do(es) not support Objective-C: /Users/adolfogc/Downloads/keepassxc/.clang-format
make[3]: *** [CMakeFiles/format] Error 1
make[2]: *** [CMakeFiles/format.dir/all] Error 2
make[1]: *** [CMakeFiles/format.dir/rule] Error 2
make: *** [format] Error 2❗️ Please note ClangFormat did affect the project files as expected. Possible solution:See my other comments in the code. |
cmake/CLangFormat.cmake
Outdated
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| set(THIRD_PARTY_DIRS |
There was a problem hiding this comment.
Include autotype/mac here.
cmake/CLangFormat.cmake
Outdated
| streams/QtIOCompressor | ||
| ) | ||
|
|
||
| set(THIRD_PARTY_FILES |
There was a problem hiding this comment.
Include core/ScreenLockListenerMac.h and core/ScreenLockListenerMac.cpp here.
There was a problem hiding this comment.
Would be nice to have all the third party files centralised in one directory...
There was a problem hiding this comment.
I'm not sure those two are third party code, they need to be excluded because they contain Objective-C code.
There was a problem hiding this comment.
They are not third-party.
Maybe we can exclude them in another group? 🤔
There was a problem hiding this comment.
I just renamed the lists so that we can exclude both third-party and obj-c files.
|
I like this solution @louib |
|
@adolfogc I tried setting up Can you try again |
|
|
||
| Formatting can be performed automatically by calling `make format` from the `build/` directory. | ||
|
|
||
| Note that [formatting can be disabled on a piece of code](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code) if manual formatting is deemed more readable. |
|
@louib I tested again using macOS, I can confirm the issue is now fixed. |
Sure, we can work on it in a next PR. |
|
@adolfogc cool, thanks! If you guys are good with the solution we can keep this PR open until before the next major release and then format the codebase and merge. I'd still like to have @droidmonkey 's approval since he wasn't convinced by the brute-force approach of enforcing formatting. My rationale for using |
TheZ3ro
left a comment
There was a problem hiding this comment.
For me it's an approval. Leaving the PR open until all the code is formatted before 2.3.0
|
I give my approval under the condition that we have a rough look through the code in advance and identify sections that need |
|
I'm good with this approach as long as we make a massive reformat (that doesn't impact functionality) right before we complete 2.3.0 |
2b3d14f to
d494741
Compare
|
@phoerious ping me when both PRs are merged, I'll do the formatting. Not sure how to do the TeamCity adjustment though. |
ccd63f4 to
ec680ea
Compare
|
@phoerious I'll let you take care of this one. |
d8fea07 to
a24d127
Compare
|
@phoerious rebased, changed base branch and reformatted the code. |
|
Do we still want to do this for 2.3.2 or 2.4 (ie develop) |
|
Sincerely, I think 2.4 it's better |
|
@keepassxreboot/core-developers rebased to develop and removed exclusion of |
|
I think we can merge this, everybody agrees? |
|
Lets bite the bullet and do it before we get too far down the road |
|
Seems that new code was added with #1702, we need to re-update this PR now |
|
@TheZ3ro should be good now. |
Fixes #1168
@droidmonkey @adolfogc @TheZ3ro what would you think about this?
How has this been tested?