ronantakizawa/codereview-bench huggingface dataset:
Repository: fastfetch-cli/fastfetch
File: src/common/processing_linux.c (C)

Code before:
#include "fastfetch.h"
#include "common/processing.h"
#include "common/io/io.h"
#include "common/time.h"

#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <poll.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>

#define FF_PIPE_BUFSIZ 16384

static inline void waitpid_wrapper(const pid_t* pid)
{
    // remove zombie processes
    if (*pid > 0)
        waitpid(*pid, NULL, 0);
}

static inline int ffPipe2(int *fds, int flags) {
    #ifdef __APPLE__
        if(pipe(fds) == -1)
            return -1;
        fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
        fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL) | flags);
        return 0;
    #else
        return pipe2(fds, flags);
    #endif
}

const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
    int pipes[2];
    const int timeout = instance.config.general.processingTimeout;
    const int pipeFlags = O_CLOEXEC;

Review comment (suggestion):
You once again assume unreliable things. The pipe buf size has been increased twice, how can you be sure that it won't be increased again?

However, I think it should be ok even if FF_PIPE_BUFSIZ is smaller than real pipe buf size.

Code after:
#include "fastfetch.h"
#include "common/processing.h"
#include "common/io/io.h"
#include "common/time.h"

#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <poll.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>

#define FF_PIPE_BUFSIZ 4096

static inline void waitpid_wrapper(const pid_t* pid)
{
    // remove zombie processes
    if (*pid > 0)
        waitpid(*pid, NULL, 0);
}

static inline int ffPipe2(int *fds, int flags)
{
    #ifdef __APPLE__
        if(pipe(fds) == -1)
            return -1;
        fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
        fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL) | flags);
        return 0;
    #else
        return pipe2(fds, flags);
    #endif
}

const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
    int pipes[2];
    const int timeout = instance.config.general.processingTimeout;
Repository: fastfetch-cli/fastfetch
File: src/common/processing_linux.c (C)

Code before:
#define FF_PIPE_BUFSIZ 16384

static inline void waitpid_wrapper(const pid_t* pid)
{
    // remove zombie processes
    if (*pid > 0)
        waitpid(*pid, NULL, 0);
}

static inline int ffPipe2(int *fds, int flags) {
    #ifdef __APPLE__
        if(pipe(fds) == -1)
            return -1;
        fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
        fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL) | flags);
        return 0;
    #else
        return pipe2(fds, flags);
    #endif
}

const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
    int pipes[2];
    const int timeout = instance.config.general.processingTimeout;
    const int pipeFlags = O_CLOEXEC;

    if(ffPipe2(pipes, pipeFlags) == -1)
        return "pipe() failed";

    __attribute__((__cleanup__(waitpid_wrapper))) pid_t childPid = fork();
    if(childPid == -1) {
        close(pipes[0]);
        close(pipes[1]);
        return "fork() failed";
    }

    //Child
    if(childPid == 0)
    {
        int nullFile = open("/dev/null", O_WRONLY);
        dup2(pipes[1], useStdErr ? STDERR_FILENO : STDOUT_FILENO);
        dup2(nullFile, useStdErr ? STDOUT_FILENO : STDERR_FILENO);
        setenv("LANG", "C", 1);
        execvp(argv[0], argv);
        _exit(127);
    }

    //Parent
    close(pipes[1]);


Review comment (suggestion):
Don't make it a separate variable. It's used only once and `const` in `C` doesn't really make a variable a constant.

Code after:
#define FF_PIPE_BUFSIZ 4096

static inline void waitpid_wrapper(const pid_t* pid)
{
    // remove zombie processes
    if (*pid > 0)
        waitpid(*pid, NULL, 0);
}

static inline int ffPipe2(int *fds, int flags)
{
    #ifdef __APPLE__
        if(pipe(fds) == -1)
            return -1;
        fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
        fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL) | flags);
        return 0;
    #else
        return pipe2(fds, flags);
    #endif
}

