From 1f122f04c80740c286a8d728de80dae80c672821 Mon Sep 17 00:00:00 2001 From: Junwang Zhao Date: Thu, 23 Jan 2025 22:48:53 +0800 Subject: [PATCH 1/4] Add a .clang-tidy to explicitly specify the check rules. Signed-off-by: Junwang Zhao --- .clang-tidy | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..cca8dfef5 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,37 @@ +# 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. +--- +Checks: | + -*, + clang-diagnostic-*, + clang-analyzer-*, + google-*, + modernize-*, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, + +CheckOptions: + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + +HeaderFilterRegex: '(src|test|example)' From 2708d07c6ed255b53cf3c564de2f26f883e8da01 Mon Sep 17 00:00:00 2001 From: Junwang Zhao Date: Fri, 24 Jan 2025 00:07:39 +0800 Subject: [PATCH 2/4] enforce [[nodiscard]] Signed-off-by: Junwang Zhao --- .clang-tidy | 1 - src/iceberg/arrow/demo_arrow.h | 2 +- src/iceberg/demo_table.h | 2 +- src/iceberg/puffin.h | 2 +- src/iceberg/puffin/demo_puffin.h | 2 +- src/iceberg/table.h | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index cca8dfef5..1c4714c54 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -21,7 +21,6 @@ Checks: | clang-analyzer-*, google-*, modernize-*, - -modernize-use-nodiscard, -modernize-use-trailing-return-type, CheckOptions: diff --git a/src/iceberg/arrow/demo_arrow.h b/src/iceberg/arrow/demo_arrow.h index 61ac953c5..cc51e113a 100644 --- a/src/iceberg/arrow/demo_arrow.h +++ b/src/iceberg/arrow/demo_arrow.h @@ -30,7 +30,7 @@ class ICEBERG_ARROW_EXPORT DemoArrow : public Table { public: DemoArrow() = default; ~DemoArrow() override = default; - std::string print() const override; + [[nodiscard]] std::string print() const override; }; } // namespace iceberg::arrow diff --git a/src/iceberg/demo_table.h b/src/iceberg/demo_table.h index 2dabaa5ca..749daa150 100644 --- a/src/iceberg/demo_table.h +++ b/src/iceberg/demo_table.h @@ -28,7 +28,7 @@ class ICEBERG_EXPORT DemoTable : public Table { DemoTable() = default; ~DemoTable() override = default; - std::string print() const override; + [[nodiscard]] std::string print() const override; }; } // namespace iceberg diff --git a/src/iceberg/puffin.h b/src/iceberg/puffin.h index 52514f76f..3aed6aab9 100644 --- a/src/iceberg/puffin.h +++ b/src/iceberg/puffin.h @@ -28,7 +28,7 @@ namespace iceberg { class ICEBERG_EXPORT Puffin { public: virtual ~Puffin() = default; - virtual std::string print() const = 0; + [[nodiscard]] virtual std::string print() const = 0; }; } // namespace iceberg diff --git a/src/iceberg/puffin/demo_puffin.h b/src/iceberg/puffin/demo_puffin.h index 3544b7c10..55ef65313 100644 --- a/src/iceberg/puffin/demo_puffin.h +++ b/src/iceberg/puffin/demo_puffin.h @@ -28,7 +28,7 @@ class ICEBERG_PUFFIN_EXPORT DemoPuffin : public Puffin { public: DemoPuffin() = default; ~DemoPuffin() override = default; - std::string print() const override; + [[nodiscard]] std::string print() const override; }; } // namespace iceberg::puffin diff --git a/src/iceberg/table.h b/src/iceberg/table.h index 1d3700804..0d8ebdc06 100644 --- a/src/iceberg/table.h +++ b/src/iceberg/table.h @@ -29,7 +29,7 @@ namespace iceberg { class ICEBERG_EXPORT Table { public: virtual ~Table() = default; - virtual std::string print() const = 0; + [[nodiscard]] virtual std::string print() const = 0; }; } // namespace iceberg From ed9f1134bcf197a0665a9d770378be61aa456684 Mon Sep 17 00:00:00 2001 From: Junwang Zhao Date: Fri, 24 Jan 2025 16:30:17 +0800 Subject: [PATCH 3/4] Revert "enforce [[nodiscard]]" This reverts commit 2708d07c6ed255b53cf3c564de2f26f883e8da01. --- .clang-tidy | 1 + src/iceberg/arrow/demo_arrow.h | 2 +- src/iceberg/demo_table.h | 2 +- src/iceberg/puffin.h | 2 +- src/iceberg/puffin/demo_puffin.h | 2 +- src/iceberg/table.h | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1c4714c54..cca8dfef5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -21,6 +21,7 @@ Checks: | clang-analyzer-*, google-*, modernize-*, + -modernize-use-nodiscard, -modernize-use-trailing-return-type, CheckOptions: diff --git a/src/iceberg/arrow/demo_arrow.h b/src/iceberg/arrow/demo_arrow.h index cc51e113a..61ac953c5 100644 --- a/src/iceberg/arrow/demo_arrow.h +++ b/src/iceberg/arrow/demo_arrow.h @@ -30,7 +30,7 @@ class ICEBERG_ARROW_EXPORT DemoArrow : public Table { public: DemoArrow() = default; ~DemoArrow() override = default; - [[nodiscard]] std::string print() const override; + std::string print() const override; }; } // namespace iceberg::arrow diff --git a/src/iceberg/demo_table.h b/src/iceberg/demo_table.h index 749daa150..2dabaa5ca 100644 --- a/src/iceberg/demo_table.h +++ b/src/iceberg/demo_table.h @@ -28,7 +28,7 @@ class ICEBERG_EXPORT DemoTable : public Table { DemoTable() = default; ~DemoTable() override = default; - [[nodiscard]] std::string print() const override; + std::string print() const override; }; } // namespace iceberg diff --git a/src/iceberg/puffin.h b/src/iceberg/puffin.h index 3aed6aab9..52514f76f 100644 --- a/src/iceberg/puffin.h +++ b/src/iceberg/puffin.h @@ -28,7 +28,7 @@ namespace iceberg { class ICEBERG_EXPORT Puffin { public: virtual ~Puffin() = default; - [[nodiscard]] virtual std::string print() const = 0; + virtual std::string print() const = 0; }; } // namespace iceberg diff --git a/src/iceberg/puffin/demo_puffin.h b/src/iceberg/puffin/demo_puffin.h index 55ef65313..3544b7c10 100644 --- a/src/iceberg/puffin/demo_puffin.h +++ b/src/iceberg/puffin/demo_puffin.h @@ -28,7 +28,7 @@ class ICEBERG_PUFFIN_EXPORT DemoPuffin : public Puffin { public: DemoPuffin() = default; ~DemoPuffin() override = default; - [[nodiscard]] std::string print() const override; + std::string print() const override; }; } // namespace iceberg::puffin diff --git a/src/iceberg/table.h b/src/iceberg/table.h index 0d8ebdc06..1d3700804 100644 --- a/src/iceberg/table.h +++ b/src/iceberg/table.h @@ -29,7 +29,7 @@ namespace iceberg { class ICEBERG_EXPORT Table { public: virtual ~Table() = default; - [[nodiscard]] virtual std::string print() const = 0; + virtual std::string print() const = 0; }; } // namespace iceberg From 6da3c09d496a56f3edc3951075de1bf3ebd58bc8 Mon Sep 17 00:00:00 2001 From: Junwang Zhao Date: Fri, 24 Jan 2025 17:24:29 +0800 Subject: [PATCH 4/4] change tidy-checks from file to '' Rely on a .clang-tidy config file by specifying `tidy-checks` option as a blank string (''), see [0] for details. [0] https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#tidy-checks Signed-off-by: Junwang Zhao --- .github/workflows/cpp-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index 6291ac999..cc1055537 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -43,7 +43,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: style: file - tidy-checks: file + tidy-checks: '' files-changed-only: true lines-changed-only: true thread-comments: true