wgtmac commented on code in PR #1888:
URL: https://github.com/apache/orc/pull/1888#discussion_r1562214532


##########
c++/build-support/lint_exclusions.txt:
##########
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.

Review Comment:
   If there is nothing to exclude, probably remove it at all?



##########
.github/workflows/build_and_test.yml:
##########
@@ -169,19 +169,19 @@ jobs:
 
   formatting-check:
     name: "C++ format check"
-    runs-on: ubuntu-20.04
-    strategy:
-      matrix:
-        path:
-          - 'c++'
-          - 'tools'
+    runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v3
-    - name: Run clang-format style check for C++ code
-      uses: jidicula/[email protected]
-      with:
-        clang-format-version: '13'
-        check-path: ${{ matrix.path }}
+      - name: Checkout repository
+        uses: actions/checkout@v4
+      - name: Run build
+        run: |
+          mkdir build
+          cd build
+          cmake .. -DBUILD_JAVA=OFF -DCMAKE_CXX_COMPILER=clang++ 
-DCMAKE_C_COMPILER=clang -DSTOP_BUILD_ON_WARNING=OFF 
-DCMAKE_EXPORT_COMPILE_COMMANDS=1
+      - name: Check clang-tidy
+        run: make check-clang-tidy
+      - name: check clang-format

Review Comment:
   ```suggestion
         - name: Check clang-format
   ```



##########
cmake_modules/CheckFormat.cmake:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Needed for linting targets, etc.
+# Use the first Python installation on PATH, not the newest one
+set(Python3_FIND_STRATEGY "LOCATION")
+# On Windows, use registry last, not first
+set(Python3_FIND_REGISTRY "LAST")
+# On macOS, use framework last, not first
+set(Python3_FIND_FRAMEWORK "LAST")
+
+find_package(Python3)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+
+set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/c++/build-support")
+
+find_program(CLANG_FORMAT_BIN
+        NAMES clang-format clang-format-14
+        HINTS ${CLANG_SEARCH_PATH})
+
+find_program(CLANG_TIDY_BIN
+        NAMES clang-tidy clang-tidy-14
+        HINTS ${CLANG_SEARCH_PATH})
+
+find_program(CLANG_APPLY_REPLACEMENTS_BIN
+        NAMES clang-apply-replacements clang-apply-replacements-14
+        HINTS ${CLANG_SEARCH_PATH})
+
+
+if("${CLANG_FORMAT_BIN}" STREQUAL "CLANG_FORMAT_BIN-NOTFOUND")
+        message(WARNING "Couldn't find clang-format.")
+else()
+        message(STATUS "Found clang-format at ${CLANG_FORMAT_BIN}")
+endif()
+
+if("${CLANG_TIDY_BIN}" STREQUAL "CLANG_TIDY_BIN-NOTFOUND")
+        message(WARNING "Couldn't find clang-tidy.")
+else()
+        # Output compile_commands.json
+        set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+        message(STATUS "Found clang-tidy at ${CLANG_TIDY_BIN}")
+endif()
+
+if("${CLANG_APPLY_REPLACEMENTS_BIN}" STREQUAL 
"CLANG_APPLY_REPLACEMENTS_BIN-NOTFOUND")
+        message(WARNING "Couldn't find clang-apply-replacements.")
+else()
+        # Output compile_commands.json
+        set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+        message(STATUS "Found clang-apply-replacements at 
${CLANG_APPLY_REPLACEMENTS_BIN}")
+endif()
+
+if(NOT LINT_EXCLUSIONS_FILE)
+        # source files matching a glob from a line in this file
+        # will be excluded from linting (cpplint, clang-tidy, clang-format)
+        set(LINT_EXCLUSIONS_FILE ${BUILD_SUPPORT_DIR}/lint_exclusions.txt)
+endif()
+
+# runs clang-tidy and exits with a non-zero exit code if any errors are found.
+# note that clang-tidy automatically looks for a .clang-tidy file in parent 
directories
+add_custom_target(check-clang-tidy

Review Comment:
   Could you also add a README in the build-support folder to simply describe 
how to use these commands?



##########
c++/src/OrcHdfsFile.cc:
##########
@@ -42,23 +42,23 @@ namespace orc {
 
   class HdfsFileInputStream : public InputStream {
    private:
-    std::string filename;
-    std::unique_ptr<hdfs::FileHandle> file;
-    std::unique_ptr<hdfs::FileSystem> file_system;
-    uint64_t totalLength;
-    const uint64_t READ_SIZE = 1024 * 1024;  // 1 MB
-    ReaderMetrics* metrics;
+    std::string filename_;
+    std::unique_ptr<hdfs::FileHandle> file_;
+    std::unique_ptr<hdfs::FileSystem> file_system_;
+    uint64_t totalLength_;
+    const uint64_t READ_SIZE_ = 1024 * 1024;  // 1 MB

Review Comment:
   This change looks a little bit weird.



##########
c++/src/OrcHdfsFile.cc:
##########
@@ -42,23 +42,23 @@ namespace orc {
 
   class HdfsFileInputStream : public InputStream {
    private:
-    std::string filename;
-    std::unique_ptr<hdfs::FileHandle> file;
-    std::unique_ptr<hdfs::FileSystem> file_system;
-    uint64_t totalLength;
-    const uint64_t READ_SIZE = 1024 * 1024;  // 1 MB
-    ReaderMetrics* metrics;
+    std::string filename_;
+    std::unique_ptr<hdfs::FileHandle> file_;
+    std::unique_ptr<hdfs::FileSystem> file_system_;

Review Comment:
   fileSystem_ ?



##########
cmake_modules/CheckFormat.cmake:
##########
@@ -0,0 +1,113 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Needed for linting targets, etc.
+# Use the first Python installation on PATH, not the newest one
+set(Python3_FIND_STRATEGY "LOCATION")
+# On Windows, use registry last, not first
+set(Python3_FIND_REGISTRY "LAST")
+# On macOS, use framework last, not first
+set(Python3_FIND_FRAMEWORK "LAST")
+
+find_package(Python3)
+set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
+
+set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/c++/build-support")
+
+find_program(CLANG_FORMAT_BIN
+        NAMES clang-format clang-format-14

Review Comment:
   why add clang-format and clang-format-14 at the same time?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to