Skip to content

Commit

Permalink
Various Sonar Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ad3154 committed Nov 5, 2024
1 parent 65a90db commit 33516cd
Show file tree
Hide file tree
Showing 31 changed files with 178 additions and 170 deletions.
12 changes: 6 additions & 6 deletions isobus/include/isobus/isobus/can_extended_transport_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,31 +219,31 @@ namespace isobus
/// @brief Gracefully closes a session to prepare for a new session
/// @param[in] session The session to close
/// @param[in] successful Denotes if the session was successful
void close_session(std::shared_ptr<ExtendedTransportProtocolSession> &session, bool successful);
void close_session(const std::shared_ptr<ExtendedTransportProtocolSession> &session, bool successful);

/// @brief Sends the "request to send" message as part of initiating a transmit
/// @param[in] session The session for which we're sending the RTS
/// @returns true if the RTS was sent, false if sending was not successful
bool send_request_to_send(std::shared_ptr<ExtendedTransportProtocolSession> &session) const;
bool send_request_to_send(const std::shared_ptr<ExtendedTransportProtocolSession> &session) const;

/// @brief Sends the "clear to send" message
/// @param[in] session The session for which we're sending the CTS
/// @returns true if the CTS was sent, false if sending was not successful
bool send_clear_to_send(std::shared_ptr<ExtendedTransportProtocolSession> &session) const;
bool send_clear_to_send(const std::shared_ptr<ExtendedTransportProtocolSession> &session) const;

/// @brief Sends the "data packet offset" message for the provided session
/// @param[in] session The session for which we're sending the DPO
/// @returns true if the DPO was sent, false if sending was not successful
bool send_data_packet_offset(std::shared_ptr<ExtendedTransportProtocolSession> &session) const;
bool send_data_packet_offset(const std::shared_ptr<ExtendedTransportProtocolSession> &session) const;

/// @brief Sends the "end of message acknowledgement" message for the provided session
/// @param[in] session The session for which we're sending the EOM ACK
/// @returns true if the EOM was sent, false if sending was not successful
bool send_end_of_session_acknowledgement(std::shared_ptr<ExtendedTransportProtocolSession> &session) const;
bool send_end_of_session_acknowledgement(const std::shared_ptr<ExtendedTransportProtocolSession> &session) const;

///@brief Sends data transfer packets for the specified ExtendedTransportProtocolSession.
/// @param[in] session The ExtendedTransportProtocolSession for which to send data transfer packets.
void send_data_transfer_packets(std::shared_ptr<ExtendedTransportProtocolSession> &session) const;
void send_data_transfer_packets(const std::shared_ptr<ExtendedTransportProtocolSession> &session) const;

/// @brief Processes a request to send a message over the CAN transport protocol.
/// @param[in] source The shared pointer to the source control function.
Expand Down
10 changes: 5 additions & 5 deletions isobus/include/isobus/isobus/can_network_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace isobus
/// @param[in] CANPort The CAN channel associated with this control function definition
/// @param[in] NAMEFilters A list of filters that describe the identity of the CF based on NAME components
/// @returns A shared pointer to a PartneredControlFunction object created with the parameters passed in
std::shared_ptr<PartneredControlFunction> create_partnered_control_function(std::uint8_t CANPort, const std::vector<NAMEFilter> NAMEFilters);
std::shared_ptr<PartneredControlFunction> create_partnered_control_function(std::uint8_t CANPort, const std::vector<NAMEFilter> &NAMEFilters);

/// @brief Removes an internal control function from the network manager, making it inactive
/// @param[in] controlFunction The control function to deactivate
Expand Down Expand Up @@ -118,7 +118,7 @@ namespace isobus
/// @brief Returns an internal control function if the passed-in control function is an internal type
/// @param[in] controlFunction The control function to get the internal control function from
/// @returns An internal control function casted from the passed in control function
std::shared_ptr<InternalControlFunction> get_internal_control_function(std::shared_ptr<ControlFunction> controlFunction);
std::shared_ptr<InternalControlFunction> get_internal_control_function(std::shared_ptr<ControlFunction> controlFunction) const;

