Skip to content

Issue #958: Travis CI should enforce clang-format standards #1026

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

Merged
merged 5 commits into from
Oct 11, 2019

Conversation

baylesj
Copy link
Contributor

@baylesj baylesj commented Sep 16, 2019

This patch adds clang format support to the travis bots.

@baylesj
Copy link
Contributor Author

baylesj commented Sep 16, 2019

Any issues with pulling the run-clang-format.py script? It's MIT licensed.

@dota17
Copy link
Member

dota17 commented Sep 17, 2019

Some questions for me.

  1. After running these command from Building

cd jsoncpp/
BUILD_TYPE=release
#plain, debug, debugoptimized, release, minsize
LIB_TYPE=shared
#LIB_TYPE=static
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
ninja -v -C build-${LIB_TYPE} test

I run

ninja -v -C build-${LIB_TYPE} clang-format

and I got these changes (some changes were wrong) :
run-clang-format.txt

  1. From PR Just run clang format #1025 , I found that
    Value& root and IStream & is, Value & root
    before char &, some places have a blank, some places have no.

  2. To test this PR, I run some tests by pushing some wrong format codes. It is OK to check the wrong format.
    But the third test [Mac clang meson static release testing] is error, and the error message is
    run-clang-format.py: error: Command 'clang-format --version' failed to start: [Errno 2] No such file or directory
    Is it better to remove format check in third test or update the env?

@baylesj
Copy link
Contributor Author

baylesj commented Sep 17, 2019

  1. This should not change the results of ninja clang-format at all, so I'm not sure what the cause of what you are seeing is. This only affects Travis. Update: I have changed our clang format settings so that it is more consistent and should look better now.

  2. Updated to fix pointer binding. They renamed the config value.

  3. I can fix that, I think clang format isn't installing properly on mac.

@baylesj baylesj changed the title Issue #958: Travis CI should enfore clang-format standards Issue #958: Travis CI should enforce clang-format standards Sep 17, 2019
@dota17
Copy link
Member

dota17 commented Sep 18, 2019

hi, I have checked the new commit and find the question 2 and 3 have been repaired.
however, as for the question 1,I have some questions.

  1. After merging the fix-deprecated to clang-formatize and building, I get this result:
    test.txt
+[[noreturn]] void throwRuntimeError(String const& msg) {
+  abort();
+}[[noreturn]] void throwLogicError(String const& msg) {
+  abort();
+}

this change is wrong and it means this clang-format standards still have some questons.

  1. the clang-format result in local is different from the result of Travis CI.
    I run ./travis_scripts/run-clang-format.sh in my local computer and get the same changes with test.txt.
run-clang-format.sh: 3: run-clang-format.sh: Bad substitution
--- /root/jsoncpp/community/jsoncpp/.travis_scripts/../src/lib_json/json_value.cpp      (original)
+++ /root/jsoncpp/community/jsoncpp/.travis_scripts/../src/lib_json/json_value.cpp      (reformatted)
@@ -206,14 +206,17 @@
 Exception::~Exception() JSONCPP_NOEXCEPT {}
 char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
 RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
-LogicError::LogicError(String const& msg) : Exception(msg) {}
-[[noreturn]] void throwRuntimeError(String const& msg) {
+LogicError::LogicError(String const& msg)
+    : Exception(msg){}[[noreturn]] void throwRuntimeError(String const& msg) {
   throw RuntimeError(msg);
 }
 [[noreturn]] void throwLogicError(String const& msg) { throw LogicError(msg); }
 #else // !JSON_USE_EXCEPTION
-[[noreturn]] void throwRuntimeError(String const& msg) { abort(); }
-[[noreturn]] void throwLogicError(String const& msg) { abort(); }
+[[noreturn]] void throwRuntimeError(String const& msg) {
+  abort();
+}[[noreturn]] void throwLogicError(String const& msg) {
+  abort();
+}
 #endif

 // //////////////////////////////////////////////////////////////////
@@ -227,7 +230,9 @@
 // Notes: policy_ indicates if the string was allocated when
 // a string is stored.

-Value::CZString::CZString(ArrayIndex index) : cstr_(nullptr), index_(index) {}
+Value::CZString::CZString(ArrayIndex index)
+    : cstr_(nullptr), index_(index) {
+}

 Value::CZString::CZString(char const* str, unsigned length,
                           DuplicationPolicy allocate)

The results are same.

@dota17
Copy link
Member

dota17 commented Sep 26, 2019

The Travis CI checks were not successful, Fixed it by #1036

@dota17
Copy link
Member

dota17 commented Oct 8, 2019

The above problem in my local env had been solved.
Tips: use the current version - clang-8 and clang-format-8

@baylesj baylesj merged commit f34bf24 into master Oct 11, 2019
@baylesj baylesj deleted the clang-formatize branch October 11, 2019 18:21
@cdunn2001
Copy link
Contributor

Very nice!

@cdunn2001
Copy link
Contributor

Hmmm. Today I hit a tiny clang-format error. I guess we have to run clang-format now locally before pushing. I've added a script for that in #1229. I hope different versions of clang-format don't disagree with each other.

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.

3 participants