const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
    int pipes[2];
    const int timeout = instance.config.general.processingTimeout;

    if(ffPipe2(pipes, O_CLOEXEC) == -1)
        return "pipe() failed";

    __attribute__((__cleanup__(waitpid_wrapper))) pid_t childPid = fork();
    if(childPid == -1)
    {
        close(pipes[0]);
        close(pipes[1]);
        return "fork() failed";
    }

    //Child
    if(childPid == 0)
    {
        int nullFile = open("/dev/null", O_WRONLY|O_CLOEXEC);
        dup2(pipes[1], useStdErr ? STDERR_FILENO : STDOUT_FILENO);
        dup2(nullFile, useStdErr ? STDOUT_FILENO : STDERR_FILENO);
        setenv("LANG", "C", 1);
        execvp(argv[0], argv);
        _exit(127);
    }

    //Parent
    close(pipes[1]);
Repository: fastfetch-cli/fastfetch
File: src/detection/memory/memory_linux.c (C)

Code before:
#include "memory.h"
#include "common/io/io.h"
#include "util/mallocHelper.h"

#include <inttypes.h>

const char* ffDetectMemory(FFMemoryResult* ram)
{
    char buf[PROC_FILE_BUFFSIZ];
    ssize_t nRead = ffReadFileData("/proc/meminfo", sizeof(buf) - 1, buf);
    if(nRead < 0)
        return "ffReadFileData(\"/proc/meminfo\", sizeof(buf)-1, buf)";
    buf[nRead] = '\0';

    uint64_t memTotal = 0,
             shmem = 0,
             memFree = 0,
             buffers = 0,
             cached = 0,
             sReclaimable = 0;
    
    char *token = NULL;
    if((token = strstr(buf, "MemTotal:")) != NULL)
        sscanf(token, "MemTotal: %" PRIu64, &memTotal);

    if((token = strstr(buf, "MemFree:")) != NULL)
        sscanf(token, "MemFree: %" PRIu64, &memFree);

    if((token = strstr(buf, "Buffers:")) != NULL)
        sscanf(token, "Buffers: %" PRIu64, &buffers);
    
    if((token = strstr(buf, "Cached:")) != NULL)
        sscanf(token, "Cached: %" PRIu64, &cached);
    
    if((token = strstr(buf, "Shmem:")) != NULL)
        sscanf(token, "Shmem: %" PRIu64, &shmem);
    
    if((token = strstr(buf, "SReclaimable:")) != NULL)
        sscanf(token, "SReclaimable: %" PRIu64, &sReclaimable);

    ram->bytesTotal = memTotal * 1024lu;
    ram->bytesUsed = (memTotal + shmem - memFree - buffers - cached - sReclaimable) * 1024lu;

    return NULL;
}


Review comment (suggestion):
Since you have matched `MemTotal:` with `strstr`, `sscanf` is no longer necessary.

I prefer `strtoul(token + strlen("MemTotal:"), NULL, 10)`

Code after:
#include "memory.h"
#include "common/io/io.h"
#include "util/mallocHelper.h"

#include <inttypes.h>

const char* ffDetectMemory(FFMemoryResult* ram)
{
    char buf[PROC_FILE_BUFFSIZ];
    ssize_t nRead = ffReadFileData("/proc/meminfo", sizeof(buf) - 1, buf);
    if(nRead < 0)
        return "ffReadFileData(\"/proc/meminfo\", sizeof(buf)-1, buf)";
    buf[nRead] = '\0';

    uint64_t memTotal = 0,
             shmem = 0,
             memFree = 0,
             buffers = 0,
             cached = 0,
             sReclaimable = 0;
    
    char *token = NULL;
    if((token = strstr(buf, "MemTotal:")) != NULL)
        memTotal = strtoul(token + strlen("MemTotal:"), NULL, 10);

    if((token = strstr(buf, "MemFree:")) != NULL)
        memFree = strtoul(token + strlen("MemFree:"), NULL, 10);

    if((token = strstr(buf, "Buffers:")) != NULL)
        buffers = strtoul(token + strlen("Buffers:"), NULL, 10);
    
    if((token = strstr(buf, "Cached:")) != NULL)
        cached = strtoul(token + strlen("Cached:"), NULL, 10);
    
    if((token = strstr(buf, "Shmem:")) != NULL)
        shmem = strtoul(token + strlen("Shmem:"), NULL, 10);
    
    if((token = strstr(buf, "SReclaimable:")) != NULL)
        sReclaimable = strtoul(token + strlen("SReclaimable:"), NULL, 10);

    ram->bytesTotal = memTotal * 1024lu;
    ram->bytesUsed = (memTotal + shmem - memFree - buffers - cached - sReclaimable) * 1024lu;

    return NULL;
}
Repository: fastfetch-cli/fastfetch
File: src/detection/keyboard/keyboard_haiku.cpp (C++)

