Giter Site home page Giter Site logo

clang-tidy warning about async_mqtt HOT 5 CLOSED

Meisterian avatar Meisterian commented on July 30, 2024
clang-tidy warning

from async_mqtt.

Comments (5)

Meisterian avatar Meisterian commented on July 30, 2024 1

I am not familiar with GitHub CI, but it is not that hard to run clang-tidy. It can be configured with a lot of checks, but then someone have to work in months to fix all warnings. I was experimenting a little with this repository to see what checks that could be a good start and came up with this:
cmake -Bbuild -H. -DCMAKE_CXX_COMPILER=clang++-15 -DASYNC_MQTT_USE_TLS=ON -DASYNC_MQTT_USE_WS=ON -DASYNC_MQTT_USE_STR_CHECK=ON -DASYNC_MQTT_USE_LOG=ON -DASYNC_MQTT_PRINT_PAYLOAD=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DASYNC_MQTT_BUILD_UNIT_TESTS=ON -DASYNC_MQTT_BUILD_SYSTEM_TESTS=ON -DASYNC_MQTT_BUILD_TOOLS=ON -DASYNC_MQTT_BUILD_EXAMPLES=ON
run-clang-tidy-15 -p build -checks='clang-analyzer-*,concurrency-*,portability-*' -header-filter=.include > clang-tidy.txt

That gives a lot of warnings, but almost everything ends at the same function:
/tmp/async_mqtt/include/async_mqtt/util/scope_guard.hpp:18:5: note: Address of stack memory associated with local variable 'deleter' is still referred to by the stack variable 'guard' upon returning to the caller. This will be a dangling reference
return std::unique_ptr<void, decltype(deleter)>(&deleter, force_move(deleter));

It also found the bug mentioned in this issue.

from async_mqtt.

redboltz avatar redboltz commented on July 30, 2024 1

Thank you for giving the information. It helps introducing clang-tidy to async_mqtt. I will try it later :)

from async_mqtt.

redboltz avatar redboltz commented on July 30, 2024 1

I ran run-clang-tify on my local environment. It seems that it is too heavy to run on CI.
I've fixed all clang-tidy warnings under include/async_mqtt directory.
Other warnings are intentional static_assert() error as expected in the test code and some tools force exit. It is not related to users.

from async_mqtt.

redboltz avatar redboltz commented on July 30, 2024

Thanks you for reporting the issue. You are right. It shoul be fixed. I just create a pull request to fix it #144
BTW, CI doesn't report the warning (as error), so far.
In CI https://github.com/redboltz/async_mqtt/blob/4c022b7e9c650a9f0b1673fb483151affb1f577d/.github/workflows/gha.yml
I use clang++ but not use clang-tidy.
I don't have much about clang-tidy but it seems to useful to find this kinds of issue. If you create a PR to add clang-tify on CI. I would appreciate.

from async_mqtt.

Meisterian avatar Meisterian commented on July 30, 2024

That is great!
If you want, I can do a pull request (not today), where we include clang-tidy as an optional choice that can be activated when choosing clang as a compiler.
Is it too heavy for the CI, so that it fails, or do you think that the build time have increased too much?
Anyway, if it is added to the cmake structure, it will only use the number of threads you specify. Then it can probably be run, if it failed on CI.

from async_mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.