Skip to content

Commit

Permalink
add cpplint for cyphal
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Apr 2, 2024
1 parent afbbf0e commit b2314b8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: code_style

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
cpplint:
timeout-minutes: 1
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: pip3 install cpplint
- name: cpplint cyphal
run: |
cpplint Src/cyphal_application/*pp Src/cyphal_application/modules/*/*pp
27 changes: 27 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# CPPLINT.cfg

# Stop searching for additional config files.
set noparent

# Increase limit line length because 80 it's not enough
linelength=100

# Actually, it's a good requirement, it's better to fix it soon
filter=-build/header_guard

# Ignore requirement to include "foo/bar.h" instead of just "bar.h"
filter=-build/include_subdir

# Ignore requirement to use copyright
filter=-legal/copyright

# Ignore too much complications with spaces
filter=-whitespace/braces
filter=-whitespace/parens
filter=-whitespace/indent

# This this is not C++, C-style cast is the only way to perform cast
filter=-readability/casting
filter=-build/include_what_you_use

filter=-runtime/arrays
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=RaccoonlabDev_mini_v2_node&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=RaccoonlabDev_mini_v2_node) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=RaccoonlabDev_mini_v2_node&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=RaccoonlabDev_mini_v2_node) [![cyphal](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/cyphal.yml/badge.svg)](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/cyphal.yml) [![dronecan](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/dronecan.yml/badge.svg)](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/dronecan.yml)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=RaccoonlabDev_mini_v2_node&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=RaccoonlabDev_mini_v2_node) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=RaccoonlabDev_mini_v2_node&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=RaccoonlabDev_mini_v2_node) [![cyphal](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/cyphal.yml/badge.svg)](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/cyphal.yml) [![dronecan](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/dronecan.yml/badge.svg)](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/dronecan.yml) [![dronecan](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/code_style.yml/badge.svg)](https://github.com/RaccoonlabDev/mini_v2_node/actions/workflows/code_style.yml)

# Mini v2 Cyphal/DroneCAN application template

Expand Down
2 changes: 1 addition & 1 deletion Src/cyphal_application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "periphery/iwdg/iwdg.hpp"

void init_persistent_storage() {
paramsInit(static_cast<uint8_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT), NUM_OF_STR_PARAMS, -1, 1);
paramsInit((ParamIndex_t)IntParamsIndexes::INTEGER_PARAMS_AMOUNT, NUM_OF_STR_PARAMS, -1, 1);
paramsLoad();

auto node_name_param_idx = static_cast<ParamIndex_t>(IntParamsIndexes::INTEGER_PARAMS_AMOUNT);
Expand Down
8 changes: 4 additions & 4 deletions Src/cyphal_application/modules/feedback/feedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void FeedbackPublisher::publish_msg(uint32_t crnt_time_ms) {
setPortId(paramsGetIntegerValue(PARAM_PUB_FEEDBACK_1_ID));

uint8_t buffer[reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_];
size_t buffer_size = reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_;
int32_t result = reg_udral_service_actuator_common_Feedback_0_1_serialize_(&msg, buffer, &buffer_size);
if (NUNAVUT_SUCCESS == result) {
push(buffer_size, buffer);
size_t size = reg_udral_service_actuator_common_Feedback_0_1_EXTENT_BYTES_;
int32_t res = reg_udral_service_actuator_common_Feedback_0_1_serialize_(&msg, buffer, &size);
if (NUNAVUT_SUCCESS == res) {
push(size, buffer);
}
}
2 changes: 1 addition & 1 deletion Src/cyphal_application/modules/feedback/feedback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {

class FeedbackPublisher: public cyphal::CyphalPublisher {
public:
explicit FeedbackPublisher(cyphal::Cyphal* driver_) : CyphalPublisher(driver_, 0) {};
explicit FeedbackPublisher(cyphal::Cyphal* driver_) : CyphalPublisher(driver_, 0) {}
int8_t init();
void process(uint32_t crnt_time_ms);
void publish_msg(uint32_t crnt_time_ms);
Expand Down
6 changes: 3 additions & 3 deletions Src/cyphal_application/modules/setpoint/setpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

SetpointSubscriber::SetpointSubscriber(cyphal::Cyphal* driver_) :
CyphalSubscriber(driver_, 0) {
};
}

int8_t SetpointSubscriber::init() {
PwmPeriphery::init(PwmPin::PWM_1);
Expand All @@ -33,9 +33,9 @@ int8_t SetpointSubscriber::init() {

void SetpointSubscriber::callback(const cyphal::CanardRxTransfer& transfer) {
auto payload = static_cast<const uint8_t*>(transfer.payload);
size_t payload_len = transfer.payload_size;
size_t len = transfer.payload_size;
reg_udral_service_actuator_common_sp_Vector31_0_1 msg;
if (reg_udral_service_actuator_common_sp_Vector31_0_1_deserialize_(&msg, payload, &payload_len) < 0) {
if (reg_udral_service_actuator_common_sp_Vector31_0_1_deserialize_(&msg, payload, &len) < 0) {
return;
}

Expand Down

0 comments on commit b2314b8

Please sign in to comment.