Skip to content

Commit

Permalink
introduce pre-commit (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler authored Nov 25, 2024
1 parent 15090bb commit 73f6c64
Show file tree
Hide file tree
Showing 43 changed files with 55 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/zip_content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ flash.py
monitor.py
README.md
requirements.txt
LICENSE
LICENSE
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sdkconfig
owl_executable
config.txt
*.lock
.venv
.venv
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default_install_hook_types:
- pre-commit
- pre-push

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: double-quote-string-fixer
2 changes: 1 addition & 1 deletion .syncignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ __pycache__/
.DS_Store
*.tmp
.env
.venv
.venv
2 changes: 1 addition & 1 deletion backtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ then
exit
fi

addr2line=~/esp/esp-tools_4.2/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-addr2line
addr2line=~/esp/esp-tools_4.2/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-addr2line
addresses=$@
$addr2line -e build/lizard.elf $addresses
6 changes: 3 additions & 3 deletions examples/ota_example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def ota_binary_verify(request: Request) -> Response:
verify_bin_str = os.path.basename(verify_bin).replace('.bin', '').replace('lizard', '').replace('-', '')
if verify_bin_str is None:
log.push('No "Lizard" binary found. But connection established')
return Response("No Lizard")
if verify_bin_str == "":
return Response('No Lizard')
if verify_bin_str == '':
log.push('Binary without version found')
return Response("Unknown version")
return Response('Unknown version')
response = Response(verify_bin_str)
log.push(f'Send response: {verify_bin_str}')
return response
Expand Down
2 changes: 1 addition & 1 deletion examples/ros/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ do
docker build --tag $name . || exit ;;
r | run)
docker run -it $args $name || exit ;;
s | shell)
s | shell)
docker run -it $args $name /bin/bash || exit ;;
l | log | logs)
docker logs -f --tail 100 $name || exit ;;
Expand Down
2 changes: 1 addition & 1 deletion main/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
parser.h
parser.h
2 changes: 1 addition & 1 deletion main/compilation/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ using Action_ptr = std::shared_ptr<Action>;
class Action {
public:
virtual bool run() = 0;
};
};
2 changes: 1 addition & 1 deletion main/compilation/await_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ AwaitCondition::AwaitCondition(const ConstExpression_ptr condition)

bool AwaitCondition::run() {
return this->condition->evaluate_boolean();
}
}
2 changes: 1 addition & 1 deletion main/compilation/await_condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class AwaitCondition : public Action {

AwaitCondition(const ConstExpression_ptr condition);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/compilation/await_routine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ bool AwaitRoutine::run() {
this->is_waiting = false;
}
return can_proceed;
}
}
2 changes: 1 addition & 1 deletion main/compilation/await_routine.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class AwaitRoutine : public Action {

AwaitRoutine(const Routine_ptr routine);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/compilation/method_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ MethodCall::MethodCall(const Module_ptr module, const std::string method_name, c
bool MethodCall::run() {
this->module->call_with_shadows(this->method_name, this->arguments);
return true;
}
}
2 changes: 1 addition & 1 deletion main/compilation/method_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class MethodCall : public Action {

MethodCall(const Module_ptr module, const std::string method_name, const std::vector<ConstExpression_ptr> arguments);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/compilation/property_assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ PropertyAssignment::PropertyAssignment(const Module_ptr module, const std::strin
bool PropertyAssignment::run() {
this->module->write_property(this->property_name, this->expression);
return true;
}
}
2 changes: 1 addition & 1 deletion main/compilation/property_assignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class PropertyAssignment : public Action {

PropertyAssignment(const Module_ptr module, const std::string property_name, const ConstExpression_ptr expression);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/compilation/routine.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class Routine {
bool is_running() const;
void start();
void step();
};
};
2 changes: 1 addition & 1 deletion main/compilation/routine_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ RoutineCall::RoutineCall(const Routine_ptr routine) : routine(routine) {
bool RoutineCall::run() {
this->routine->start();
return true;
}
}
2 changes: 1 addition & 1 deletion main/compilation/routine_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class RoutineCall : public Action {

RoutineCall(const Routine_ptr routine);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/compilation/rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Rule {
const ConstExpression_ptr condition;
const Routine_ptr routine;
Rule(const ConstExpression_ptr condition, const Routine_ptr routine);
};
};
2 changes: 1 addition & 1 deletion main/compilation/variable_assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ VariableAssignment::VariableAssignment(const Variable_ptr variable, const ConstE
bool VariableAssignment::run() {
this->variable->assign(this->expression);
return true;
}
}
2 changes: 1 addition & 1 deletion main/compilation/variable_assignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class VariableAssignment : public Action {

VariableAssignment(const Variable_ptr variable, const ConstExpression_ptr expression);
bool run() override;
};
};
2 changes: 1 addition & 1 deletion main/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

CXXFLAGS += -std=c++17

COMPONENT_SRCDIRS := . compilation modules utils
COMPONENT_SRCDIRS := . compilation modules utils
2 changes: 1 addition & 1 deletion main/modules/BNO055ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,4 +845,4 @@ void BNO055::stop() {
#ifndef BNO055_DEBUG_OFF
ESP_LOGD(BNO055_LOG_TAG, "Destroyed");
#endif
}
}
2 changes: 1 addition & 1 deletion main/modules/BNO055ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,4 @@ class BNO055 {
void disableInterrupt(uint8_t flag);
};

