ronantakizawa/codereview-bench huggingface dataset:
Repository: louislam/uptime-kuma
File: src/languages/ko-KR.js (JavaScript)

Code before:
    "pushoversounds mechanical": "Mechanical",
    "pushoversounds pianobar": "Piano Bar",
    "pushoversounds siren": "Siren",
    "pushoversounds spacealarm": "Space Alarm",
    "pushoversounds tugboat": "Tug Boat",
    "pushoversounds alien": "Alien Alarm (long)",
    "pushoversounds climb": "Climb (long)",
    "pushoversounds persistent": "Persistent (long)",
    "pushoversounds echo": "Pushover Echo (long)",
    "pushoversounds updown": "Up Down (long)",
    "pushoversounds vibrate": "진동만",
    "pushoversounds none": "없음 (무음)",
    pushyAPIKey: "비밀 API 키",
    pushyToken: "기기 토큰",
    "Show update if available": "사용 가능한 경우에 업데이트 표시",
    "Also check beta release": "베타 릴리즈 확인",
    "Using a Reverse Proxy?": "리버스 프록시를 사용하시나요?",
    "Check how to config it for WebSocket": "웹소켓 대한 설정 방법",
    "Steam Game Server": "스팀 게임 서버",
    "Most likely causes:": "원인:",
    "The resource is no longer available.": "더이상 사용할 수 없어요...",
    "There might be a typing error in the address.": "주소에 오탈자가 있을 수 있어요.",
    "What you can try:": "해결 방법:",
    "Retype the address.": "주소 다시 입력하기",
    "Go back to the previous page.": "이전 페이지로 돌아가기",
    "Coming Soon": "Coming Soon...",
    wayToGetClickSendSMSToken: "{0}에서 API 사용자 이름과 키를 얻을 수 있어요.",
};


Review comment (suggestion):
```suggestion
    "Coming Soon": "곧 만나보세요.",
```

If we try to use Korean in all wording, I think this could be used.

Code after:
    "pushoversounds mechanical": "Mechanical",
    "pushoversounds pianobar": "Piano Bar",
    "pushoversounds siren": "Siren",
    "pushoversounds spacealarm": "Space Alarm",
    "pushoversounds tugboat": "Tug Boat",
    "pushoversounds alien": "Alien Alarm (long)",
    "pushoversounds climb": "Climb (long)",
    "pushoversounds persistent": "Persistent (long)",
    "pushoversounds echo": "Pushover Echo (long)",
    "pushoversounds updown": "Up Down (long)",
    "pushoversounds vibrate": "진동만",
    "pushoversounds none": "없음 (무음)",
    pushyAPIKey: "비밀 API 키",
    pushyToken: "기기 토큰",
    "Show update if available": "사용 가능한 경우에 업데이트 표시",
    "Also check beta release": "베타 릴리즈 확인",
    "Using a Reverse Proxy?": "리버스 프록시를 사용하시나요?",
    "Check how to config it for WebSocket": "웹소켓 대한 설정 방법",
    "Steam Game Server": "스팀 게임 서버",
    "Most likely causes:": "원인:",
    "The resource is no longer available.": "더 이상 사용할 수 없어요...",
    "There might be a typing error in the address.": "주소에 오탈자가 있을 수 있어요.",
    "What you can try:": "해결 방법:",
    "Retype the address.": "주소 다시 입력하기",
    "Go back to the previous page.": "이전 페이지로 돌아가기",
    "Coming Soon": "Coming Soon...",
    wayToGetClickSendSMSToken: "{0}에서 API 사용자 이름과 키를 얻을 수 있어요.",
};
Repository: louislam/uptime-kuma
File: server/notification-providers/freemobile.js (JavaScript)

Code before:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class FreeMobile extends NotificationProvider {

    name = "FreeMobile";

    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        let okMsg = "Sent Successfully.";
        try {
            await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURI(msg.replace("🔴", "⛔️"))}`, {
                "user": notification.freemobileUser,
                "pass": notification.freemobilePass,
            });

            return okMsg;

        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = FreeMobile;


Review comment (suggestion):
```suggestion
            await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURIComponent(msg.replace("🔴", "⛔️"))}`, {
```