/// @brief Returns an estimated busload between 0.0f and 100.0f
/// @details This calculates busload over a 1 second window.
Expand Down Expand Up @@ -282,7 +282,7 @@ namespace isobus

/// @brief Processes a message for each internal control function for address claiming
/// @param[in] message The message to process
void process_rx_message_for_address_claiming(const CANMessage &message);
void process_rx_message_for_address_claiming(const CANMessage &message) const;

/// @brief Processes a CAN message's contribution to the current busload
/// @param[in] channelIndex The CAN channel index associated to the message being processed
Expand Down Expand Up @@ -349,7 +349,7 @@ namespace isobus

/// @brief Matches a CAN message to any matching PGN callback, and calls that callback
/// @param[in] message A pointer to a CAN message to be processed
void process_can_message_for_global_and_partner_callbacks(const CANMessage &message);
void process_can_message_for_global_and_partner_callbacks(const CANMessage &message) const;

/// @brief Processes the internal received message queue
void process_rx_messages();
Expand Down Expand Up @@ -381,7 +381,7 @@ namespace isobus
/// @brief Gets a PGN callback for the global address by index
/// @param[in] index The index of the callback to get
/// @returns A structure containing the global PGN callback data
ParameterGroupNumberCallbackData get_global_parameter_group_number_callback(std::uint32_t index) const;
ParameterGroupNumberCallbackData get_global_parameter_group_number_callback(std::size_t index) const;

static constexpr std::uint32_t BUSLOAD_SAMPLE_WINDOW_MS = 1000; ///< Using a 1s window to average the bus load, otherwise it's very erratic
static constexpr std::uint32_t BUSLOAD_UPDATE_FREQUENCY_MS = 100; ///< Bus load bit accumulation happens over a 100ms window
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace isobus
/// @brief the constructor for a PartneredControlFunction, which is called by the factory function
/// @param[in] CANPort The CAN channel associated with this control function definition
/// @param[in] NAMEFilters A list of filters that describe the identity of the CF based on NAME components
PartneredControlFunction(std::uint8_t CANPort, const std::vector<NAMEFilter> NAMEFilters);
PartneredControlFunction(std::uint8_t CANPort, const std::vector<NAMEFilter> &NAMEFilters);

/// @brief Deleted copy constructor for PartneredControlFunction to avoid slicing
PartneredControlFunction(PartneredControlFunction &) = delete;
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace isobus
/// @brief Returns the number of NAME filters with a specific NAME parameter component, like manufacturer code
/// @param[in] parameter The NAME parameter to check against
/// @returns The number of NAME filters with a specific NAME parameter component
std::size_t get_number_name_filters_with_parameter_type(NAME::NAMEParameters parameter);
std::size_t get_number_name_filters_with_parameter_type(NAME::NAMEParameters parameter) const;

/// @brief Returns a NAME filter by index
/// @param[in] index The index of the filter to get
Expand Down
12 changes: 6 additions & 6 deletions isobus/include/isobus/isobus/can_transport_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,31 +233,31 @@ namespace isobus
/// @brief Gracefully closes a session to prepare for a new session
/// @param[in] session The session to close
/// @param[in] successful Denotes if the session was successful
void close_session(std::shared_ptr<TransportProtocolSession> &session, bool successful);
void close_session(const std::shared_ptr<TransportProtocolSession> &session, bool successful);

/// @brief Sends the "broadcast announce" message
/// @param[in] session The session for which we're sending the BAM
/// @returns true if the BAM was sent, false if sending was not successful
bool send_broadcast_announce_message(std::shared_ptr<TransportProtocolSession> &session) const;
bool send_broadcast_announce_message(const std::shared_ptr<TransportProtocolSession> &session) const;

/// @brief Sends the "request to send" message as part of initiating a transmit
/// @param[in] session The session for which we're sending the RTS
/// @returns true if the RTS was sent, false if sending was not successful
bool send_request_to_send(std::shared_ptr<TransportProtocolSession> &session) const;
bool send_request_to_send(const std::shared_ptr<TransportProtocolSession> &session) const;