#endif
#endif
2 changes: 1 addition & 1 deletion main/modules/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ std::string Core::get_output() const {

void Core::keep_alive() {
this->last_message_millis = millis();
}
}
2 changes: 1 addition & 1 deletion main/modules/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class Core : public Module {
void set(std::string property_name, double value);
std::string get_output() const override;
void keep_alive();
};
};
2 changes: 1 addition & 1 deletion main/modules/d1_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class D1Motor : public Module, public std::enable_shared_from_this<D1Motor> {
void profile_position(const int32_t position);
void profile_velocity(const int32_t velocity);
void stop();
};
};
2 changes: 1 addition & 1 deletion main/modules/dunker_motor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ void DunkerMotor::speed(const double speed) {

double DunkerMotor::get_speed() {
return this->properties.at("speed")->number_value;
}
}
2 changes: 1 addition & 1 deletion main/modules/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ class McpInput : public Input {
public:
McpInput(const std::string name, const Mcp23017_ptr mcp, const uint8_t number);
bool get_level() const override;
};
};
2 changes: 1 addition & 1 deletion main/modules/linear_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ class McpLinearMotor : public LinearMotor {
const uint8_t move_out,
const uint8_t end_in,
const uint8_t end_out);
};
};
2 changes: 1 addition & 1 deletion main/modules/odrive_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ class ODriveMotor : public Module, public std::enable_shared_from_this<ODriveMot
void position(const double position, const double speed, const double acceleration) override;
double get_speed() override;
void speed(const double speed, const double acceleration) override;
};
};
2 changes: 1 addition & 1 deletion main/modules/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class McpOutput : public Output {

public:
McpOutput(const std::string name, const Mcp23017_ptr mcp, const uint8_t number);
};
};
2 changes: 1 addition & 1 deletion main/modules/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class Proxy : public Module {
const std::vector<ConstExpression_ptr> arguments);
void call(const std::string method_name, const std::vector<ConstExpression_ptr> arguments) override;
void write_property(const std::string property_name, const ConstExpression_ptr expression, const bool from_expander) override;
};
};
2 changes: 1 addition & 1 deletion main/modules/rmd_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ class RmdMotor : public Module, public std::enable_shared_from_this<RmdMotor> {
double get_position() const;
double get_speed() const;
bool set_acceleration(const uint8_t index, const uint32_t acceleration);
};
};
2 changes: 1 addition & 1 deletion main/modules/roboclaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ class RoboClaw : public Module {
uint32_t Read4(uint8_t cmd, bool *valid);
uint16_t Read2(uint8_t cmd, bool *valid);
uint8_t Read1(uint8_t cmd, bool *valid);
};
};
1 change: 0 additions & 1 deletion main/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8194,4 +8194,3 @@ static void left_right_operand_slots_lookup(uint32_t rule, uint32_t *left, uint3
}
}
#endif

2 changes: 1 addition & 1 deletion main/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class Storage {
static void print_startup(const std::string substring = "");
static void save_startup();
static void clear_nvs();
};
};
2 changes: 1 addition & 1 deletion main/utils/string_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ int csprintf(char *buffer, size_t buffer_len, const char *format, ...) {
throw std::runtime_error("buffer too small");

return num_chars;
}
}
2 changes: 1 addition & 1 deletion main/utils/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ std::string cut_first_word(std::string &msg, char delimiter = ' ');

bool starts_with(const std::string haystack, const std::string needle);

int csprintf(char *buffer, size_t buffer_len, const char *format, ...);
int csprintf(char *buffer, size_t buffer_len, const char *format, ...);
2 changes: 1 addition & 1 deletion main/utils/timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ unsigned long millis_since(const unsigned long time) {

unsigned long micros_since(const unsigned long time) {
return micros() - time;
}
}
2 changes: 1 addition & 1 deletion main/utils/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ unsigned long int micros();
unsigned long int millis();

unsigned long millis_since(const unsigned long time);
unsigned long micros_since(const unsigned long time);
unsigned long micros_since(const unsigned long time);

0 comments on commit 73f6c64

Please sign in to comment.