Code after:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");

class FreeMobile extends NotificationProvider {

    name = "FreeMobile";

    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        let okMsg = "Sent Successfully.";
        try {
            await axios.post(`https://smsapi.free-mobile.fr/sendmsg?msg=${encodeURIComponent(msg.replace("🔴", "⛔️"))}`, {
                "user": notification.freemobileUser,
                "pass": notification.freemobilePass,
            });

            return okMsg;

        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = FreeMobile;
Repository: louislam/uptime-kuma
File: server/check-version.js (JavaScript)

Code before:
const { setSetting, setting } = require("./util-server");
const axios = require("axios");
const { log } = require("../src/util");

exports.version = require("../package.json").version;
exports.latestVersion = null;

const UPDATE_CHECKER_INTERVAL_MS = 3600 * 1000 * 48;
const UPDATE_CHECKER_LATEST_VERSION_URL = "https://uptime.kuma.pet/version";

let interval;

exports.startInterval = () => {
    let check = async () => {
        if (await setting("checkUpdate") === false) {
            return;
        }

        log.debug("update-checker", "retrieving latest versions");

        try {
            const res = await axios.get(UPDATE_CHECKER_LATEST_VERSION_URL);

            // For debug
            if (process.env.TEST_CHECK_VERSION === "1") {
                res.data.slow = "1000.0.0";
            }

            let checkBeta = await setting("checkBeta");

            if (checkBeta && res.data.beta) {
                exports.latestVersion = res.data.beta;
            }

            if (res.data.slow) {
                exports.latestVersion = res.data.slow;
            }

        } catch (_) {
            log.info("update-checker", "Update checker: failed to check for new versions");
        }

    };


Review comment (bug):
```suggestion
        log.debug("update-checker", "Retrieving latest versions");
```

Code after:
const { setSetting, setting } = require("./util-server");
const axios = require("axios");
const compareVersions = require("compare-versions");
const { log } = require("../src/util");

exports.version = require("../package.json").version;
exports.latestVersion = null;

// How much time in ms to wait between update checks
const UPDATE_CHECKER_INTERVAL_MS = 1000 * 60 * 60 * 48;
const UPDATE_CHECKER_LATEST_VERSION_URL = "https://uptime.kuma.pet/version";

let interval;

exports.startInterval = () => {
    let check = async () => {
        if (await setting("checkUpdate") === false) {
            return;
        }

        log.debug("update-checker", "Retrieving latest versions");

        try {
            const res = await axios.get(UPDATE_CHECKER_LATEST_VERSION_URL);

            // For debug
            if (process.env.TEST_CHECK_VERSION === "1") {
                res.data.slow = "1000.0.0";
            }

            let checkBeta = await setting("checkBeta");

            if (checkBeta && res.data.beta) {
                if (compareVersions.compare(res.data.beta, res.data.slow, ">")) {
                    exports.latestVersion = res.data.beta;
                    return;
                }
            }

            if (res.data.slow) {
                exports.latestVersion = res.data.slow;
            }

        } catch (_) {
Repository: louislam/uptime-kuma
File: server/auth.js (JavaScript)

Code before:
const basicAuth = require("express-basic-auth");
const passwordHash = require("./password-hash");
const { R } = require("redbean-node");
const { setting } = require("./util-server");
const { loginRateLimiter } = require("./rate-limiter");

/**
 * Login to web app
 * @param {string} username
 * @param {string} password
 * @returns {Promise<(Bean|null)>}
 */
exports.login = async function (username, password) {
    if (typeof username !== "string" || typeof password !== "string") {
        return null;
    }

    let user = await R.findOne("user", " username LIKE ? AND active = 1 ", [
        username,
    ]);

    if (user && passwordHash.verify(password, user.password)) {
        // Upgrade the hash to bcrypt
        if (passwordHash.needRehash(user.password)) {
            await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
                passwordHash.generate(password),
                user.id,
            ]);
        }
        return user;
    }

    return null;
};

/**
 * Callback for myAuthorizer
 * @callback myAuthorizerCB
 * @param {any} err Any error encountered
 * @param {boolean} authorized Is the client authorized?
 */

/**

Review comment (security):
Thanks, I didn't notice that, because I thought SQLite is similar MySQL and MySQL is case-insensitive by default.

However, I don't think using `LIKE` is a best choice. 

Code after:
const basicAuth = require("express-basic-auth");
const passwordHash = require("./password-hash");
const { R } = require("redbean-node");
const { setting } = require("./util-server");
const { loginRateLimiter } = require("./rate-limiter");

/**
 * Login to web app
 * @param {string} username
 * @param {string} password
 * @returns {Promise<(Bean|null)>}
 */
exports.login = async function (username, password) {
    if (typeof username !== "string" || typeof password !== "string") {
        return null;
    }

    let user = await R.findOne("user", " username = ? AND active = 1", [
        username,
    ]);

    if (user && passwordHash.verify(password, user.password)) {
        // Upgrade the hash to bcrypt
        if (passwordHash.needRehash(user.password)) {
            await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
                passwordHash.generate(password),
                user.id,
            ]);
        }
        return user;
    }

    return null;
};

/**
 * Callback for myAuthorizer
 * @callback myAuthorizerCB
 * @param {any} err Any error encountered
 * @param {boolean} authorized Is the client authorized?
 */

/**
Repository: louislam/uptime-kuma
File: src/pages/EditMonitor.vue (Vue)

Code before:

message HealthCheckRequest {
  string service = 1;
}

message HealthCheckResponse {
  enum ServingStatus {
    UNKNOWN = 0;
    SERVING = 1;
    NOT_SERVING = 2;
    SERVICE_UNKNOWN = 3;  // Used only by the Watch method.
  }
  ServingStatus status = 1;
}
            ` ]);
        },
        bodyPlaceholder() {
            return this.$t("Example:", [ `
{
    "key": "value"
}` ]);
        },

        headersPlaceholder() {
            return this.$t("Example:", [ `
{
    "HeaderName": "HeaderValue"
}` ]);
        }

    },
    watch: {
        "$root.proxyList"() {
            if (this.isAdd) {
                if (this.$root.proxyList && !this.monitor.proxyId) {
                    const proxy = this.$root.proxyList.find(proxy => proxy.default);

                    if (proxy) {
                        this.monitor.proxyId = proxy.id;
                    }
                }
            }
        },

        "$route.fullPath"() {
            this.init();
        },

        "monitor.interval"(value, oldValue) {
            // Link interval and retryInterval if they are the same value.
            if (this.monitor.retryInterval === oldValue) {

Review comment (bug):
I would do as:
```Javascript
let name;
if (this.isClone) {
  name = "Clone Monitor";
} else if (this.isAdd) {
  name = "Edit";
} else if (this.isEdit) {
  name = "Add New Monitor";
} else {
  name = "Wrong Monitor Action";
}
return this.$t(name);
```

And I would add in en.js: Wrong Monitor Action

Also, it's not quite clear to me why the Edit Monitor translation key wouldn't be added, so that when you change the Edit key for other purposes, you don't risk making this one case incomprehensible

Code after:
            dnsresolvetypeOptions: [],
            ipOrHostnameRegexPattern: hostNameRegexPattern(),
            mqttIpOrHostnameRegexPattern: hostNameRegexPattern(true),
            gameList: null,
        };
    },

    computed: {

        ipRegex() {

            // Allow to test with simple dns server with port (127.0.0.1:5300)
            if (! isDev) {
                return this.ipRegexPattern;
            }
            return null;
        },

        pageName() {
            let name = "Add New Monitor";
            if (this.isClone) {
                name = "Clone Monitor";
            } else if (this.isEdit) {
                name = "Edit";
            }
            return this.$t(name);
        },

        isAdd() {
            return this.$route.path === "/add";
        },

        isClone() {
            return this.$route.path.startsWith("/clone");
        },

        isEdit() {
            return this.$route.path.startsWith("/edit");
        },

        pushURL() {
            return this.$root.baseURL + "/api/push/" + this.monitor.pushToken + "?status=up&msg=OK&ping=";
        },

        protoServicePlaceholder() {
            return this.$t("Example:", [ "Health" ]);
        },

        protoMethodPlaceholder() {
            return this.$t("Example:", [ "check" ]);
        },
Repository: louislam/uptime-kuma
File: server/util-server.js (JavaScript)

Code before:
    hostname,
    username,
    password,
    calledStationId,
    callingStationId,
    secret,
    port = 1812,
) {
    const client = new radiusClient({
        host: hostname,
        hostPort: port,
        dictionaries: [ file ],
    });

    return client.accessRequest({
        secret: secret,
        attributes: [
            [ attributes.USER_NAME, username ],
            [ attributes.USER_PASSWORD, password ],
            [ attributes.CALLING_STATION_ID, callingStationId ],
            [ attributes.CALLED_STATION_ID, calledStationId ],
        ],
    });
};
/**
 * Redis server ping
 * @param {string} dsn The redis connection string
 */
exports.redisPingAsync = function (dsn) {
    return new Promise((resolve, reject) => {
        const client = redis.createClient({
            url: dsn,
        });
        client.on("error", (err) => {
            reject(err);
        });
        client.connect().then(() => {
            client.ping().then((res, err) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(res);
                }
            });
        });
    });
};

