ronantakizawa/codereview-bench huggingface dataset:
Repository: didi/nightingale
File: center/router/router_datasource.go (Go)

Code before:
// getElasticsearchVersion 该函数尝试从提供的Elasticsearch数据源中获取版本号，遍历所有URL，
// 直到成功获取版本号或所有URL均尝试失败为止。
func getElasticsearchVersion(ds models.Datasource) (string, error) {
	client := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: ds.HTTPJson.TLS.SkipTlsVerify,
			},
		},
	}

	urls := make([]string, 0)
	if len(ds.HTTPJson.Urls) > 0 {
		urls = append(urls, ds.HTTPJson.Urls...)
	}
	if ds.HTTPJson.Url != "" {
		urls = append(urls, ds.HTTPJson.Url)
	}
	if len(urls) == 0 {
		return "", fmt.Errorf("no url provided")
	}

	var lastErr error
	for _, raw := range urls {
		baseURL := strings.TrimRight(raw, "/") + "/"
		for attempt := 0; attempt < 10; attempt++ {
			req, err := http.NewRequest("GET", baseURL, nil)
			if err != nil {
				lastErr = err
				continue
			}

			if ds.AuthJson.BasicAuthUser != "" {
				req.SetBasicAuth(ds.AuthJson.BasicAuthUser, ds.AuthJson.BasicAuthPassword)
			}

			for k, v := range ds.HTTPJson.Headers {
				req.Header.Set(k, v)
			}

			resp, err := client.Do(req)
			if err != nil {
				lastErr = err
				continue
			}

			body, err := io.ReadAll(resp.Body)
			resp.Body.Close()
			if err != nil {
				lastErr = err
				continue

Review comment (bug):
Here you can not add retries. If the version number fails to be obtained, we can directly report an error and let the user save again

Code after:

// getElasticsearchVersion 该函数尝试从提供的Elasticsearch数据源中获取版本号，遍历所有URL，
// 直到成功获取版本号或所有URL均尝试失败为止。
func getElasticsearchVersion(ds models.Datasource, timeout time.Duration) (string, error) {
	client := &http.Client{
		Timeout: timeout,
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: ds.HTTPJson.TLS.SkipTlsVerify,
			},
		},
	}

	urls := make([]string, 0)
	if len(ds.HTTPJson.Urls) > 0 {
		urls = append(urls, ds.HTTPJson.Urls...)
	}
	if ds.HTTPJson.Url != "" {
		urls = append(urls, ds.HTTPJson.Url)
	}
	if len(urls) == 0 {
		return "", fmt.Errorf("no url provided")
	}

	var lastErr error
	for _, raw := range urls {
		baseURL := strings.TrimRight(raw, "/") + "/"
		req, err := http.NewRequest("GET", baseURL, nil)
		if err != nil {
			lastErr = err
			continue
		}

		if ds.AuthJson.BasicAuthUser != "" {
			req.SetBasicAuth(ds.AuthJson.BasicAuthUser, ds.AuthJson.BasicAuthPassword)
		}

		for k, v := range ds.HTTPJson.Headers {
			req.Header.Set(k, v)
		}

		resp, err := client.Do(req)
		if err != nil {
			lastErr = err
			continue
		}

		body, err := io.ReadAll(resp.Body)
		resp.Body.Close()
		if err != nil {
			lastErr = err
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/templates/global_sections/index.js (JavaScript)

Code before:
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

export { default as HTTPS } from './https';
export { default as Security } from './security';
export { default as PHP } from './php';
export { default as Python } from './python';
export { default as ReverseProxy } from './reverse_proxy';
export { default as Performance } from './performance';
export { default as Logging } from './logging';
export { default as NGINX } from './nginx';
export { default as Tools } from './tools';
export { default as Docker } from './docker';


Review comment (suggestion):
```suggestion
export { default as Docker } from './docker';
export { default as Tools } from './tools';
```
Tools is a bit of a tool-meta tab, so we should put config generation tabs before it :)

Code after:
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

export { default as HTTPS } from './https';
export { default as Security } from './security';
export { default as PHP } from './php';
export { default as Python } from './python';
export { default as ReverseProxy } from './reverse_proxy';
export { default as Performance } from './performance';
export { default as Logging } from './logging';
export { default as NGINX } from './nginx';
export { default as Docker } from './docker';
export { default as Tools } from './tools';
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/i18n/en/common.js (JavaScript)

Code before:
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

export default {
	back: 'Back',
	next: 'Next',
	enable: 'enable',
	php: 'PHP',
	ssl: 'SSL',
	nginx: 'NGINX',
	http: 'HTTP',
	https: 'HTTPS',
	letsEncrypt: 'Let\'s Encrypt',
	python: 'Python',
	docker: 'Dockerfile',
	wordPress: 'WordPress',
	drupal: 'Drupal',
	magento: 'Magento',
	django: 'Django',
	logging: 'Logging',
    reverseProxy: 'Reverse proxy',
    reverseProxyLower: 'reverse proxy',
};


Review comment (suggestion):
```suggestion
	docker: 'Docker',
```
Lets keep the tab named 'Docker' so it can potentially be used for more in the future

Code after:
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

export default {
	back: 'Back',
	next: 'Next',
	enable: 'enable',
	php: 'PHP',
	ssl: 'SSL',
	nginx: 'NGINX',
	http: 'HTTP',
	https: 'HTTPS',
	letsEncrypt: 'Let\'s Encrypt',
	python: 'Python',
	docker: 'Docker',
	wordPress: 'WordPress',
	drupal: 'Drupal',
	magento: 'Magento',
	django: 'Django',
	logging: 'Logging',
    reverseProxy: 'Reverse proxy',
    reverseProxyLower: 'reverse proxy',
};
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/i18n/en/templates/global_sections/docker.js (JavaScript)

Code before:
You may obtain a copy of the License at
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

export default {
    dockerfile: `Include ${common.docker} to run nginx with Docker`,
};


Review comment (suggestion):
```suggestion
    dockerfile: `Include Dockerfile to run nginx with ${common.docker}`,
```
Update to string based on above change to common

Code after:
You may obtain a copy of the License at
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

export default {
    dockerfile: `Include Dockerfile to run nginx with ${common.docker}`,
};
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/templates/domain_sections/restrict.vue (Vue)

Code before:
        },
        traceMethod: {
            default: false,
            enabled: true,
        },
    };

    export default {
        name: 'DomainRestrict',                                  // Component name
        display: i18n.common.restrict,                           // Display name for tab
        key: 'restrict',                                         // Key for data in parent
        delegated: delegatedFromDefaults(defaults),             // Data the parent will present here
        components: {
            PrettyCheck,
        },
        props: {
            data: Object,                                       // Data delegated back to us from parent
        },
        data () {
            return {
                i18n,
            };
        },
        computed: {
            ...computedFromDefaults(defaults, 'restrict'),    // Getters & setters for the delegated data
        },
    };
</script>


Review comment (suggestion):
```suggestion
        computed: computedFromDefaults(defaults, 'restrict'),   // Getters & setters for the delegated data
```
Can be a single line :)

