Skip to content

[CODE HEALTH] Fix clang tidy warnings in API common and context#3948

Merged
marcalff merged 8 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_warnings_in_common_and_context
Mar 20, 2026
Merged

[CODE HEALTH] Fix clang tidy warnings in API common and context#3948
marcalff merged 8 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_warnings_in_common_and_context

Conversation

@dbarker
Copy link
Member

@dbarker dbarker commented Mar 20, 2026

Contributes to #2053

Changes

  • Disables the portability-template-virtual-member-function check (gcc, clang, and msvc builds are tested in ci)
  • Fixes the following warnings:

opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable.h (2 warnings)

Line Check Message
17 cppcoreguidelines-special-member-functions class 'KeyValueIterable' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
40 cppcoreguidelines-special-member-functions class 'NoopKeyValueIterable' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator

opentelemetry-cpp/api/include/opentelemetry/common/key_value_iterable_view.h (3 warnings)

Line Check Message
64 portability-template-virtual-member-function unspecified virtual member function instantiation; the virtual member function is not instantiated but it might be with a different compiler
79 portability-template-virtual-member-function unspecified virtual member function instantiation; the virtual member function is not instantiated but it might be with a different compiler
127 bugprone-return-const-ref-from-parameter returning a constant reference parameter may cause use-after-free when the parameter is constructed from a temporary

opentelemetry-cpp/api/include/opentelemetry/common/kv_properties.h (3 warnings)

Line Check Message
132 cppcoreguidelines-use-default-member-init use default member initializer for 'index_'
140 cppcoreguidelines-special-member-functions class 'Entry' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
153 cppcoreguidelines-c-copy-assignment-signature,misc-unconventional-assign-operator operator=() should take 'Entry const&', 'Entry&&' or 'Entry'

opentelemetry-cpp/api/include/opentelemetry/common/spin_lock_mutex.h (1 warnings)

Line Check Message
52 cppcoreguidelines-special-member-functions class 'SpinLockMutex' defines a default destructor, a copy constructor and a copy assignment operator but does not define a move constructor or a move assignment operator

opentelemetry-cpp/api/include/opentelemetry/context/context.h (4 warnings)

Line Check Message
93 cppcoreguidelines-special-member-functions class 'DataList' defines a non-default destructor, a copy constructor and a move assignment operator but does not define a copy assignment operator or a move constructor
130 cppcoreguidelines-prefer-member-initializer 'key_' should be initialized in a member initializer of the constructor
131 cppcoreguidelines-prefer-member-initializer 'key_length_' should be initialized in a member initializer of the constructor
134 cppcoreguidelines-prefer-member-initializer 'value_' should be initialized in a member initializer of the constructor

opentelemetry-cpp/api/include/opentelemetry/context/propagation/text_map_propagator.h (2 warnings)

Line Check Message
18 cppcoreguidelines-special-member-functions class 'TextMapCarrier' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
42 cppcoreguidelines-special-member-functions class 'TextMapPropagator' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator

opentelemetry-cpp/api/include/opentelemetry/context/runtime_context.h (7 warnings)

Line Check Message
24 cppcoreguidelines-special-member-functions class 'Token' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
38 cppcoreguidelines-avoid-const-or-ref-data-members member 'context_' of type 'const Context' is const qualified
48 cppcoreguidelines-special-member-functions class 'RuntimeContextStorage' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
240 cppcoreguidelines-special-member-functions class 'Stack' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
362 cppcoreguidelines-use-default-member-init use default member initializer for 'size_'
363 cppcoreguidelines-use-default-member-init use default member initializer for 'capacity_'
364 cppcoreguidelines-use-default-member-init use default member initializer for 'base_'

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.09%. Comparing base (06f6086) to head (ee3dafe).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3948      +/-   ##
==========================================
+ Coverage   90.09%   90.09%   +0.01%     
==========================================
  Files         227      227              
  Lines        7250     7251       +1     
==========================================
+ Hits         6531     6532       +1     
  Misses        719      719              
Files with missing lines Coverage Δ
.../include/opentelemetry/common/key_value_iterable.h 100.00% <100.00%> (ø)
...ude/opentelemetry/common/key_value_iterable_view.h 100.00% <ø> (ø)
api/include/opentelemetry/common/kv_properties.h 98.87% <100.00%> (ø)
api/include/opentelemetry/common/spin_lock_mutex.h 100.00% <ø> (ø)
api/include/opentelemetry/context/context.h 100.00% <100.00%> (ø)
...elemetry/context/propagation/text_map_propagator.h 66.67% <100.00%> (+16.67%) ⬆️
...pi/include/opentelemetry/context/runtime_context.h 92.14% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbarker dbarker marked this pull request as ready for review March 20, 2026 18:29
@dbarker dbarker requested a review from a team as a code owner March 20, 2026 18:29
Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix.

@marcalff marcalff merged commit ebdb633 into open-telemetry:main Mar 20, 2026
68 checks passed
@dbarker dbarker deleted the fix_clang_tidy_warnings_in_common_and_context branch March 20, 2026 21:24
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.

2 participants