Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Checks: "-clang-analyzer-unix.Stream,-clang-analyzer-optin.core.EnumCastOutOfRange"
Checks: ""
# -clang-analyzer-unix.Stream
# -clang-analyzer-optin.core.EnumCastOutOfRange
# TODO: google-explicit-constructor / misc-explicit-constructor
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ help:
@echo " clean Clean build directory"
@echo " cmake Configure packages"
@echo " build Build packages"
@echo " pre-commit Run pre-commit"
@echo " pre-commit Run pre-commit (clang-format, ...)"
@echo " test Run tests"
@echo " install Install packages (into INSTALL_PREFIX path)"
@echo " doc Generate documentation (into build directory)"
@echo " doc-dev Generate documentation and start webserver to view it"
@echo " lint Run linter"
@echo " lint Run linters (clang-tidy, ...)"
@echo
@echo "Typically you want to do something like this:"
@echo
Expand Down Expand Up @@ -70,6 +70,7 @@ SED := sed
LN := ln
TEE := tee
RUN_CLANG_TIDY := run-clang-tidy
JQ := jq

ifeq ($(VERBOSE),1)
V =
Expand Down Expand Up @@ -256,15 +257,27 @@ doc-dev: $(BUILD_DIR)/.make-doc

# ----------------------------------------------------------------------------------------------------------------------

.PHONY: pre-commit
pre-commit: | $(BUILD_DIR)
@echo "$(HLW)***** pre-commit checks *****$(HLO)"
$(V)$(MKDIR) -p $(BUILD_DIR)/.bin
$(V)$(LN) -sf /usr/bin/clang-format-17 $(BUILD_DIR)/.bin/clang-format
$(V)export PATH=$(BUILD_DIR)/.bin:$$PATH; pre-commit run --all-files --hook-stage manual || return 1

# ----------------------------------------------------------------------------------------------------------------------

.PHONY: lint
lint: $(BUILD_DIR)/.lint-clang-tidy

$(BUILD_DIR)/.lint-clang-tidy: $(BUILD_DIR)/.make-build
$(BUILD_DIR)/.lint-clang-tidy: $(BUILD_DIR)/.make-cmake .clang-tidy
@echo "$(HLW)***** clang-tidy ($(BUILD_TYPE)) *****$(HLO)"
$(V)$(NICE_BUILD) $(RUN_CLANG_TIDY) -p $(BUILD_DIR) -header-filter=.* -j $(PARALLEL) \
| $(TEE) $(BUILD_DIR)/clang-tidy.log
$(V)$(MKDIR) -p $(BUILD_DIR)/.clang-tidy
$(V)$(JQ) '[ .[] | select(.file | test("/(fpsdk_common/src|fpsdk_apps)/")) ]' < $(BUILD_DIR)/compile_commands.json \
> $(BUILD_DIR)/.clang-tidy/compile_commands.json
$(V)$(NICE_BUILD) $(RUN_CLANG_TIDY) -p $(BUILD_DIR)/.clang-tidy -header-filter=.* -warnings-as-errors="*" -j $(PARALLEL)
$(V)$(TOUCH) $@


# ----------------------------------------------------------------------------------------------------------------------

.PHONY: ci
Expand Down Expand Up @@ -320,13 +333,4 @@ else
@false
endif

# ----------------------------------------------------------------------------------------------------------------------

.PHONY: pre-commit
pre-commit: | $(BUILD_DIR)
@echo "$(HLW)***** pre-commit checks *****$(HLO)"
$(V)$(MKDIR) -p $(BUILD_DIR)/.bin
$(V)$(LN) -sf /usr/bin/clang-format-17 $(BUILD_DIR)/.bin/clang-format
$(V)export PATH=$(BUILD_DIR)/.bin:$$PATH; pre-commit run --all-files --hook-stage manual || return 1

########################################################################################################################
8 changes: 8 additions & 0 deletions docker/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ function pre_commit_check
make pre-commit
}

TITLES["lint_check"]="Linters"
function lint_check
{
cd ${FPSDK_SRC_DIR}
make lint
}

########################################################################################################################

