Question: Exclude Generated Header Files from clang-tidy Checks

Aperta
#302 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp, python

Direzione di ricerca

Start by reading the linked CMakeLists.txt and package.xml attachments, then inspect how the project configures its clang-tidy test and how generate_parameter_library() creates headers. The report identifies generated headers under the build directory, including scorpio_base_parameters.hpp, as the files triggering warnings. Done means clang-tidy still checks user source files but excludes generated headers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When using the generate_parameter_library tool in a ROS2 project, the generated header files (e.g., those created by generate_parameter_library() in CMake) are being included in clang-tidy static analysis checks. This is problematic because these files are auto-generated and not part of the user's source code, leading to unnecessary warnings or errors that clutter the output and make it harder to focus on actual code quality issues in the developer's own files.

I would like to exclude these generated header files from clang-tidy checks while still allowing clang-tidy to analyze the rest of the codebase.

Has anyone attempted to solve this issue?

❯ colcon test-result --verbose
build/scorpio_base/Testing/20251220-0855/Test.xml: 2 tests, 0 errors, 1 failure, 0 skipped
- clang_tidy
  <<< failure message
    -- run_test.py: invoking following command in '/home/lihanchen/Downloads/tmp/src':
     - /opt/ros/humble/bin/ament_clang_tidy --xunit-file /home/lihanchen/Downloads/tmp/build/scorpio_base/test_results/scorpio_base/clang_tidy.xunit.xml /home/lihanchen/Downloads/tmp/build/scorpio_base --config /home/lihanchen/Downloads/tmp/src/.clang-tidy
    found compilation database for package "scorpio_base"...
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:108:15: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
          logger_{std::move(logger)} {
                  ^~~~~~~~~~      ~
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:120:12: warning: invalid case style for method 'get_params' [readability-identifier-naming]
        Params get_params() const{
               ^~~~~~~~~~
               getParams
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:131:10: warning: invalid case style for method 'try_update_params' [readability-identifier-naming]
        bool try_update_params(Params & params_in) const {
             ^~~~~~~~~~~~~~~~~
             tryUpdateParams
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:149:10: warning: invalid case style for method 'try_get_params' [readability-identifier-naming]
        bool try_get_params(Params & params_in) const {
             ^~~~~~~~~~~~~~
             tryGetParams
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:160:10: warning: invalid case style for method 'is_old' [readability-identifier-naming]
        bool is_old(Params const& other) const {
             ^~~~~~
             isOld
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:165:17: warning: invalid case style for method 'get_stack_params' [readability-identifier-naming]
        StackParams get_stack_params() {
                    ^~~~~~~~~~~~~~~~
                    getStackParams
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:177:10: warning: invalid case style for method 'refresh_dynamic_parameters' [readability-identifier-naming]
        void refresh_dynamic_parameters() {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
             refreshDynamicParameters
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:276:10: warning: invalid case style for method 'declare_params' [readability-identifier-naming]
        void declare_params(){
             ^~~~~~~~~~~~~~
             declareParams
    /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:439:12: warning: invalid case style for method 'update_internal_params' [readability-identifier-naming]
          void update_internal_params(Params updated_params) {
               ^~~~~~~~~~~~~~~~~~~~~~
               updateInternalParams
    -- run_test.py: return code 0
    -- run_test.py: verify result file '/home/lihanchen/Downloads/tmp/build/scorpio_base/test_results/scorpio_base/clang_tidy.xunit.xml'
  >>>
build/scorpio_base/test_results/scorpio_base/clang_tidy.xunit.xml: 14 tests, 0 errors, 9 failures, 0 skipped
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:108:15
  <<< failure message
    ove() as a const reference argument; no move will actually happen [performance-move-const-arg]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:120:12
  <<< failure message
    invalid case style for method 'get_params' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:131:10
  <<< failure message
    invalid case style for method 'try_update_params' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:149:10
  <<< failure message
    invalid case style for method 'try_get_params' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:160:10
  <<< failure message
    invalid case style for method 'is_old' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:165:17
  <<< failure message
    invalid case style for method 'get_stack_params' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:177:10
  <<< failure message
    invalid case style for method 'refresh_dynamic_parameters' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:276:10
  <<< failure message
    invalid case style for method 'declare_params' [readability-identifier-naming]
  >>>
- scorpio_base.clang_tidy /home/lihanchen/Downloads/tmp/build/scorpio_base/include/scorpio_base/scorpio_base_parameters.hpp:439:12
  <<< failure message
    invalid case style for method 'update_internal_params' [readability-identifier-naming]
  >>>

Summary: 23 tests, 0 errors, 10 failures, 0 skipped

Here is my source files:

CMakeLists.txt
package.xml

---
Checks:          '-*,
                  performance-*,
                  -performance-unnecessary-value-param,
                  llvm-namespace-comment,
                  modernize-redundant-void-arg,
                  modernize-use-nullptr,
                  modernize-use-default,
                  modernize-use-override,
                  modernize-loop-convert,
                  modernize-make-shared,
                  modernize-make-unique,
                  misc-unused-parameters,
                  readability-named-parameter,
                  readability-redundant-smartptr-get,
                  readability-redundant-string-cstr,
                  readability-simplify-boolean-expr,
                  readability-container-size-empty,
                  readability-identifier-naming,
                  '
HeaderFilterRegex: ''
CheckOptions:
  - key:             llvm-namespace-comment.ShortNamespaceLines
    value:           '10'
  - key:             llvm-namespace-comment.SpacesBeforeComments
    value:           '2'
  - key:             misc-unused-parameters.StrictMode
    value:           '1'
  - key:             readability-braces-around-statements.ShortStatementLines
    value:           '2'
  # type names
  - key:             readability-identifier-naming.ClassCase
    value:           CamelCase
  - key:             readability-identifier-naming.EnumCase
    value:           CamelCase
  - key:             readability-identifier-naming.UnionCase
    value:           CamelCase
  # method names
  - key:             readability-identifier-naming.MethodCase
    value:           camelBack
  # variable names
  - key:             readability-identifier-naming.VariableCase
    value:           lower_case
  # class member names
  - key:             readability-identifier-naming.PrivateMemberCase
    value:           lower_case
  - key:             readability-identifier-naming.PrivateMemberSuffix
    value:           '_'
  - key:             readability-identifier-naming.ProtectedMemberCase
    value:           lower_case
  - key:             readability-identifier-naming.ProtectedMemberSuffix
    value:           '_'
  # const static or global variables are UPPER_CASE
  - key:             readability-identifier-naming.EnumConstantCase
    value:           UPPER_CASE
  - key:             readability-identifier-naming.StaticConstantCase
    value:           UPPER_CASE
  - key:             readability-identifier-naming.ClassConstantCase
    value:           UPPER_CASE
  - key:             readability-identifier-naming.GlobalVariableCase
    value:           UPPER_CASE
...
Lingua principale
Python
Stelle
385
Fork
81
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PickNikRobotics/generate_parameter_library

Tutte le issue di PickNikRobotics/generate_parameter_library

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.