Code after:
            default: false,
            enabled: true,
        },
        deleteMethod: {
            default: false,
            enabled: true,
        },
        headMethod: {
            default: false,
            enabled: true,
        },
        connectMethod: {
            default: false,
            enabled: true,
        },
        optionsMethod: {
            default: false,
            enabled: true,
        },
        traceMethod: {
            default: false,
            enabled: true,
        },
        responseCode: {
            default: 405,
            enabled: true,
        },
    };

    export default {
        name: 'DomainRestrict',                                  // Component name
        display: i18n.common.restrict,                           // Display name for tab
        key: 'restrict',                                         // Key for data in parent
        delegated: delegatedFromDefaults(defaults),             // Data the parent will present here
        components: {
            PrettyCheck,
        },
        props: {
            data: Object,                                       // Data delegated back to us from parent
        },
        data () {
            return {
                i18n,
                validResponseCode: true,
            };
        },
        computed: {
            ...computedFromDefaults(defaults, 'restrict'),    // Getters & setters for the delegated data
            hasAtLeastOneEnabled() {
                return (Object.keys(this.$props.data).filter(k => this.$props.data[k].computed && k !== 'responseCode')).length > 0;
            },
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/i18n/en/templates/domain_sections/php.js (JavaScript)

Code before:
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

export default {
    phpIsDisabled: `${common.php} is disabled.`,
    phpCannotBeEnabledWithReverseProxy: `${common.php} cannot be enabled whilst the reverse proxy is enabled.`,
    phpCannotBeEnabledWithPython: `${common.php} cannot be enabled whilst ${common.python} is enabled.`,
    enablePhp: `${common.enable} ${common.php}`,
    wordPressRules: `${common.wordPress} rules`,
    enableWordPressRules: `${common.enable} ${common.wordPress}-specific rules`,
    drupalRules: `${common.drupal} rules`,
    enableDrupalRules: `${common.enable} ${common.drupal}-specific rules`,
    magentoRules: `${common.magento} rules`,
    enableMagentoRules: `${common.enable} ${common.magento}-specific rules`,
    joomlaRules: `${common.joomla} rules`,
    enablejoomlaRules: `${common.enable} ${common.joomla}-specific rules`,
};


Review comment (suggestion):
```suggestion
    enableJoomlaRules: `${common.enable} ${common.joomla}-specific rules`,
```

Code after:
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

export default {
    phpIsDisabled: `${common.php} is disabled.`,
    phpCannotBeEnabledWithReverseProxy: `${common.php} cannot be enabled whilst the reverse proxy is enabled.`,
    phpCannotBeEnabledWithPython: `${common.php} cannot be enabled whilst ${common.python} is enabled.`,
    enablePhp: `${common.enable} ${common.php}`,
    wordPressRules: `${common.wordPress} rules`,
    enableWordPressRules: `${common.enable} ${common.wordPress}-specific rules`,
    drupalRules: `${common.drupal} rules`,
    enableDrupalRules: `${common.enable} ${common.drupal}-specific rules`,
    magentoRules: `${common.magento} rules`,
    enableMagentoRules: `${common.enable} ${common.magento}-specific rules`,
    joomlaRules: `${common.joomla} rules`,
    enableJoomlaRules: `${common.enable} ${common.joomla}-specific rules`,
};
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/i18n/zh-tw/templates/global_sections/docker.js (JavaScript)

Code before:
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

const docker = 'Docker';
const dockerfile = 'Dockerfile';

export default {
    docker,
    dockerfile,
    dockerCompose: `${docker} 編排服務`,
    applyDockerTweaks: `應用${docker}調整`,
    applyDockerTweaksForNginx: `為使用${docker}運行${common.nginx}進行配寘調整。`,
    applyDockerTweaksExplainer: `將${common.nginx}用戶更新為<code class=“slim”>nginx</code>，將pid更新為<code class=“slim”>/var/run/nginx.pid</code>`,
    includeDockerfile: `生成${dockerfile}運行${common.nginx}與${docker}`,
    includeDockerCompose: `生成docker-compose.yaml來運行${common.nginx} docker-compose`,
};


Review comment (suggestion):
```suggestion
    applyDockerTweaksExplainer: `將${common.nginx}用戶更新為<code class="slim">nginx</code>，將pid更新為<code class="slim">/var/run/nginx.pid</code>`,
```
Needs normal quotes for the HTML

Code after:
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import common from '../../common';

const docker = 'Docker';
const dockerfile = 'Dockerfile';

export default {
    docker,
    dockerfile,
    dockerCompose: `${docker} 編排服務`,
    applyDockerTweaks: `應用${docker}調整`,
    applyDockerTweaksForNginx: `為使用${docker}運行${common.nginx}進行配寘調整。`,
    applyDockerTweaksExplainer: `將${common.nginx}用戶更新為<code class="slim">nginx</code>，將pid更新為<code class="slim">/var/run/nginx.pid</code>`,
    includeDockerfile: `生成${dockerfile}運行${common.nginx}與${docker}`,
    includeDockerCompose: `生成docker-compose.yaml來運行${common.nginx} docker-compose`,
};
Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/templates/domain_sections/https.vue (Vue)

Code before:
            default: true,
            enabled: true,
        },
        http3: {
            default: false,
            enabled: true,
        },
        portReuse: {
            default: true,
            enabled: false,
        },
        forceHttps: {
            default: true,
            enabled: true,
        },
        hsts: {
            default: true,
            enabled: true,
        },
        hstsSubdomains: {
            default: true,
            enabled: true,
        },
        hstsPreload: {
            default: false,
            enabled: true,
        },
        certType: {
            default: 'letsEncrypt',
            options: {
                letsEncrypt: 'common.letsEncrypt', // i18n key
                custom: 'templates.domainSections.https.customCertificate', // i18n key
            },
            enabled: true,
        },
        letsEncryptEmail: {
            default: '',
            computed: 'info@example.com', // No default value, but a default computed
            enabled: true,
        },
        sslCertificate: {
            default: '',
            enabled: false,
        },
        sslCertificateKey: {
            default: '',
            enabled: false,
        },
    };

    export default {

Review comment (suggestion):
```suggestion
            default: false,
```
We probably don't want reuseport to be on by default

Code after:
        </template>
    </div>
</template>

<script>
    import PrettyCheck from 'pretty-checkbox-vue/check';
    import PrettyRadio from 'pretty-checkbox-vue/radio';
    import ExternalLink from 'do-vue/src/templates/external_link';
    import delegatedFromDefaults from '../../util/delegated_from_defaults';
    import computedFromDefaults from '../../util/computed_from_defaults';

    const defaults = {
        https: {
            default: true,
            enabled: true,
        },
        http2: {
            default: true,
            enabled: true,
        },
        http3: {
            default: false,
            enabled: true,
        },
        portReuse: {
            default: true,
            enabled: false,
        },
        forceHttps: {
            default: true,
            enabled: true,
        },
        hsts: {
            default: true,
            enabled: true,
        },
        hstsSubdomains: {
            default: true,
            enabled: true,
        },
        hstsPreload: {
            default: false,
            enabled: true,
        },
        certType: {
            default: 'letsEncrypt',
            options: {
                letsEncrypt: 'common.letsEncrypt', // i18n key
                custom: 'templates.domainSections.https.customCertificate', // i18n key
            },
            enabled: true,