/// @brief Sends the "clear to send" message
/// @param[in] session The session for which we're sending the CTS
/// @returns true if the CTS was sent, false if sending was not successful
bool send_clear_to_send(std::shared_ptr<TransportProtocolSession> &session) const;
bool send_clear_to_send(const std::shared_ptr<TransportProtocolSession> &session) const;

/// @brief Sends the "end of message acknowledgement" message for the provided session
/// @param[in] session The session for which we're sending the EOM ACK
/// @returns true if the EOM was sent, false if sending was not successful
bool send_end_of_session_acknowledgement(std::shared_ptr<TransportProtocolSession> &session) const;
bool send_end_of_session_acknowledgement(const std::shared_ptr<TransportProtocolSession> &session) const;

///@brief Sends data transfer packets for the specified TransportProtocolSession.
/// @param[in] session The TransportProtocolSession for which to send data transfer packets.
void send_data_transfer_packets(std::shared_ptr<TransportProtocolSession> &session);
void send_data_transfer_packets(const std::shared_ptr<TransportProtocolSession> &session);

/// @brief Processes a broadcast announce message.
/// @param[in] source The source control function that sent the broadcast announce message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ namespace isobus

/// @brief Returns The raw bytes that comprise the current localization data as defined in ISO11783-7
/// @returns The raw bytes that comprise the current localization data
const std::array<std::uint8_t, 7> get_localization_raw_data() const;
std::array<std::uint8_t, 7> get_localization_raw_data() const;

/// @brief Parses incoming CAN messages into usable unit and language settings
/// @param message The CAN message to parse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace isobus
/// @brief Alters the settings object to indicate you want to support documentation.
/// @param[in] supported Whether or not the TC supports documentation.
/// @returns An updated settings object.
TaskControllerOptions with_documentation(bool supported = true);
TaskControllerOptions with_documentation(bool supported = true) const;

/// @brief Alters the settings object to indicate you want to support tc-geo without position based control.
/// @param[in] supported Whether or not the TC supports tc-geo without position based control.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace isobus
/// should be relatively quick as it will be called from the CAN stack's thread, and you don't want to delay the stack's update thread.
/// The function should return "true" if the time and date information was successfully populated, and "false" if it was not.
/// Note that if it returns false, the request will probably be NACKed, which is not ideal.
TimeDateInterface(std::shared_ptr<InternalControlFunction> sourceControlFunction, std::function<bool(TimeAndDate &timeAndDateToPopulate)> timeAndDateCallback);
TimeDateInterface(std::shared_ptr<InternalControlFunction> sourceControlFunction, const std::function<bool(TimeAndDate &timeAndDateToPopulate)> &timeAndDateCallback);

/// @brief Destructor for the TimeDateInterface class.
~TimeDateInterface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ namespace isobus
void set_object_pool(std::uint8_t poolIndex,
const std::uint8_t *pool,
std::uint32_t size,
std::string version = "");
const std::string &version = "");

/// @brief Assigns an object pool to the client using a vector.
/// @details This is good for small pools or pools where you have all the data in memory.
Expand All @@ -1232,7 +1232,7 @@ namespace isobus
/// @param[in] version An optional version string. The stack will automatically store/load your pool from the VT if this is provided.
void set_object_pool(std::uint8_t poolIndex,
const std::vector<std::uint8_t> *pool,
std::string version = "");
const std::string &version = "");

/// @brief Configures an object pool to be automatically scaled to match the target VT server
/// @param[in] poolIndex The index of the pool you want to auto-scale
Expand Down Expand Up @@ -1553,7 +1553,7 @@ namespace isobus
/// @param[in] scaleFactor The scale factor to scale the object by
/// @param[in] type The type of the object to resize. Must match the object located at `buffer`
/// @returns true if the object was resized, otherwise false
bool resize_object(std::uint8_t *buffer, float scaleFactor, VirtualTerminalObjectType type);
bool resize_object(std::uint8_t *buffer, float scaleFactor, VirtualTerminalObjectType type) const;

/// @brief Extract from the cache whether a VT does not support a specific function
/// @param[in] function The function to check
Expand Down
Loading

0 comments on commit 33516cd

Please sign in to comment.