TITLES["build_toplevel_release_noros"]="Build top-level project (release, without ROS)"
Expand Down Expand Up @@ -524,6 +531,7 @@ function doxygen_release_ros2
echo "===== non-ROS builds ====="
if [ "${FPSDK_IMAGE%-*}" = "trixie" ]; then
do_step pre_commit_check || true # continue
do_step lint_check || true # continue
fi
do_step build_toplevel_release_noros || true # continue
do_step test_toplevel_release_noros || true # continue
Expand Down
2 changes: 2 additions & 0 deletions docker/scripts/install_apt_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.lyrical.trixie build-essential
.......humble.jazzy.lyrical.trixie clang
....................lyrical.trixie clang-format
....................lyrical.trixie clang-tools
....................lyrical.trixie clang-tidy
noetic.humble.jazzy.lyrical.trixie cmake
noetic.humble.jazzy.lyrical.trixie curl
............................trixie doxygen
Expand Down
2 changes: 0 additions & 2 deletions docker/scripts/install_apt_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ packages=$(awk -v filt=${FPSDK_IMAGE%-*} '$1 ~ filt { print $2 }' <<EOF
noetic.humble.jazzy.lyrical.trixie can-utils
noetic.humble.jazzy.lyrical.trixie ccache
noetic.humble.jazzy.lyrical.trixie chrpath
....................lyrical.trixie clang-tools
....................lyrical.trixie clang-tidy
....................lyrical.trixie clangd
noetic.humble.jazzy.lyrical.trixie curl
noetic.humble.jazzy.lyrical.trixie dlocate
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_apps/fpltool/fpltool_extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool FplToolExtract::Run()
double rate = 0.0;
bool ok = true;
FplMessage fpl_msg;
bool do_extract = (opts_.skip_ == 0);
bool do_extract = true;
uint32_t time_into_log = 0;
std::size_t errors = 0;
while (!sig_int.ShouldAbort() && fpl_reader.Next(fpl_msg) && ok) {
Expand Down
7 changes: 4 additions & 3 deletions fpsdk_apps/yaml2shell/yaml2shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ class YamlToShell
// Have filter?
if (!opts_.filter_.empty()) {
try {
filter_ = std::make_unique<std::regex>(opts_.filter_,
opts_.filter_ == StrToLower(opts_.filter_) ? std::regex_constants::icase
: (std::regex_constants::syntax_option_type)0);
filter_ = std::make_unique<std::regex>(
opts_.filter_, opts_.filter_ == StrToLower(opts_.filter_)
? std::regex_constants::ECMAScript | std::regex_constants::icase
: std::regex_constants::ECMAScript);
} catch (std::exception& ex) {
WARNING("Bad filter %s: %s", opts_.filter_.c_str(), ex.what());
return false;
Expand Down
6 changes: 3 additions & 3 deletions fpsdk_common/include/fpsdk_common/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SigIntHelper
*
* @param[in] warn Print a WARNING() (true, default) or a DEBUG() (false) on signal
*/
SigIntHelper(const bool warn = true);
explicit SigIntHelper(const bool warn = true);

/**
* @brief Destructor
Expand Down Expand Up @@ -106,7 +106,7 @@ class SigTermHelper
*
* @param[in] warn Print a WARNING() (true, default) or a DEBUG() (false) on signal
*/
SigTermHelper(const bool warn = true);
explicit SigTermHelper(const bool warn = true);

/**
* @brief Destructor
Expand Down Expand Up @@ -144,7 +144,7 @@ class SigPipeHelper
*
* @param[in] warn Print a WARNING() (true) or a DEBUG() (false, default)
*/
SigPipeHelper(const bool warn = false);
explicit SigPipeHelper(const bool warn = false);

/**
* @brief Destructor
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/cam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class CamStream
*
* @param[in] params Parameters
*/
CamStream(const CamStreamParams& params);
explicit CamStream(const CamStreamParams& params);

/**
* @brief Destructor
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/can.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class RawCan : private types::NoCopyNoMove
*
* @param[in] device Device name (e.g. "can0")
*/
RawCan(const std::string& device);
explicit RawCan(const std::string& device);

/**
* @brief Destructor
Expand Down
14 changes: 7 additions & 7 deletions fpsdk_common/include/fpsdk_common/fpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ struct LogMeta
*
* @param[in] log_msg .fpl log message
*/
LogMeta(const FplMessage& log_msg);
explicit LogMeta(const FplMessage& log_msg);
bool valid_ = false; //!< Data valid, successfully extracted from message
std::string info_; //!< Stringification of (some of the) data, for debugging
std::string hw_uid_; //!< Hardware UID
Expand Down Expand Up @@ -296,7 +296,7 @@ struct LogStatus
*
* @param[in] log_msg .fpl log message
*/
LogStatus(const FplMessage& log_msg);
explicit LogStatus(const FplMessage& log_msg);
bool valid_; //!< Data valid, successfully extracted from message

// Version 1 and later
Expand Down Expand Up @@ -343,7 +343,7 @@ struct RosMsgDef
*
* @param[in] log_msg .fpl log message
*/
RosMsgDef(const FplMessage& log_msg);
explicit RosMsgDef(const FplMessage& log_msg);
bool valid_ = false; //!< Data valid, successfully extracted from message
std::string info_; //!< Stringification of (some of the) data, for debugging
std::string topic_name_; //!< The topic name
Expand All @@ -366,7 +366,7 @@ struct RosMsgBin
*
* @param[in] log_msg .fpl log message
*/
RosMsgBin(const FplMessage& log_msg);
explicit RosMsgBin(const FplMessage& log_msg);
bool valid_ = false; //!< Data valid, successfully extracted from message
std::string info_; //!< Stringification of (some of the) data, for debugging
std::string topic_name_; //!< The topic name
Expand All @@ -388,7 +388,7 @@ struct StreamMsg
*
* @param[in] log_msg .fpl log message
*/
StreamMsg(const FplMessage& log_msg);
explicit StreamMsg(const FplMessage& log_msg);
bool valid_ = false; //!< Data valid, successfully extracted from message
std::string info_; //!< Stringification of (some of the) data, for debugging
time::RosTime rec_time_; //!< Recording timestamp
Expand All @@ -408,7 +408,7 @@ struct FileDump
*
* @param[in] log_msg .fpl log message
*/
FileDump(const FplMessage& log_msg);
explicit FileDump(const FplMessage& log_msg);
bool valid_; //!< Data valid, successfully extracted from message
std::string info_; //!< Stringification of (some of the) data, for debugging
std::string filename_; //!< Filename
Expand All @@ -428,7 +428,7 @@ struct CamData : public cam::CamData
*
* @param[in] log_msg .fpl log message
*/
CamData(const FplMessage& log_msg);
explicit CamData(const FplMessage& log_msg);
std::string info_; //!< Stringification of (some of the) data, for debugging
time::RosTime rec_time_; //!< Recording timestamp
};
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/gnss.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ struct Sat
*
* @param[in] str The string ("G03", "R22", "C12", ...)
*/
Sat(const char* str);
explicit Sat(const char* str);

/**
* @brief Get GNSS
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class LoggingOstream
*
* @param[in] level The logging level to use
*/
LoggingOstream(const LoggingLevel level);
explicit LoggingOstream(const LoggingLevel level);

/**
* @brief Get stream handle
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DegMinSec
*
* @param[in] deg Fractional degrees
*/
DegMinSec(const double deg);
explicit DegMinSec(const double deg);
int deg_ = 0; //!< Integer degrees
int min_ = 0; //!< Integer minutes
double sec_ = 0.0; //!< Fractional seconds
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/parser/nmea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct NmeaCoordinates
* @param[in] degs Decimal degrees
* @param[in] digits Number of digits (0-12), param clamped to range
*/
NmeaCoordinates(const double degs, const int digits = 5);
explicit NmeaCoordinates(const double degs, const int digits = 5);

int deg_; //!< Integer degrees value, >= 0
double min_; //!< Fractional minutes value, >= 0.0
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/ros1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace ros1 {
// without needing the mutability of the buffer itself.
struct ConstBuffer
{
ConstBuffer(const std::vector<uint8_t>& buf)
explicit ConstBuffer(const std::vector<uint8_t>& buf)
: data_{ buf.data() }, end_{ buf.data() + static_cast<uint32_t>(buf.size()) }
{
}
Expand Down
4 changes: 2 additions & 2 deletions fpsdk_common/include/fpsdk_common/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct RosTime
*
* @param[in] nsec Time value nanoseconds
*/
RosTime(const uint64_t nsec);
explicit RosTime(const uint64_t nsec);

/**
* @brief Convert to seconds
Expand Down Expand Up @@ -488,7 +488,7 @@ struct WnoTow
*
* @param[in] sys GNSS
*/
WnoTow(const Sys sys = Sys::GPS);
explicit WnoTow(const Sys sys = Sys::GPS);

/**
* @brief Constructor
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/trafo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Transformer : private types::NoCopyNoMove
*
* @param[in] name Optional name, for debugging
*/
Transformer(const std::string& name = "");
explicit Transformer(const std::string& name = "");

~Transformer();

Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CircularBuffer
*
* @param[in] size Size of buffer [bytes]
*/
CircularBuffer(const std::size_t size);
explicit CircularBuffer(const std::size_t size);

/**
* @brief Reset buffer, discard all data
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/include/fpsdk_common/video.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class VideoFrameDecoder
*
* @param[in] params The parameters
*/
VideoFrameDecoder(const VideoDecoderParams& params);
explicit VideoFrameDecoder(const VideoDecoderParams& params);

/**
* @brief Destructor
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/src/cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ CamStream::~CamStream()
class CamStreamImpl : public CamStream, private NoCopyNoMove
{
public:
CamStreamImpl(const CamStreamParams& params);
explicit CamStreamImpl(const CamStreamParams& params);
~CamStreamImpl();
bool Connect() override final;
void Disconnect() override final;
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void LoggingPrint(const LoggingLevel level, const std::size_t repeat, const char
if (len > (sizeof(g_line) - repeat_str_len)) {
len = sizeof(g_line) - repeat_str_len;
}
len += std::snprintf(&g_line[len], sizeof(g_line) - len, " [%" PRIuMAX "x]", repeat);
/*len +=*/std::snprintf(&g_line[len], sizeof(g_line) - len, " [%" PRIuMAX "x]", repeat);
}

g_params.fn_(g_params, level, g_line);
Expand Down
2 changes: 1 addition & 1 deletion fpsdk_common/src/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ std::optional<ImageData> VideoFrameDecoder::DecodeFrame(const std::vector<uint8_
class VideoFrameDecoderImpl : public VideoFrameDecoder, private NoCopyNoMove
{
public:
VideoFrameDecoderImpl(const VideoDecoderParams& params);
explicit VideoFrameDecoderImpl(const VideoDecoderParams& params);
~VideoFrameDecoderImpl();
std::optional<ImageData> DecodeFrame(const uint8_t* data, const std::size_t size) override final;
bool IsOkay() const override final;
Expand Down
Loading