feat: great beautiful fixes

This commit is contained in:
Krzysztof Rudnicki 2026-02-20 01:17:53 +01:00
parent 67da5c4fb9
commit ac7d678007
9 changed files with 41 additions and 39 deletions

View File

@ -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;
}

View File

@ -1,6 +1,6 @@
# Clang-format configuration for imageViewer project
---
Language: C
Language: Cpp
# Base style
BasedOnStyle: LLVM

View File

@ -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 */

View File

@ -63,6 +63,7 @@ bool validInput(const std::string s) {
return 1;
}
// cppcheck-suppress missingReturn
std::vector<int> requiredShoots(const int pointsLeft) {}
int main() {

View File

@ -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];
}

View File

@ -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}`);
});

View File

@ -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);
}

View File

@ -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

View File

@ -3,10 +3,7 @@
#include <gtk/gtk.h>
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_