/**
 * Retrieve value of setting based on key
 * @param {string} key Key of setting to retrieve

Review comment (suggestion):
```suggestion

/**
```
Preserve line between function and previous statement.

Code after:
    hostname,
    username,
    password,
    calledStationId,
    callingStationId,
    secret,
    port = 1812,
) {
    const client = new radiusClient({
        host: hostname,
        hostPort: port,
        dictionaries: [ file ],
    });

    return client.accessRequest({
        secret: secret,
        attributes: [
            [ attributes.USER_NAME, username ],
            [ attributes.USER_PASSWORD, password ],
            [ attributes.CALLING_STATION_ID, callingStationId ],
            [ attributes.CALLED_STATION_ID, calledStationId ],
        ],
    });
};

/**
 * Redis server ping
 * @param {string} dsn The redis connection string
 */
exports.redisPingAsync = function (dsn) {
    return new Promise((resolve, reject) => {
        const client = redis.createClient({
            url: dsn,
        });
        client.on("error", (err) => {
            reject(err);
        });
        client.connect().then(() => {
            client.ping().then((res, err) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(res);
                }
            });
        });
    });
};

/**
 * Retrieve value of setting based on key
Repository: louislam/uptime-kuma
File: extra/update-wiki-version.js (JavaScript)

Code before:

    childProcess.spawnSync("git", [ "clone", "https://github.com/louislam/uptime-kuma.wiki.git", wikiDir ]);
    let content = fs.readFileSync(howToUpdateFilename).toString();

    // Replace the version: https://regex101.com/r/hmj2Bc/1
    content = content.replace(/(git checkout )([^\s]+)/, `$1${newVersion}`);
    fs.writeFileSync(howToUpdateFilename, content);

    childProcess.spawnSync("git", [ "add", "-A" ], {
        cwd: wikiDir,
    });

    childProcess.spawnSync("git", [ "commit", "-m", `Update to ${newVersion}` ], {
        cwd: wikiDir,
    });

    console.log("Pushing to Github");
    childProcess.spawnSync("git", [ "push" ], {
        cwd: wikiDir,
    });

    safeDelete(wikiDir);
}

/**
 * Check if a directory exists before deleting
 * @param {string} dir Directory to delete
 */