Code before:
extern "C" {
#include "keyboard.h"
#include "common/io/io.h"
}

#include <interface/Input.h>
#include <support/List.h>

const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */)
{
    BList list;
    BInputDevice *device;

    if (get_input_devices(&list) != B_OK)
    {
        return NULL;
    }

    int32 i, n = list.CountItems();
    for (i = 0; i < n; i++)
    {
        device = (BInputDevice *) list.ItemAt(i);
        if (device->Type() != B_KEYBOARD_DEVICE)
            continue;

        FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
        if (!device->IsRunning())
            ffStrbufAppendS(&name, " (stopped)");

        FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
        ffStrbufInitStatic(&device->serial, "");
        ffStrbufInitMove(&device->name, &name);
    }

    return NULL;
}


Review comment (bug):
```suggestion
    return "get_input_devices(&list) failed";
```

Code after:
extern "C" {
#include "keyboard.h"
#include "common/io/io.h"
}

#include <interface/Input.h>
#include <support/List.h>

const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */)
{
    BList list;
    BInputDevice *device;

    if (get_input_devices(&list) != B_OK)
    {
        return "get_input_devices() failed";
    }

    int32 i, n = list.CountItems();
    for (i = 0; i < n; i++)
    {
        device = (BInputDevice *) list.ItemAt(i);
        if (device->Type() != B_KEYBOARD_DEVICE)
            continue;

        FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
        if (!device->IsRunning())
            ffStrbufAppendS(&name, " (stopped)");

        FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
        ffStrbufInit(&device->serial);
        ffStrbufInitMove(&device->name, &name);
    }

    return NULL;
}
Repository: fastfetch-cli/fastfetch
File: src/detection/keyboard/keyboard_haiku.cpp (C++)

Code before:
#include <interface/Input.h>
#include <support/List.h>

const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */)
{
    BList list;
    BInputDevice *device;

    if (get_input_devices(&list) != B_OK)
    {
        return NULL;
    }

    int32 i, n = list.CountItems();
    for (i = 0; i < n; i++)
    {
        device = (BInputDevice *) list.ItemAt(i);
        if (device->Type() != B_KEYBOARD_DEVICE)
            continue;

        FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
        if (!device->IsRunning())
            ffStrbufAppendS(&name, " (stopped)");

        FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
        ffStrbufInitStatic(&device->serial, "");
        ffStrbufInitMove(&device->name, &name);
    }

    return NULL;
}


Review comment (suggestion):
```suggestion
        ffStrbufInit(&device->serial);
```

Code after:
#include <interface/Input.h>
#include <support/List.h>

const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */)
{
    BList list;
    BInputDevice *device;

    if (get_input_devices(&list) != B_OK)
    {
        return "get_input_devices() failed";
    }

    int32 i, n = list.CountItems();
    for (i = 0; i < n; i++)
    {
        device = (BInputDevice *) list.ItemAt(i);
        if (device->Type() != B_KEYBOARD_DEVICE)
            continue;

        FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
        if (!device->IsRunning())
            ffStrbufAppendS(&name, " (stopped)");

        FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
        ffStrbufInit(&device->serial);
        ffStrbufInitMove(&device->name, &name);
    }

    return NULL;
}
Repository: fastfetch-cli/fastfetch
File: src/logo/builtin.c (C)

