mirror of https://github.com/commaai/openpilot.git
cpplint: add `readability/braces` filter (#29554)
old-commit-hash: 363740a497
This commit is contained in:
parent
7ecfda8b79
commit
004a097c95
|
@ -64,7 +64,7 @@ repos:
|
|||
- --linelength=240
|
||||
# https://google.github.io/styleguide/cppguide.html
|
||||
# relevant rules are whitelisted, see all options with: cpplint --filter=
|
||||
- --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body
|
||||
- --filter=-build,-legal,-readability,-runtime,-whitespace,+build/forward_decl,+build/deprecated,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+readability/braces
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: test_translations
|
||||
|
|
|
@ -44,7 +44,7 @@ void cloudlog_te(int levelnum, const char* filename, int lineno, const char* fun
|
|||
int __millis = (millis); \
|
||||
uint64_t __ts = nanos_since_boot(); \
|
||||
\
|
||||
if (!__begin) __begin = __ts; \
|
||||
if (!__begin) { __begin = __ts; } \
|
||||
\
|
||||
if (__begin + __millis*1000000ULL < __ts) { \
|
||||
if (__missed) { \
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
#ifndef __APPLE__
|
||||
std::signal(SIGPWR, (sighandler_t)set_do_exit);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
inline static std::atomic<bool> power_failure = false;
|
||||
inline static std::atomic<int> signal = 0;
|
||||
inline operator bool() { return do_exit; }
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// comms base class
|
||||
class PandaCommsHandle {
|
||||
public:
|
||||
PandaCommsHandle(std::string serial) {};
|
||||
virtual ~PandaCommsHandle() {};
|
||||
PandaCommsHandle(std::string serial) {}
|
||||
virtual ~PandaCommsHandle() {}
|
||||
virtual void cleanup() = 0;
|
||||
|
||||
std::string hw_serial;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
LockEx(int fd, std::recursive_mutex &m) : fd(fd), m(m) {
|
||||
m.lock();
|
||||
flock(fd, LOCK_EX);
|
||||
};
|
||||
}
|
||||
|
||||
~LockEx() {
|
||||
flock(fd, LOCK_UN);
|
||||
|
|
|
@ -240,8 +240,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData
|
|||
LOGE("Sensor reading ignored, sensor timestamp more than 100ms off from log time");
|
||||
this->observation_timings_invalid = true;
|
||||
return;
|
||||
}
|
||||
else if (!this->is_timestamp_valid(sensor_time)) {
|
||||
} else if (!this->is_timestamp_valid(sensor_time)) {
|
||||
this->observation_timings_invalid = true;
|
||||
return;
|
||||
}
|
||||
|
@ -258,8 +257,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData
|
|||
if (meas.norm() < ROTATION_SANITY_CHECK) {
|
||||
this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_GYRO, { meas });
|
||||
this->observation_values_invalid["gyroscope"] *= DECAY;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
this->observation_values_invalid["gyroscope"] += 1.0;
|
||||
}
|
||||
}
|
||||
|
@ -277,8 +275,7 @@ void Localizer::handle_sensor(double current_time, const cereal::SensorEventData
|
|||
if (meas.norm() < ACCEL_SANITY_CHECK) {
|
||||
this->kf->predict_and_observe(sensor_time, OBSERVATION_PHONE_ACCEL, { meas });
|
||||
this->observation_values_invalid["accelerometer"] *= DECAY;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
this->observation_values_invalid["accelerometer"] += 1.0;
|
||||
}
|
||||
}
|
||||
|
@ -414,8 +411,7 @@ void Localizer::handle_gnss(double current_time, const cereal::GnssMeasurements:
|
|||
orientation_reset &= !this->standstill;
|
||||
if (orientation_reset) {
|
||||
this->orientation_reset_count++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this->orientation_reset_count = 0;
|
||||
}
|
||||
|
||||
|
@ -649,8 +645,7 @@ void Localizer::determine_gps_mode(double current_time) {
|
|||
if (this->gps_mode){
|
||||
this->gps_mode = false;
|
||||
this->reset_kalman(current_time);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
this->input_fake_gps_observations(current_time);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class NavigationRequest : public QObject {
|
|||
|
||||
public:
|
||||
static NavigationRequest *instance();
|
||||
QJsonArray currentLocations() const { return locations; };
|
||||
QJsonArray currentLocations() const { return locations; }
|
||||
|
||||
signals:
|
||||
void locationsUpdated(const QJsonArray &locations);
|
||||
|
|
|
@ -63,7 +63,7 @@ class TermsPage : public QFrame {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {};
|
||||
explicit TermsPage(QWidget *parent = 0) : QFrame(parent) {}
|
||||
|
||||
public slots:
|
||||
void enableAccept();
|
||||
|
@ -82,7 +82,7 @@ class DeclinePage : public QFrame {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {};
|
||||
explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {}
|
||||
|
||||
private:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
|
|
@ -18,7 +18,7 @@ class OnroadAlerts : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {};
|
||||
OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {}
|
||||
void updateAlert(const Alert &a);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -93,7 +93,7 @@ Spinner::Spinner(QWidget *parent) : QWidget(parent) {
|
|||
|
||||
notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read);
|
||||
QObject::connect(notifier, &QSocketNotifier::activated, this, &Spinner::update);
|
||||
};
|
||||
}
|
||||
|
||||
void Spinner::update(int n) {
|
||||
std::string line;
|
||||
|
|
|
@ -27,7 +27,7 @@ Sound::Sound(QObject *parent) : sm({"controlsState", "microphone"}) {
|
|||
QTimer *timer = new QTimer(this);
|
||||
QObject::connect(timer, &QTimer::timeout, this, &Sound::update);
|
||||
timer->start(1000 / UI_FREQ);
|
||||
};
|
||||
}
|
||||
|
||||
void Sound::update() {
|
||||
sm.update(0);
|
||||
|
|
|
@ -194,7 +194,7 @@ static cam_cmd_power *power_set_wait(cam_cmd_power *power, int16_t delay_ms) {
|
|||
unconditional_wait->delay = delay_ms;
|
||||
unconditional_wait->op_code = CAMERA_SENSOR_WAIT_OP_SW_UCND;
|
||||
return (struct cam_cmd_power *)(unconditional_wait + 1);
|
||||
};
|
||||
}
|
||||
|
||||
int CameraState::sensors_init() {
|
||||
uint32_t cam_packet_handle = 0;
|
||||
|
|
|
@ -37,7 +37,7 @@ std::optional<int32_t> device_acquire(int fd, int32_t session_handle, void *data
|
|||
};
|
||||
int err = do_cam_control(fd, CAM_ACQUIRE_DEV, &cmd, sizeof(cmd));
|
||||
return err == 0 ? std::make_optional(cmd.dev_handle) : std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t packet_handle) {
|
||||
struct cam_config_dev_cmd cmd = {
|
||||
|
|
|
@ -11,10 +11,10 @@ public:
|
|||
static constexpr float MIN_VOLUME = 0.2;
|
||||
|
||||
static std::string get_os_version() { return ""; }
|
||||
static std::string get_name() { return ""; };
|
||||
static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::UNKNOWN; };
|
||||
static int get_voltage() { return 0; };
|
||||
static int get_current() { return 0; };
|
||||
static std::string get_name() { return ""; }
|
||||
static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::UNKNOWN; }
|
||||
static int get_voltage() { return 0; }
|
||||
static int get_current() { return 0; }
|
||||
|
||||
static std::string get_serial() { return "cccccc"; }
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
class HardwarePC : public HardwareNone {
|
||||
public:
|
||||
static std::string get_os_version() { return "openpilot for PC"; }
|
||||
static std::string get_name() { return "pc"; };
|
||||
static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; };
|
||||
static std::string get_name() { return "pc"; }
|
||||
static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; }
|
||||
static bool PC() { return true; }
|
||||
static bool TICI() { return util::getenv("TICI", 0) == 1; }
|
||||
static bool AGNOS() { return util::getenv("TICI", 0) == 1; }
|
||||
|
|
|
@ -15,19 +15,19 @@ public:
|
|||
static bool AGNOS() { return true; }
|
||||
static std::string get_os_version() {
|
||||
return "AGNOS " + util::read_file("/VERSION");
|
||||
};
|
||||
}
|
||||
|
||||
static std::string get_name() {
|
||||
std::string devicetree_model = util::read_file("/sys/firmware/devicetree/base/model");
|
||||
return (devicetree_model.find("tizi") != std::string::npos) ? "tizi" : "tici";
|
||||
};
|
||||
}
|
||||
|
||||
static cereal::InitData::DeviceType get_device_type() {
|
||||
return (get_name() == "tizi") ? cereal::InitData::DeviceType::TIZI : cereal::InitData::DeviceType::TICI;
|
||||
};
|
||||
}
|
||||
|
||||
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); };
|
||||
static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); };
|
||||
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); }
|
||||
static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); }
|
||||
|
||||
static std::string get_serial() {
|
||||
static std::string serial("");
|
||||
|
@ -47,8 +47,8 @@ public:
|
|||
return serial;
|
||||
}
|
||||
|
||||
static void reboot() { std::system("sudo reboot"); };
|
||||
static void poweroff() { std::system("sudo poweroff"); };
|
||||
static void reboot() { std::system("sudo reboot"); }
|
||||
static void poweroff() { std::system("sudo poweroff"); }
|
||||
static void set_brightness(int percent) {
|
||||
std::string max = util::read_file("/sys/class/backlight/panel0-backlight/max_brightness");
|
||||
|
||||
|
@ -57,14 +57,14 @@ public:
|
|||
brightness_control << (int)(percent * (std::stof(max)/100.)) << "\n";
|
||||
brightness_control.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
static void set_display_power(bool on) {
|
||||
std::ofstream bl_power_control("/sys/class/backlight/panel0-backlight/bl_power");
|
||||
if (bl_power_control.is_open()) {
|
||||
bl_power_control << (on ? "0" : "4") << "\n";
|
||||
bl_power_control.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
static void set_volume(float volume) {
|
||||
volume = util::map_val(volume, 0.f, 1.f, MIN_VOLUME, MAX_VOLUME);
|
||||
|
||||
|
@ -99,6 +99,6 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); };
|
||||
static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); };
|
||||
static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); }
|
||||
static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); }
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
class VideoEncoder {
|
||||
public:
|
||||
VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
|
||||
virtual ~VideoEncoder() {};
|
||||
virtual ~VideoEncoder() {}
|
||||
virtual int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) = 0;
|
||||
virtual void encoder_open(const char* path) = 0;
|
||||
virtual void encoder_close() = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@ class Sensor {
|
|||
public:
|
||||
int gpio_fd = -1;
|
||||
uint64_t init_delay = 500e6; // default dealy 500ms
|
||||
virtual ~Sensor() {};
|
||||
virtual ~Sensor() {}
|
||||
virtual int init() = 0;
|
||||
virtual bool get_event(MessageBuilder &msg, uint64_t ts = 0) = 0;
|
||||
virtual bool has_interrupt_enabled() = 0;
|
||||
|
|
|
@ -295,8 +295,7 @@ kj::Array<capnp::word> UbloxMsgParser::parse_glonass_ephemeris(ubx_t::rxm_sfrbx_
|
|||
continue;
|
||||
if (glonass_string_superframes[msg->freq_id()][i] == 0 || gl_string.superframe_number() == 0) {
|
||||
superframe_unknown = true;
|
||||
}
|
||||
else if (glonass_string_superframes[msg->freq_id()][i] != gl_string.superframe_number()) {
|
||||
} else if (glonass_string_superframes[msg->freq_id()][i] != gl_string.superframe_number()) {
|
||||
needs_clear = true;
|
||||
}
|
||||
// Check if string times add up to being from the same frame
|
||||
|
|
|
@ -39,7 +39,7 @@ class AbstractStream : public QObject {
|
|||
|
||||
public:
|
||||
AbstractStream(QObject *parent);
|
||||
virtual ~AbstractStream() {};
|
||||
virtual ~AbstractStream() {}
|
||||
virtual void start() = 0;
|
||||
inline bool liveStreaming() const { return route() == nullptr; }
|
||||
virtual void seekTo(double ts) {}
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
inline void setSpeed(float speed) { speed_ = speed; }
|
||||
inline float getSpeed() const { return speed_; }
|
||||
inline const std::vector<Event *> *events() const { return events_.get(); }
|
||||
inline const std::map<int, std::unique_ptr<Segment>> &segments() const { return segments_; };
|
||||
inline const std::map<int, std::unique_ptr<Segment>> &segments() const { return segments_; }
|
||||
inline const std::string &carFingerprint() const { return car_fingerprint_; }
|
||||
inline const std::vector<std::tuple<double, double, TimelineType>> getTimeline() {
|
||||
std::lock_guard lk(timeline_lock);
|
||||
|
|
Loading…
Reference in New Issue