Skip to content

[CODE HEALTH] Fix more clang-tidy warnings in api#3950

Open
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_warnings_in_api
Open

[CODE HEALTH] Fix more clang-tidy warnings in api#3950
dbarker wants to merge 2 commits intoopen-telemetry:mainfrom
dbarker:fix_clang_tidy_warnings_in_api

Conversation

@dbarker
Copy link
Member

@dbarker dbarker commented Mar 23, 2026

Contributes to #2053

Changes

Fixes the following warnings:


opentelemetry-cpp/api/include/opentelemetry/logs/event_logger.h (1 warnings)

Line Check Message
22 cppcoreguidelines-special-member-functions class 'EventLogger' 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/logs/event_logger_provider.h (1 warnings)

Line Check Message
22 cppcoreguidelines-special-member-functions class 'EventLoggerProvider' 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/logs/log_record.h (1 warnings)

Line Check Message
28 cppcoreguidelines-special-member-functions class 'LogRecord' 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/logs/logger.h (1 warnings)

Line Check Message
27 cppcoreguidelines-special-member-functions class 'Logger' 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/logs/logger_provider.h (1 warnings)

Line Check Message
23 cppcoreguidelines-special-member-functions class 'LoggerProvider' 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/logs/logger_type_traits.h (4 warnings)

Line Check Message
48 cppcoreguidelines-missing-std-forward forwarding reference parameter 'arg' is never forwarded inside the function body
60 cppcoreguidelines-missing-std-forward forwarding reference parameter 'arg' is never forwarded inside the function body
134 cppcoreguidelines-missing-std-forward forwarding reference parameter 'arg' is never forwarded inside the function body
176 cppcoreguidelines-missing-std-forward forwarding reference parameter 'arg' is never forwarded inside the function body

opentelemetry-cpp/api/include/opentelemetry/logs/noop.h (5 warnings)

Line Check Message
49 cppcoreguidelines-rvalue-reference-param-not-moved rvalue reference parameter '' is never moved from inside the function body
52 cppcoreguidelines-special-member-functions class 'NoopLogRecord' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
98 cppcoreguidelines-special-member-functions class 'NoopEventLogger' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator
108 cppcoreguidelines-rvalue-reference-param-not-moved rvalue reference parameter '' is never moved from inside the function body
118 cppcoreguidelines-special-member-functions class 'NoopEventLoggerProvider' 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/metrics/async_instruments.h (1 warnings)

Line Check Message
15 cppcoreguidelines-special-member-functions class 'ObservableInstrument' 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/metrics/meter.h (1 warnings)

Line Check Message
42 cppcoreguidelines-special-member-functions class 'Meter' 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/metrics/meter_provider.h (1 warnings)

Line Check Message
22 cppcoreguidelines-special-member-functions class 'MeterProvider' 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/metrics/multi_observer_result.h (1 warnings)

Line Check Message
16 cppcoreguidelines-special-member-functions class 'MultiObserverResult' 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/metrics/noop.h (1 warnings)

Line Check Message
57 cppcoreguidelines-special-member-functions class 'NoopUpDownCounter' 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/metrics/observer_result.h (1 warnings)

Line Check Message
24 cppcoreguidelines-special-member-functions class 'ObserverResultT' 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/metrics/sync_instruments.h (1 warnings)

Line Check Message
18 cppcoreguidelines-special-member-functions class 'SynchronousInstrument' 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/plugin/detail/dynamic_library_handle.h (1 warnings)

Line Check Message
14 cppcoreguidelines-special-member-functions class 'DynamicLibraryHandle' 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/plugin/detail/dynamic_load_unix.h (1 warnings)

Line Check Message
20 cppcoreguidelines-special-member-functions class 'DynamicLibraryHandleUnix' defines a non-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/plugin/detail/tracer_handle.h (1 warnings)

Line Check Message
19 cppcoreguidelines-special-member-functions class 'TracerHandle' 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/plugin/factory.h (1 warnings)

Line Check Message
22 cppcoreguidelines-special-member-functions class 'FactoryImpl' defines a non-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/trace/propagation/detail/hex.h (3 warnings)

Line Check Message
39 google-readability-casting C-style casts are discouraged; use static_cast
60 google-readability-casting C-style casts are discouraged; use static_cast
61 google-readability-casting C-style casts are discouraged; use static_cast

opentelemetry-cpp/api/test/nostd/shared_ptr_test.cc (1 warnings)

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

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 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.07%. Comparing base (2a6062b) to head (ebc56ed).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3950      +/-   ##
==========================================
+ Coverage   90.07%   90.07%   +0.01%     
==========================================
  Files         227      227              
  Lines        7247     7258      +11     
==========================================
+ Hits         6527     6537      +10     
- Misses        720      721       +1     
Files with missing lines Coverage Δ
api/include/opentelemetry/logs/event_logger.h 91.67% <100.00%> (+1.67%) ⬆️
...include/opentelemetry/logs/event_logger_provider.h 100.00% <100.00%> (ø)
api/include/opentelemetry/logs/log_record.h 100.00% <100.00%> (ø)
api/include/opentelemetry/logs/logger.h 64.87% <100.00%> (+2.01%) ⬆️
api/include/opentelemetry/logs/logger_provider.h 100.00% <100.00%> (ø)
...pi/include/opentelemetry/logs/logger_type_traits.h 100.00% <100.00%> (ø)
api/include/opentelemetry/logs/noop.h 76.93% <100.00%> (-2.38%) ⬇️
.../include/opentelemetry/metrics/async_instruments.h 100.00% <100.00%> (ø)
api/include/opentelemetry/metrics/meter.h 100.00% <100.00%> (ø)
api/include/opentelemetry/metrics/meter_provider.h 100.00% <100.00%> (ø)
... and 9 more

... and 1 file with indirect coverage changes

🚀 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 23, 2026 19:55
@dbarker dbarker requested a review from a team as a code owner March 23, 2026 19:55
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, see some questions about possible memory leak.

Comment on lines +49 to +50
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
void EmitLogRecord(nostd::unique_ptr<LogRecord> && /* log_record */) noexcept override {}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of suppression for the warning, how about:

  • move the parameter into a local variable
  • let the local variable destructor reclaim memory for the log record

Please check if there is an existing unit test covering this, or create one if needed, and try running it under valgrind.
I suspect there is an existing memory leak here.

Comment on lines +105 to +108
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
void EmitEvent(nostd::string_view,
nostd::unique_ptr<LogRecord> && /* log_record */) noexcept override
{}
Copy link
Member

Choose a reason for hiding this comment

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

Same concern as NoopLogger, possible memory leak.

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