Code before:
            FF_COLOR_FG_GREEN,
            FF_COLOR_FG_GREEN,
        },
    },
    // SuseSmall
    {
        .names = {"suse_small", "suse-linux_small"},
        .type = FF_LOGO_LINE_TYPE_SMALL_BIT,
        .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL,
        .colors = {
            FF_COLOR_FG_GREEN,
            FF_COLOR_FG_GREEN,
        },
    },
    // Swagarch
    {
        .names = {"Swagarch"},
        .lines = FASTFETCH_DATATEXT_LOGO_SWAGARCH,
        .colors = {
            FF_COLOR_FG_BLUE,
            FF_COLOR_FG_WHITE,
        },
    },
    // Shebang
    {
        .names = {"Shebang Linux", "Shebang", "shebang"},
        .lines = FASTFETCH_DATATEXT_LOGO_SHEBANG,
        .colors = {
            FF_COLOR_FG_WHITE,
            FF_COLOR_FG_WHITE,
        },
    },
    // LAST
    {},
};

static const FFlogo T[] = {
    // T2
    {
        .names = {"T2"},
        .lines = FASTFETCH_DATATEXT_LOGO_T2,
        .colors = {
            FF_COLOR_FG_WHITE,
            FF_COLOR_FG_BLUE,
        },
    },
    // Tails
    {
        .names = {"Tails"},
        .lines = FASTFETCH_DATATEXT_LOGO_TAILS,
        .colors = {

Review comment (suggestion):
```suggestion
        .names = {"Shebang"},
```

`"Shebang"` is enough. Cases don't matter.

Code after:
            FF_COLOR_FG_RGB "160;205;102",
            FF_COLOR_FG_RGB "181;225;102",
        },
    },
    // Suse
    {
        .names = {"suse", "suse-linux"},
        .lines = FASTFETCH_DATATEXT_LOGO_SUSE,
        .colors = {
            FF_COLOR_FG_GREEN,
            FF_COLOR_FG_GREEN,
        },
    },
    // SuseSmall
    {
        .names = {"suse_small", "suse-linux_small"},
        .type = FF_LOGO_LINE_TYPE_SMALL_BIT,
        .lines = FASTFETCH_DATATEXT_LOGO_OPENSUSE_SMALL,
        .colors = {
            FF_COLOR_FG_GREEN,
            FF_COLOR_FG_GREEN,
        },
    },
    // Swagarch
    {
        .names = {"Swagarch"},
        .lines = FASTFETCH_DATATEXT_LOGO_SWAGARCH,
        .colors = {
            FF_COLOR_FG_BLUE,
            FF_COLOR_FG_WHITE,
        },
    },
    // LAST
    {},
};

