Apply all clang-tidy fixes
This commit is contained in:
parent
b308a6bfea
commit
dd2f2f8b02
|
@ -59,7 +59,6 @@ cert-err60-cpp,
|
||||||
cert-flp30-c,
|
cert-flp30-c,
|
||||||
cert-msc50-cpp,
|
cert-msc50-cpp,
|
||||||
cert-msc51-cpp,
|
cert-msc51-cpp,
|
||||||
cert-str34-c,
|
|
||||||
cppcoreguidelines-interfaces-global-init,
|
cppcoreguidelines-interfaces-global-init,
|
||||||
cppcoreguidelines-narrowing-conversions,
|
cppcoreguidelines-narrowing-conversions,
|
||||||
cppcoreguidelines-pro-type-member-init,
|
cppcoreguidelines-pro-type-member-init,
|
||||||
|
@ -122,7 +121,6 @@ performance-type-promotion-in-math-fn,
|
||||||
performance-unnecessary-copy-initialization,
|
performance-unnecessary-copy-initialization,
|
||||||
performance-unnecessary-value-param,
|
performance-unnecessary-value-param,
|
||||||
portability-simd-intrinsics,
|
portability-simd-intrinsics,
|
||||||
readability-avoid-const-params-in-decls,
|
|
||||||
readability-const-return-type,
|
readability-const-return-type,
|
||||||
readability-container-size-empty,
|
readability-container-size-empty,
|
||||||
readability-convert-member-functions-to-static,
|
readability-convert-member-functions-to-static,
|
||||||
|
@ -131,7 +129,6 @@ readability-deleted-default,
|
||||||
readability-inconsistent-declaration-parameter-name,
|
readability-inconsistent-declaration-parameter-name,
|
||||||
readability-make-member-function-const,
|
readability-make-member-function-const,
|
||||||
readability-misleading-indentation,
|
readability-misleading-indentation,
|
||||||
readability-misplaced-array-index,
|
|
||||||
readability-non-const-parameter,
|
readability-non-const-parameter,
|
||||||
readability-redundant-control-flow,
|
readability-redundant-control-flow,
|
||||||
readability-redundant-declaration,
|
readability-redundant-declaration,
|
||||||
|
@ -144,4 +141,4 @@ readability-static-accessed-through-instance,
|
||||||
readability-static-definition-in-anonymous-namespace,
|
readability-static-definition-in-anonymous-namespace,
|
||||||
readability-string-compare,
|
readability-string-compare,
|
||||||
readability-uniqueptr-delete-release,
|
readability-uniqueptr-delete-release,
|
||||||
readability-use-anyofallof'
|
readability-use-anyofallof'
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
void drawLogo(U8G2 u8g2, e_logo logo);
|
void drawLogo(U8G2 u8g2, e_logo logo);
|
||||||
void drawStatusText(U8G2 u8g2, String status, String statusRightAligned = "");
|
void drawStatusText(U8G2 u8g2, const String& status, const String& statusRightAligned = "");
|
||||||
|
|
||||||
void updateOLED(U8G2 u8g2, e_state state, String statusText, String statusTextRightAligned = "");
|
void updateOLED(U8G2 u8g2, e_state state, const String& statusText, const String& statusTextRightAligned = "");
|
||||||
void updateOLED(U8G2 u8g2, e_state state);
|
void updateOLED(const U8G2& u8g2, e_state state);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
|
||||||
|
|
||||||
#define NOTE_NONE 0
|
#define NOTE_NONE 0
|
||||||
#define NOTE_B0 31
|
#define NOTE_B0 31
|
||||||
|
@ -90,3 +92,5 @@
|
||||||
#define NOTE_CS8 4435
|
#define NOTE_CS8 4435
|
||||||
#define NOTE_D8 4699
|
#define NOTE_D8 4699
|
||||||
#define NOTE_DS8 4978
|
#define NOTE_DS8 4978
|
||||||
|
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
unsigned long cooldownSecondsRemaining(unsigned long timeout, unsigned long timer);
|
unsigned long cooldownSecondsRemaining(unsigned long timeout, unsigned long timer);
|
||||||
String byteArrayAsHexString(byte *buffer, byte bufferSize);
|
String byteArrayAsHexString(byte *buffer, byte bufferSize);
|
||||||
String uint32AsHexString(uint32_t input);
|
String cardLink(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId);
|
||||||
String cardLink(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId);
|
String cardBalance(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId);
|
||||||
String cardBalance(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId);
|
String cardTransaction(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& amount);
|
||||||
String cardTransaction(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId, String amount);
|
String splitString(const String& data, char separator, int index);
|
||||||
String splitString(String data, char separator, int index);
|
|
||||||
|
|
||||||
enum e_state {
|
enum e_state {
|
||||||
STATE_IDLE,
|
STATE_IDLE,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||||
|
|
||||||
class WiFiClientFixed : public WiFiClient {
|
class WiFiClientFixed : public WiFiClient {
|
||||||
public:
|
public:
|
||||||
void flush() override;
|
void flush() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
|
@ -109,7 +109,7 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFiClass::status() != WL_CONNECTED) {
|
||||||
updateOLED(u8g2, state, "WiFi disconnected :(");
|
updateOLED(u8g2, state, "WiFi disconnected :(");
|
||||||
state = STATE_IDLE;
|
state = STATE_IDLE;
|
||||||
WiFi.reconnect();
|
WiFi.reconnect();
|
||||||
|
|
|
@ -74,7 +74,7 @@ void drawLogo(U8G2 u8g2, e_logo logo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawStatusText(U8G2 u8g2, String status, String statusRightAligned = "") {
|
void drawStatusText(U8G2 u8g2, const String& status, const String& statusRightAligned = "") {
|
||||||
u8g2.setFont(u8g2_font_bpixel_te);
|
u8g2.setFont(u8g2_font_bpixel_te);
|
||||||
u8g2.drawUTF8(0, 61, status.c_str());
|
u8g2.drawUTF8(0, 61, status.c_str());
|
||||||
|
|
||||||
|
@ -84,14 +84,14 @@ void drawStatusText(U8G2 u8g2, String status, String statusRightAligned = "") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawFullScreenText(U8G2 u8g2, String textTop, String textBottom) {
|
void drawFullScreenText(U8G2 u8g2, const String& textTop, const String& textBottom) {
|
||||||
u8g2.setFont(u8g2_font_chargen_92_tr);
|
u8g2.setFont(u8g2_font_chargen_92_tr);
|
||||||
u8g2.drawUTF8((127-u8g2.getUTF8Width(textTop.c_str()))/2, 13, textTop.c_str());
|
u8g2.drawUTF8((127-u8g2.getUTF8Width(textTop.c_str()))/2, 13, textTop.c_str());
|
||||||
u8g2.setFont(u8g2_font_maniac_te);
|
u8g2.setFont(u8g2_font_maniac_te);
|
||||||
u8g2.drawUTF8((127-u8g2.getUTF8Width(textBottom.c_str()))/2, 45, textBottom.c_str());
|
u8g2.drawUTF8((127-u8g2.getUTF8Width(textBottom.c_str()))/2, 45, textBottom.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateOLED(U8G2 u8g2, e_state state, String statusText, String statusTextRightAligned = "") {
|
void updateOLED(U8G2 u8g2, e_state state, const String& statusText, const String& statusTextRightAligned = "") {
|
||||||
u8g2.clearBuffer();
|
u8g2.clearBuffer();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -125,7 +125,7 @@ void updateOLED(U8G2 u8g2, e_state state, String statusText, String statusTextRi
|
||||||
u8g2.sendBuffer();
|
u8g2.sendBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateOLED(U8G2 u8g2, e_state state) {
|
void updateOLED(const U8G2& u8g2, e_state state) {
|
||||||
String time = DateTime.format(DateFormatter::TIME_ONLY);
|
String time = DateTime.format(DateFormatter::TIME_ONLY);
|
||||||
if (!digitalRead(PIN_INTERRUPT_CANCEL) || millis()%20000 < 10000)
|
if (!digitalRead(PIN_INTERRUPT_CANCEL) || millis()%20000 < 10000)
|
||||||
updateOLED(u8g2, state, time, AFRAPAY_REVISION);
|
updateOLED(u8g2, state, time, AFRAPAY_REVISION);
|
||||||
|
|
|
@ -12,10 +12,6 @@ String byteArrayAsHexString(byte *buffer, byte bufferSize) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uint32AsHexString(uint32_t input) {
|
|
||||||
return byteArrayAsHexString(reinterpret_cast<byte *>(&input), sizeof input);
|
|
||||||
}
|
|
||||||
|
|
||||||
String CentsToEuros(long cents){
|
String CentsToEuros(long cents){
|
||||||
char euros[16];
|
char euros[16];
|
||||||
sprintf(euros, "%s%ld,%02ld", cents < 0 ? "-" : "", abs(cents / 100), abs(cents % 100));
|
sprintf(euros, "%s%ld,%02ld", cents < 0 ? "-" : "", abs(cents / 100), abs(cents % 100));
|
||||||
|
@ -33,10 +29,10 @@ String getIdempotencyKey(){
|
||||||
return byteArrayAsHexString(buf, len);
|
return byteArrayAsHexString(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
String splitString(String data, char separator, int index) {
|
String splitString(const String& data, char separator, int index) {
|
||||||
int found = 0;
|
unsigned int maxIndex = data.length() - 1;
|
||||||
int strIndex[] = {0, -1};
|
int strIndex[] = {0, -1};
|
||||||
int maxIndex = data.length() - 1;
|
int found = 0;
|
||||||
|
|
||||||
for (int i = 0; i <= maxIndex && found <= index; i++) {
|
for (int i = 0; i <= maxIndex && found <= index; i++) {
|
||||||
if (data.charAt(i) == separator || i == maxIndex) {
|
if (data.charAt(i) == separator || i == maxIndex) {
|
||||||
|
@ -49,7 +45,7 @@ String splitString(String data, char separator, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String cardLink(WiFiClient *wifi, HTTPClient *http, String apiUrl, String cardId) {
|
String cardLink(WiFiClient *wifi, HTTPClient *http, const String& apiUrl, const String& cardId) {
|
||||||
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/link";
|
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/link";
|
||||||
http->begin(*wifi, finalRequestUrl.c_str());
|
http->begin(*wifi, finalRequestUrl.c_str());
|
||||||
http->addHeader("Content-Type", "application/json");
|
http->addHeader("Content-Type", "application/json");
|
||||||
|
@ -88,7 +84,7 @@ String cardLink(WiFiClient *wifi, HTTPClient *http, String apiUrl, String cardId
|
||||||
return String("E:Internal Error ") + httpResponseCode;
|
return String("E:Internal Error ") + httpResponseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cardBalance(WiFiClient *wifi, HTTPClient *http, String apiUrl, String cardId) {
|
String cardBalance(WiFiClient *wifi, HTTPClient *http, const String& apiUrl, const String& cardId) {
|
||||||
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/balance";
|
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/balance";
|
||||||
http->begin(*wifi, finalRequestUrl.c_str());
|
http->begin(*wifi, finalRequestUrl.c_str());
|
||||||
http->addHeader("Content-Type", "application/json");
|
http->addHeader("Content-Type", "application/json");
|
||||||
|
@ -125,7 +121,7 @@ String cardBalance(WiFiClient *wifi, HTTPClient *http, String apiUrl, String car
|
||||||
return String("E:Internal Error ") + httpResponseCode;
|
return String("E:Internal Error ") + httpResponseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cardTransaction(WiFiClient *wifi, HTTPClient *http, String apiUrl, String cardId, String amount) {
|
String cardTransaction(WiFiClient *wifi, HTTPClient *http, const String& apiUrl, const String& cardId, const String& amount) {
|
||||||
String idempotencyKey = getIdempotencyKey();
|
String idempotencyKey = getIdempotencyKey();
|
||||||
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/transaction/" + idempotencyKey + "?amount=" + amount;
|
String finalRequestUrl = apiUrl + "/api/card/" + cardId + "/transaction/" + idempotencyKey + "?amount=" + amount;
|
||||||
http->begin(*wifi, finalRequestUrl.c_str());
|
http->begin(*wifi, finalRequestUrl.c_str());
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
void WiFiClientFixed::flush() {
|
void WiFiClientFixed::flush() {
|
||||||
int res;
|
int res;
|
||||||
size_t a = available(), toRead = 0;
|
size_t a = available();
|
||||||
if (!a) {
|
if (!a) {
|
||||||
return;//nothing to flush
|
return;//nothing to flush
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue