Skip to content

C Core Guidelines: Stream Module

Ayush Salunke edited this page Mar 5, 2025 · 22 revisions
  1. csvStreamer.cpp

  • Before Clang-tidy test: before - csvStreamer

  • Guidelines followed:

    • ES: Expressions and statements
      • ES.45: Avoid “magic constants”; use symbolic constants
  • After Clang-tidy test: after - csvStreamer

csvStreamer.h

  • Before CLang-tidy test: image

  • Guidelines followed:

    • C: Classes and class hierarchies
      • C.21: If you define or =delete any copy, move, or destructor function, define or =delete them all. Add default implementations for special member functions to follow the Rule of Five.
      • C.35: A base class destructor should be either public and virtual, or protected and non-virtual. Since CsvStreamer is derived from StreamerInterface, it should have a virtual destructor to ensure proper cleanup of derived class objects when deleted via a base class pointer.
  • After Clang-tidy test: image

  1. lslStreamer.cpp

  • Before Clang-tidy test: before - lslStreamer

  • Guidelines followed:

    • ES: Expressions and statements

      • ES.25: Always initialize an object. Variable 'cf_type' is not initialized
      • ES.45: Avoid “magic constants”; use symbolic constants
      • ES.46: Avoid lossy (narrowing, truncating) arithmetic conversions. Implicit conversions should be made using the variables num_channels, sampling_rate and frame_length.
    • I: Interfaces

      • I.11: Never transfer ownership by a raw pointer (T*) or reference (T&)
  • After Clang-tidy test: after - lslStreamer

lslStreamer.h

  • Before Clang-tidy test: image

  • Guidelines followed:

    • C: Classes and class hierarchies
      • C.21: If you define or =delete any copy, move, or destructor function, define or =delete them all. Add default implementations for special member functions to follow the Rule of Five.
      • C.35: A base class destructor should be either public and virtual, or protected and non-virtual. Since CsvStreamer is derived from StreamerInterface, it should have a virtual destructor to ensure proper cleanup of derived class objects when deleted via a base class pointer.
  • After Clang-tidy test: image

  1. rosStreamer.cpp

  • Before Clang-tidy test: before - rosStreamer

  • Guidelines followed:

    • Pro safety: Type-safety profile
    • ES: Expressions and statements
      • ES.45: Avoid “magic constants”; use symbolic constants. There was a magic number 1000 in pub_buffer, replaced that with a variable.
    • A Missing ROS header file error persists even though the header file exists and is in the correct directory. This error is related to the fact that the library cannot communicate properly with the ROS libraries in the local machine. The error can also be caused by the library requiring an ROS1 interface rather than ROS2.
  • After Clang-tidy test: after - rosStreamer

  1. streamerInterface.cpp

streamerInterface.h

  • Before Clang-tidy test: image

  • Guidelines followed:

    • C: Classes and class hierarchies
      • C.21: If you define or =delete any copy, move, or destructor function, define or =delete them all. Add default implementations for special member functions to follow the Rule of Five.
      • C.35: A base class destructor should be either public and virtual, or protected and non-virtual. Since CsvStreamer is derived from StreamerInterface, it should have a virtual destructor to ensure proper cleanup of derived class objects when deleted via a base class pointer.
  1. yarpStreamer.cpp

Clone this wiki locally