Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/display/core/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
}
#endif

void Controller::setupBluetooth() {

Check failure on line 137 in src/display/core/Controller.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 33 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=jniebuhr_gaggimate&issues=AZ51SFxUVwVadeYO6GUB&open=AZ51SFxUVwVadeYO6GUB&pullRequest=721
clientController.initClient();
clientController.registerDisconnectCallback([this]() {
if (initialized) {
Expand All @@ -154,7 +154,7 @@
pluginManager->trigger("pump:flow:change", "value", pumpFlow);
pluginManager->trigger("pump:puck-resistance:change", "value", puckResistance);
});
clientController.registerBtnCallback([this](const int index, const int status) {

Check warning on line 157 in src/display/core/Controller.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This lambda has 32 lines, which is greater than the 20 lines authorized. Split it into several lambdas or functions, or make it a named function.

See more on https://sonarcloud.io/project/issues?id=jniebuhr_gaggimate&issues=AZ51SFxUVwVadeYO6GUC&open=AZ51SFxUVwVadeYO6GUC&pullRequest=721
String behavior = settings.getButtonBehavior(index);
ESP_LOGV("Controller", "Button %d changed to %d, behavior: %s", index, status, behavior);
if (behavior == "" || behavior == "none") {
Expand Down Expand Up @@ -450,6 +450,15 @@
delete process;
return;
}
// A previous process may have finished but not yet been deactivated:
// deactivate() only runs on the next loop() tick (every PROGRESS_INTERVAL),
// so isActive() reports false while currentProcess is still allocated. The
// web/BLE activate() paths run on other cores and can land in this window.
// Deactivate it first (moves it into lastProcess, firing the proper end
// events) so we don't overwrite—and leak—the live currentProcess pointer.
if (currentProcess != nullptr) {
deactivate();
}
processCompleted = false;
this->currentProcess = process;
pluginManager->trigger("controller:process:start");
Expand Down
Loading