static const FFlogo T[] = {
    // T2
    {
        .names = {"T2"},
        .lines = FASTFETCH_DATATEXT_LOGO_T2,
        .colors = {
            FF_COLOR_FG_WHITE,
            FF_COLOR_FG_BLUE,
        },
    },
    // Tails
    {
        .names = {"Tails"},
        .lines = FASTFETCH_DATATEXT_LOGO_TAILS,
        .colors = {
Repository: fastfetch-cli/fastfetch
File: src/logo/builtin.c (C)

Code before:
    },
    // MidOS
    {
        .names = {"MidOS"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIDOS,
        .colors = {
            FF_COLOR_FG_LIGHT_BLACK,
        },
        .colorKeys = FF_COLOR_FG_LIGHT_BLACK,
        .colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // MidOSOld
    {
        .names = {"MidOS_old"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIDOS_OLD,
        .type = FF_LOGO_LINE_TYPE_ALTER_BIT,
        .colors = {
            FF_COLOR_FG_LIGHT_BLACK,
            FF_COLOR_FG_WHITE,
        },
        .colorKeys = FF_COLOR_FG_LIGHT_BLACK,
        .colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // Minimal System
    {
	.names = {"Minimal System", "Minimal"},
	.lines = FASTFETCH_DATATEXT_LOGO_MINIMAL,
	.colors = {
	    FF_COLOR_FG_RED,
	},
	.colorKeys = FF_COLOR_FG_CYAN,
	.colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // Minix
    {
        .names = {"Minix"},
        .lines = FASTFETCH_DATATEXT_LOGO_MINIX,
        .colors = {
            FF_COLOR_FG_RED,
            FF_COLOR_FG_WHITE,
            FF_COLOR_FG_YELLOW,
        },
        .colorKeys = FF_COLOR_FG_RED,
        .colorTitle = FF_COLOR_FG_YELLOW,
    },
    // MiracleLinux
    {
        .names = {"MIRACLE LINUX", "miracle_linux"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIRACLE_LINUX,
        .colors = {
            FF_COLOR_FG_256 "29",

Review comment (suggestion):
```suggestion
	.names = {"Minimal_System"},
```

To match `ID` in your `/etc/os-release`

Code after:
    },
    // MidOS
    {
        .names = {"MidOS"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIDOS,
        .colors = {
            FF_COLOR_FG_LIGHT_BLACK,
        },
        .colorKeys = FF_COLOR_FG_LIGHT_BLACK,
        .colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // MidOSOld
    {
        .names = {"MidOS_old"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIDOS_OLD,
        .type = FF_LOGO_LINE_TYPE_ALTER_BIT,
        .colors = {
            FF_COLOR_FG_LIGHT_BLACK,
            FF_COLOR_FG_WHITE,
        },
        .colorKeys = FF_COLOR_FG_LIGHT_BLACK,
        .colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // Minimal System
    {
        .names = {"Minimal_System"},
        .lines = FASTFETCH_DATATEXT_LOGO_MINIMAL,
        .colors = {
            FF_COLOR_FG_RED,
        },
        .colorKeys = FF_COLOR_FG_CYAN,
        .colorTitle = FF_COLOR_FG_DEFAULT,
    },
    // Minix
    {
        .names = {"Minix"},
        .lines = FASTFETCH_DATATEXT_LOGO_MINIX,
        .colors = {
            FF_COLOR_FG_RED,
            FF_COLOR_FG_WHITE,
            FF_COLOR_FG_YELLOW,
        },
        .colorKeys = FF_COLOR_FG_RED,
        .colorTitle = FF_COLOR_FG_YELLOW,
    },
    // MiracleLinux
    {
        .names = {"MIRACLE LINUX", "miracle_linux"},
        .lines = FASTFETCH_DATATEXT_LOGO_MIRACLE_LINUX,
        .colors = {
            FF_COLOR_FG_256 "29",
Repository: fastfetch-cli/fastfetch
File: src/detection/zpool/zpool.c (C)

Code before:

typedef struct FFZfsData
{
    FF_LIBRARY_SYMBOL(libzfs_fini)
    FF_LIBRARY_SYMBOL(zpool_get_prop_int)
    FF_LIBRARY_SYMBOL(zpool_get_prop)
    FF_LIBRARY_SYMBOL(zpool_close)

    // The fields in this struct store property IDs returned by `zpool_name_to_prop`,
    // not the property values themselves.
    struct {
        int name;
        int health;
        int guid;
        int size;
        int free;
        int allocated;
        int fragmentation;
        int readonly;
    } props;

    libzfs_handle_t* handle;
    FFlist* result;
} FFZfsData;

static inline int ff_zpool_get_prop_wrapper(
    FFZfsData* data,
    zpool_handle_t *zhp,
    zpool_prop_t prop,
    char *buf,
    size_t len,
    zprop_source_t *srctype,
    boolean_t literal __attribute__((unused))
)
{
    /* 
    Solaris header: 
        extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, size_t __proplen, zprop_source_t *);
    Illumos header:
        extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *, size_t proplen, zprop_source_t *, boolean_t);
    */
#if defined(__sun) && ! defined(__illumos__)
    return data->ffzpool_get_prop(zhp, prop, buf, len, srctype);
#else
    return data->ffzpool_get_prop(zhp, prop, buf, len, srctype, literal);
#endif

}

static inline void cleanLibzfs(FFZfsData* data)
{

Review comment (suggestion):
I prefer `#define ffzpool_get_prop(data, zhp, prop, buf, len, srctype, literal) ffzpool_get_prop(data, zhp, prop, buf, len, srctype)`

Code after:
#else
#include "libzfs_simplified.h"
#endif

#include "common/library.h"

typedef struct FFZfsData
{
    FF_LIBRARY_SYMBOL(libzfs_fini)
    FF_LIBRARY_SYMBOL(zpool_get_prop_int)
    FF_LIBRARY_SYMBOL(zpool_get_prop)
    FF_LIBRARY_SYMBOL(zpool_close)

    // The fields in this struct store property IDs returned by `zpool_name_to_prop`,
    // not the property values themselves.
    struct {
        int name;
        int health;
        int guid;
        int size;
        int free;
        int allocated;
        int fragmentation;
        int readonly;
    } props;

    libzfs_handle_t* handle;
    FFlist* result;
} FFZfsData;

static inline void cleanLibzfs(FFZfsData* data)
{
    if (data->fflibzfs_fini && data->handle)
    {
        data->fflibzfs_fini(data->handle);
        data->handle = NULL;
    }
}

static int enumZpoolCallback(zpool_handle_t* zpool, void* param)
{
    FFZfsData* data = (FFZfsData*) param;
    zprop_source_t source;
    FFZpoolResult* item = ffListAdd(data->result);
    char buf[1024];
    if (data->ffzpool_get_prop(zpool, data->props.name, buf, ARRAY_SIZE(buf), &source, false) == 0)
        ffStrbufInitS(&item->name, buf);
    else
        ffStrbufInitStatic(&item->name, "unknown");
    if (data->ffzpool_get_prop(zpool, data->props.health, buf, ARRAY_SIZE(buf), &source, false) == 0)
        ffStrbufInitS(&item->state, buf);
Repository: folke/lazy.nvim
File: lua/lazy/health.lua (Lua)

Code before:
      end
    end
  end
  if not existing then
    ok("no existing packages found by other package managers")
  end

  for _, name in ipairs({ "packer", "plugged", "paq" }) do
    for _, path in ipairs(vim.opt.rtp:get()) do
      if path:find(name, 1, true) then
        error("Found paths on the rtp from another plugin manager `" .. name .. "`")
        break
      end
    end
  end

  local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
  if vim.loop.fs_stat(packer_compiled) then
    error("please remove the file `" .. packer_compiled .. "`")
  else
    ok("packer_compiled.lua not found")
  end

  local spec = Config.spec
  if spec == nil then
    ok("no packages setup for installation so far.")
  else
    for _, plugin in pairs(spec.plugins) do
      M.check_valid(plugin)
      M.check_override(plugin)
    end
    if #spec.notifs > 0 then
      error("Issues were reported when loading your specs:")
      for _, notif in ipairs(spec.notifs) do
        local lines = vim.split(notif.msg, "\n")
        for _, line in ipairs(lines) do
          if notif.level == vim.log.levels.ERROR then
            error(line)
          else
            warn(line)
          end
        end
      end
    end
  end
end

---@param plugin LazyPlugin
function M.check_valid(plugin)
  for key in pairs(plugin) do
    if not vim.tbl_contains(M.valid, key) then

Review comment (suggestion):
This should be `error("No plugins loaded. Did you forget to run `setup()`?")`

Code after:
      end
    end
  end
  if not existing then
    ok("no existing packages found by other package managers")
  end

  for _, name in ipairs({ "packer", "plugged", "paq" }) do
    for _, path in ipairs(vim.opt.rtp:get()) do
      if path:find(name, 1, true) then
        error("Found paths on the rtp from another plugin manager `" .. name .. "`")
        break
      end
    end
  end

  local packer_compiled = vim.fn.stdpath("config") .. "/plugin/packer_compiled.lua"
  if vim.loop.fs_stat(packer_compiled) then
    error("please remove the file `" .. packer_compiled .. "`")
  else
    ok("packer_compiled.lua not found")
  end

  local spec = Config.spec
  if spec == nil then
    error("No plugins loaded. Did you forget to run `require(\"lazy\").setup()`?")
  else
    for _, plugin in pairs(spec.plugins) do
      M.check_valid(plugin)
      M.check_override(plugin)
    end
    if #spec.notifs > 0 then
      error("Issues were reported when loading your specs:")
      for _, notif in ipairs(spec.notifs) do
        local lines = vim.split(notif.msg, "\n")
        for _, line in ipairs(lines) do
          if notif.level == vim.log.levels.ERROR then
            error(line)
          else
            warn(line)
          end
        end
      end
    end
  end
end

---@param plugin LazyPlugin
function M.check_valid(plugin)
  for key in pairs(plugin) do
    if not vim.tbl_contains(M.valid, key) then