function safeDelete(dir) {
    if (fs.existsSync(dir)) {
        fs.rm(dir, {
            recursive: true,
        });
    }
}


Review comment (suggestion):
IMO, it's not only "checking" :)

```suggestion
 * Check and delete existing directory
```

Code after:

    childProcess.spawnSync("git", [ "clone", "https://github.com/louislam/uptime-kuma.wiki.git", wikiDir ]);
    let content = fs.readFileSync(howToUpdateFilename).toString();

    // Replace the version: https://regex101.com/r/hmj2Bc/1
    content = content.replace(/(git checkout )([^\s]+)/, `$1${newVersion}`);
    fs.writeFileSync(howToUpdateFilename, content);

    childProcess.spawnSync("git", [ "add", "-A" ], {
        cwd: wikiDir,
    });

    childProcess.spawnSync("git", [ "commit", "-m", `Update to ${newVersion}` ], {
        cwd: wikiDir,
    });

    console.log("Pushing to Github");
    childProcess.spawnSync("git", [ "push" ], {
        cwd: wikiDir,
    });

    safeDelete(wikiDir);
}

/**
 * Check if a directory exists and then delete it
 * @param {string} dir Directory to delete
 */
function safeDelete(dir) {
    if (fs.existsSync(dir)) {
        fs.rm(dir, {
            recursive: true,
        });
    }
}
Repository: louislam/uptime-kuma
File: server/model/status_page.js (JavaScript)

Code before:
            if (this.slug === s) {
                domainList.push(domain);
            }
        }
        return domainList;
    }

    /**
     * Return an object that ready to parse to JSON
     * @returns {Object}
     */
    async toJSON() {
        return {
            id: this.id,
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            domainNameList: this.getDomainNameList(),
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id
        };
    }

    /**
     * Return an object that ready to parse to JSON for public
     * Only show necessary data to public
     * @returns {Object}
     */
    async toPublicJSON() {
        return {
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id
        };
    }

    /**

Review comment (suggestion):
```suggestion
            googleAnalyticsId: this.google_analytics_tag_id,
```

Code after:
     */
    getDomainNameList() {
        let domainList = [];
        for (let domain in StatusPage.domainMappingList) {
            let s = StatusPage.domainMappingList[domain];

            if (this.slug === s) {
                domainList.push(domain);
            }
        }
        return domainList;
    }

    /**
     * Return an object that ready to parse to JSON
     * @returns {Object}
     */
    async toJSON() {
        return {
            id: this.id,
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            domainNameList: this.getDomainNameList(),
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id,
        };
    }

    /**
     * Return an object that ready to parse to JSON for public
     * Only show necessary data to public
     * @returns {Object}
     */
    async toPublicJSON() {
        return {
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            customCSS: this.custom_css,
            footerText: this.footer_text,
Repository: louislam/uptime-kuma
File: server/model/status_page.js (JavaScript)

Code before:
            domainNameList: this.getDomainNameList(),
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id
        };
    }

    /**
     * Return an object that ready to parse to JSON for public
     * Only show necessary data to public
     * @returns {Object}
     */
    async toPublicJSON() {
        return {
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id
        };
    }

    /**
     * Convert slug to status page ID
     * @param {string} slug
     */
    static async slugToID(slug) {
        return await R.getCell("SELECT id FROM status_page WHERE slug = ? ", [
            slug
        ]);
    }

    /**
     * Get path to the icon for the page
     * @returns {string}
     */
    getIcon() {
        if (!this.icon) {
            return "/icon.svg";
        } else {
            return this.icon;
        }
    }


Review comment (suggestion):
```suggestion
            googleAnalyticsId: this.google_analytics_tag_id,
```

Code after:
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            domainNameList: this.getDomainNameList(),
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id,
        };
    }

    /**
     * Return an object that ready to parse to JSON for public
     * Only show necessary data to public
     * @returns {Object}
     */
    async toPublicJSON() {
        return {
            slug: this.slug,
            title: this.title,
            description: this.description,
            icon: this.getIcon(),
            theme: this.theme,
            published: !!this.published,
            showTags: !!this.show_tags,
            customCSS: this.custom_css,
            footerText: this.footer_text,
            showPoweredBy: !!this.show_powered_by,
            googleAnalyticsId: this.google_analytics_tag_id,
        };
    }

    /**
     * Convert slug to status page ID
     * @param {string} slug
     */
    static async slugToID(slug) {
        return await R.getCell("SELECT id FROM status_page WHERE slug = ? ", [
            slug
        ]);
    }

    /**
     * Get path to the icon for the page
     * @returns {string}
     */
    getIcon() {
        if (!this.icon) {