Apply all clang-tidy fixes

This commit is contained in:
Laura Hausmann 2023-02-10 03:09:50 +01:00
parent b308a6bfea
commit dd2f2f8b02
Signed by: zotan
GPG key ID: D044E84C5BE01605
9 changed files with 28 additions and 28 deletions

View file

@ -59,7 +59,6 @@ cert-err60-cpp,
cert-flp30-c,
cert-msc50-cpp,
cert-msc51-cpp,
cert-str34-c,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-pro-type-member-init,
@ -122,7 +121,6 @@ performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
portability-simd-intrinsics,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
@ -131,7 +129,6 @@ readability-deleted-default,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
@ -144,4 +141,4 @@ readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
readability-use-anyofallof'
readability-use-anyofallof'

View file

@ -5,7 +5,7 @@
#include "utils.h"
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);
void updateOLED(U8G2 u8g2, e_state state, const String& statusText, const String& statusTextRightAligned = "");
void updateOLED(const U8G2& u8g2, e_state state);

View file

@ -1,4 +1,6 @@
#pragma once
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
#define NOTE_NONE 0
#define NOTE_B0 31
@ -90,3 +92,5 @@
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
#pragma clang diagnostic pop

View file

@ -4,11 +4,10 @@
unsigned long cooldownSecondsRemaining(unsigned long timeout, unsigned long timer);
String byteArrayAsHexString(byte *buffer, byte bufferSize);
String uint32AsHexString(uint32_t input);
String cardLink(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId);
String cardBalance(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId);
String cardTransaction(WiFiClient* wifi, HTTPClient* http, String apiUrl, String cardId, String amount);
String splitString(String data, char separator, int index);
String cardLink(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId);
String cardBalance(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId);
String cardTransaction(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& amount);
String splitString(const String& data, char separator, int index);
enum e_state {
STATE_IDLE,

View file

@ -1,6 +1,10 @@
#pragma once
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
class WiFiClientFixed : public WiFiClient {
public:
void flush() override;
};
#pragma clang diagnostic pop

View file

@ -109,7 +109,7 @@ void setup() {
}
void loop() {
if (WiFi.status() != WL_CONNECTED) {
if (WiFiClass::status() != WL_CONNECTED) {
updateOLED(u8g2, state, "WiFi disconnected :(");
state = STATE_IDLE;
WiFi.reconnect();

View file

@ -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.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.drawUTF8((127-u8g2.getUTF8Width(textTop.c_str()))/2, 13, textTop.c_str());
u8g2.setFont(u8g2_font_maniac_te);
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();
switch (state) {
@ -125,7 +125,7 @@ void updateOLED(U8G2 u8g2, e_state state, String statusText, String statusTextRi
u8g2.sendBuffer();
}
void updateOLED(U8G2 u8g2, e_state state) {
void updateOLED(const U8G2& u8g2, e_state state) {
String time = DateTime.format(DateFormatter::TIME_ONLY);
if (!digitalRead(PIN_INTERRUPT_CANCEL) || millis()%20000 < 10000)
updateOLED(u8g2, state, time, AFRAPAY_REVISION);

View file

@ -12,10 +12,6 @@ String byteArrayAsHexString(byte *buffer, byte bufferSize) {
return s;
}
String uint32AsHexString(uint32_t input) {
return byteArrayAsHexString(reinterpret_cast<byte *>(&input), sizeof input);
}
String CentsToEuros(long cents){
char euros[16];
sprintf(euros, "%s%ld,%02ld", cents < 0 ? "-" : "", abs(cents / 100), abs(cents % 100));
@ -33,10 +29,10 @@ String getIdempotencyKey(){
return byteArrayAsHexString(buf, len);
}
String splitString(String data, char separator, int index) {
int found = 0;
String splitString(const String& data, char separator, int index) {
unsigned int maxIndex = data.length() - 1;
int strIndex[] = {0, -1};
int maxIndex = data.length() - 1;
int found = 0;
for (int i = 0; i <= maxIndex && found <= index; i++) {
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";
http->begin(*wifi, finalRequestUrl.c_str());
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;
}
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";
http->begin(*wifi, finalRequestUrl.c_str());
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;
}
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 finalRequestUrl = apiUrl + "/api/card/" + cardId + "/transaction/" + idempotencyKey + "?amount=" + amount;
http->begin(*wifi, finalRequestUrl.c_str());

View file

@ -6,7 +6,7 @@
void WiFiClientFixed::flush() {
int res;
size_t a = available(), toRead = 0;
size_t a = available();
if (!a) {
return;//nothing to flush
}