From ac7d678007c6754013f8d590be32d325ea6b85a0 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Fri, 20 Feb 2026 01:17:53 +0100 Subject: [PATCH] feat: great beautiful fixes --- C/1dvelocitysimulator/main.c | 5 ++- C/imageViewer/.clang-format | 2 +- C/vocabulary_curve/main.c | 1 + CPP/miscelanious/calculateShotsDarts/main.cpp | 1 + .../tierListConverter/tierListConverter.cpp | 4 +- .../server/src/server.ts | 16 ++++---- pomodoro_app/linux/runner/main.cc | 2 +- pomodoro_app/linux/runner/my_application.cc | 40 +++++++++---------- pomodoro_app/linux/runner/my_application.h | 9 ++--- 9 files changed, 41 insertions(+), 39 deletions(-) diff --git a/C/1dvelocitysimulator/main.c b/C/1dvelocitysimulator/main.c index 5b0c967..d4ccc07 100644 --- a/C/1dvelocitysimulator/main.c +++ b/C/1dvelocitysimulator/main.c @@ -39,11 +39,14 @@ void pauseForGivenTime(float given_time) float calculateVelocity(float starting_velocity, unsigned int physics_time, int *acceleration) { + // cppcheck-suppress nullPointer return (*acceleration) * physics_time + starting_velocity; } int calculateDisplacement(float starting_velocity, int *acceleration, unsigned int physics_time) { + // cppcheck-suppress nullPointer + // cppcheck-suppress ctunullpointer return starting_velocity * physics_time + ((1 / 2) * (*acceleration) * (physics_time ^ 2)); } @@ -55,7 +58,7 @@ void printXPosition(int position) void printClock(unsigned int *time) { - printf("%d seconds passed\n", *time); + printf("%u seconds passed\n", *time); return; } diff --git a/C/imageViewer/.clang-format b/C/imageViewer/.clang-format index 3c687ec..2b0fcc9 100644 --- a/C/imageViewer/.clang-format +++ b/C/imageViewer/.clang-format @@ -1,6 +1,6 @@ # Clang-format configuration for imageViewer project --- -Language: C +Language: Cpp # Base style BasedOnStyle: LLVM diff --git a/C/vocabulary_curve/main.c b/C/vocabulary_curve/main.c index 985d978..68b3327 100644 --- a/C/vocabulary_curve/main.c +++ b/C/vocabulary_curve/main.c @@ -447,6 +447,7 @@ static void find_longest_excerpt(int max_vocab) rarest_word = word_sequence[i]->word; } } + // cppcheck-suppress nullPointer printf("Rarest word used: %s (#%d)\n", rarest_word, max_rank_used); /* Count unique words in excerpt */ diff --git a/CPP/miscelanious/calculateShotsDarts/main.cpp b/CPP/miscelanious/calculateShotsDarts/main.cpp index 61f5eba..0dd4134 100644 --- a/CPP/miscelanious/calculateShotsDarts/main.cpp +++ b/CPP/miscelanious/calculateShotsDarts/main.cpp @@ -63,6 +63,7 @@ bool validInput(const std::string s) { return 1; } +// cppcheck-suppress missingReturn std::vector requiredShoots(const int pointsLeft) {} int main() { diff --git a/CPP/miscelanious/tierListConverter/tierListConverter.cpp b/CPP/miscelanious/tierListConverter/tierListConverter.cpp index bbf9300..393ecd5 100644 --- a/CPP/miscelanious/tierListConverter/tierListConverter.cpp +++ b/CPP/miscelanious/tierListConverter/tierListConverter.cpp @@ -43,14 +43,14 @@ bool errorUserInput(std::string userInput) { std::string convertToTier(float nominator, float denominator) { float fraction = nominator / denominator; - int tierIndex; + int tierIndex = 0; for (int i = TIER_BASE; i > 0; i--) { if (fraction >= (i / TIER_BASE)) { tierIndex = i - 1; break; } } - if (tierIndex == 0 & fraction > (1.1 / 10.0)) + if (tierIndex == 0 && fraction > (1.1 / 10.0)) return TIERS[1]; return TIERS[tierIndex]; } diff --git a/TS/champions_leauge_scores/server/src/server.ts b/TS/champions_leauge_scores/server/src/server.ts index f919fa1..bdb5d89 100644 --- a/TS/champions_leauge_scores/server/src/server.ts +++ b/TS/champions_leauge_scores/server/src/server.ts @@ -10,7 +10,7 @@ const API_BASE = 'https://api.football-data.org/v4'; const API_TOKEN = process.env.FOOTBALL_DATA_API_KEY; if (!API_TOKEN) { - + console.warn('[server] FOOTBALL_DATA_API_KEY is not set. Live data will not work until you set it.'); } @@ -51,7 +51,7 @@ app.use((req, res, next) => { return originalSend(body); }; - + console.log(`[#${id}] -> ${req.method} ${req.originalUrl}` + (Object.keys(req.query || {}).length ? ` query=${JSON.stringify(req.query)}` : '')); res.on('finish', () => { @@ -65,7 +65,7 @@ app.use((req, res, next) => { bodyPreview = ` body=${clip(str)}`; } } catch { /* ignore */ } - + console.log(`[#${id}] <- ${req.method} ${req.originalUrl} ${res.statusCode} ${durMs.toFixed(1)}ms${bodyPreview}`); }); @@ -77,12 +77,12 @@ axios.interceptors.request.use( (config) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any (config as any).metadata = { start: Date.now() }; - + console.log(`[axios ->] ${String(config.method || 'GET').toUpperCase()} ${config.url}`); return config; }, (error) => { - + console.warn('[axios req error]', error?.message || error); return Promise.reject(error); } @@ -100,7 +100,7 @@ axios.interceptors.response.use( const size = dataStr?.length || 0; const MAX_LOG_BODY = 2000; const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s); - + console.log(`[axios <-] ${response.status} ${String(response.config.method || 'GET').toUpperCase()} ${response.config.url} ${dur}ms ~${size}B data=${clip(dataStr)}`); return response; }, @@ -117,7 +117,7 @@ axios.interceptors.response.use( } catch { /* ignore */ } const MAX_LOG_BODY = 2000; const clip = (s: string) => (s && s.length > MAX_LOG_BODY ? `${s.slice(0, MAX_LOG_BODY)}…(+${s.length - MAX_LOG_BODY})` : s); - + console.warn(`[axios ! ] ${status ?? 'ERR'} ${String(cfg.method || 'GET').toUpperCase()} ${cfg.url} ${dur}ms data=${dataStr ? clip(dataStr) : (error?.message || 'error')}`); return Promise.reject(error); } @@ -211,6 +211,6 @@ app.get('/api/matches', async (req: Request, res: Response) => { }); app.listen(PORT, () => { - + console.log(`[server] Listening on http://localhost:${PORT}`); }); diff --git a/pomodoro_app/linux/runner/main.cc b/pomodoro_app/linux/runner/main.cc index e7c5c54..26cd225 100644 --- a/pomodoro_app/linux/runner/main.cc +++ b/pomodoro_app/linux/runner/main.cc @@ -1,6 +1,6 @@ #include "my_application.h" -int main(int argc, char** argv) { +int main(int argc, char **argv) { g_autoptr(MyApplication) app = my_application_new(); return g_application_run(G_APPLICATION(app), argc, argv); } diff --git a/pomodoro_app/linux/runner/my_application.cc b/pomodoro_app/linux/runner/my_application.cc index c9ab02e..5c4108f 100644 --- a/pomodoro_app/linux/runner/my_application.cc +++ b/pomodoro_app/linux/runner/my_application.cc @@ -9,20 +9,20 @@ struct _MyApplication { GtkApplication parent_instance; - char** dart_entrypoint_arguments; + char **dart_entrypoint_arguments; }; G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) // Called when first Flutter frame received. -static void first_frame_cb(MyApplication* self, FlView* view) { +static void first_frame_cb(MyApplication *self, FlView *view) { gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); } // Implements GApplication::activate. -static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); - GtkWindow* window = +static void my_application_activate(GApplication *application) { + MyApplication *self = MY_APPLICATION(application); + GtkWindow *window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); // Use a header bar when running in GNOME as this is the common style used @@ -34,16 +34,16 @@ static void my_application_activate(GApplication* application) { // if future cases occur). gboolean use_header_bar = TRUE; #ifdef GDK_WINDOWING_X11 - GdkScreen* screen = gtk_window_get_screen(window); + GdkScreen *screen = gtk_window_get_screen(window); if (GDK_IS_X11_SCREEN(screen)) { - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + const gchar *wm_name = gdk_x11_screen_get_window_manager_name(screen); if (g_strcmp0(wm_name, "GNOME Shell") != 0) { use_header_bar = FALSE; } } #endif if (use_header_bar) { - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); gtk_header_bar_set_title(header_bar, "pomodoro_app"); gtk_header_bar_set_show_close_button(header_bar, TRUE); @@ -58,7 +58,7 @@ static void my_application_activate(GApplication* application) { fl_dart_project_set_dart_entrypoint_arguments( project, self->dart_entrypoint_arguments); - FlView* view = fl_view_new(project); + FlView *view = fl_view_new(project); GdkRGBA background_color; // Background defaults to black, override it here if necessary, e.g. #00000000 // for transparent. @@ -79,10 +79,10 @@ static void my_application_activate(GApplication* application) { } // Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, - gchar*** arguments, - int* exit_status) { - MyApplication* self = MY_APPLICATION(application); +static gboolean my_application_local_command_line(GApplication *application, + gchar ***arguments, + int *exit_status) { + MyApplication *self = MY_APPLICATION(application); // Strip out the first argument as it is the binary name. self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); @@ -100,7 +100,7 @@ static gboolean my_application_local_command_line(GApplication* application, } // Implements GApplication::startup. -static void my_application_startup(GApplication* application) { +static void my_application_startup(GApplication *application) { // MyApplication* self = MY_APPLICATION(object); // Perform any actions required at application startup. @@ -109,7 +109,7 @@ static void my_application_startup(GApplication* application) { } // Implements GApplication::shutdown. -static void my_application_shutdown(GApplication* application) { +static void my_application_shutdown(GApplication *application) { // MyApplication* self = MY_APPLICATION(object); // Perform any actions required at application shutdown. @@ -118,13 +118,13 @@ static void my_application_shutdown(GApplication* application) { } // Implements GObject::dispose. -static void my_application_dispose(GObject* object) { - MyApplication* self = MY_APPLICATION(object); +static void my_application_dispose(GObject *object) { + MyApplication *self = MY_APPLICATION(object); g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); G_OBJECT_CLASS(my_application_parent_class)->dispose(object); } -static void my_application_class_init(MyApplicationClass* klass) { +static void my_application_class_init(MyApplicationClass *klass) { G_APPLICATION_CLASS(klass)->activate = my_application_activate; G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; @@ -133,9 +133,9 @@ static void my_application_class_init(MyApplicationClass* klass) { G_OBJECT_CLASS(klass)->dispose = my_application_dispose; } -static void my_application_init(MyApplication* self) {} +static void my_application_init(MyApplication *self) {} -MyApplication* my_application_new() { +MyApplication *my_application_new() { // Set the program name to the application ID, which helps various systems // like GTK and desktop environments map this running application to its // corresponding .desktop file. This ensures better integration by allowing diff --git a/pomodoro_app/linux/runner/my_application.h b/pomodoro_app/linux/runner/my_application.h index db16367..3258a73 100644 --- a/pomodoro_app/linux/runner/my_application.h +++ b/pomodoro_app/linux/runner/my_application.h @@ -3,10 +3,7 @@ #include -G_DECLARE_FINAL_TYPE(MyApplication, - my_application, - MY, - APPLICATION, +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, GtkApplication) /** @@ -16,6 +13,6 @@ G_DECLARE_FINAL_TYPE(MyApplication, * * Returns: a new #MyApplication. */ -MyApplication* my_application_new(); +MyApplication *my_application_new(); -#endif // FLUTTER_MY_APPLICATION_H_ +#endif // FLUTTER_MY_APPLICATION_H_