diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2023-01-06 17:11:40 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-01-10 20:03:01 +0000 |
commit | 8868a5ff310c74f44f2c94e46ba31065017f50b4 (patch) | |
tree | 510cd149dfc10810e2eadf311e0305eefe3cec9a /server | |
parent | 18f91c25d369917f3a99841f6bb31b94a02467fc (diff) | |
download | sonarqube-8868a5ff310c74f44f2c94e46ba31065017f50b4.tar.gz sonarqube-8868a5ff310c74f44f2c94e46ba31065017f50b4.zip |
[NO-JIRA] Remove reported code smells about text blocks
Diffstat (limited to 'server')
6 files changed, 34 insertions, 24 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java index 89d289724a0..64b00823c73 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java @@ -30,11 +30,13 @@ import java.util.stream.Collectors; import org.sonar.process.Props; public class EsJvmOptions extends JvmOptions<EsJvmOptions> { - private static final String ELASTICSEARCH_JVM_OPTIONS_HEADER = "# This file has been automatically generated by SonarQube during startup.\n" + - "# Please use sonar.search.javaOpts and/or sonar.search.javaAdditionalOpts in sonar.properties to specify jvm options for Elasticsearch\n" + - "\n" + - "# DO NOT EDIT THIS FILE\n" + - "\n"; + private static final String ELASTICSEARCH_JVM_OPTIONS_HEADER = """ + # This file has been automatically generated by SonarQube during startup. + # Please use sonar.search.javaOpts and/or sonar.search.javaAdditionalOpts in sonar.properties to specify jvm options for Elasticsearch + + # DO NOT EDIT THIS FILE + + """; public EsJvmOptions(Props props, File tmpDir) { super(mandatoryOptions(tmpDir, props)); diff --git a/server/sonar-main/src/main/java/org/sonar/application/es/EsYmlSettings.java b/server/sonar-main/src/main/java/org/sonar/application/es/EsYmlSettings.java index c18e78f3fcb..0b1535edbb4 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/es/EsYmlSettings.java +++ b/server/sonar-main/src/main/java/org/sonar/application/es/EsYmlSettings.java @@ -30,10 +30,12 @@ import org.yaml.snakeyaml.Yaml; import static org.yaml.snakeyaml.DumperOptions.FlowStyle.BLOCK; public class EsYmlSettings { - private static final String ELASTICSEARCH_YML_OPTIONS_HEADER = "# This file has been automatically generated by SonarQube during startup.\n" + - "\n" + - "# DO NOT EDIT THIS FILE\n" + - "\n"; + private static final String ELASTICSEARCH_YML_OPTIONS_HEADER = """ + # This file has been automatically generated by SonarQube during startup. + + # DO NOT EDIT THIS FILE + + """; private final Map<String, String> elasticsearchSettings; diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java index 4dca3247173..30c1284c18c 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java @@ -40,12 +40,13 @@ public class EsYmlSettingsTest { new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile); assertThat(yamlFile).exists(); - assertThat(yamlFile).hasContent("# This file has been automatically generated by SonarQube during startup.\n" + - "\n" + - "# DO NOT EDIT THIS FILE\n" + - "\n" + - "{\n" + - " }"); + assertThat(yamlFile).hasContent(""" + # This file has been automatically generated by SonarQube during startup. + + # DO NOT EDIT THIS FILE + + { + }"""); } @Test diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplate.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplate.java index 927c77701b1..a9339d43154 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplate.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplate.java @@ -27,9 +27,11 @@ import org.sonar.server.issue.notification.EmailTemplate; public class DefaultAdminCredentialsVerifierNotificationTemplate implements EmailTemplate { static final String SUBJECT = "Default Administrator credentials are still used"; - static final String BODY_FORMAT = "Hello,\n\n" + - "Your SonarQube instance is still using default administrator credentials.\n" + - "Make sure to change the password for the 'admin' account or deactivate this account."; + static final String BODY_FORMAT = """ + Hello, + + Your SonarQube instance is still using default administrator credentials. + Make sure to change the password for the 'admin' account or deactivate this account."""; @Override @CheckForNull diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplateTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplateTest.java index 0e24a9fafe5..fb24d20f28d 100644 --- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplateTest.java +++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierNotificationTemplateTest.java @@ -41,9 +41,11 @@ public class DefaultAdminCredentialsVerifierNotificationTemplateTest { EmailMessage emailMessage = underTest.format(notification); assertThat(emailMessage.getSubject()).isEqualTo("Default Administrator credentials are still used"); - assertThat(emailMessage.getMessage()).isEqualTo("Hello,\n\n" + - "Your SonarQube instance is still using default administrator credentials.\n" + - "Make sure to change the password for the 'admin' account or deactivate this account."); + assertThat(emailMessage.getMessage()).isEqualTo(""" + Hello, + + Your SonarQube instance is still using default administrator credentials. + Make sure to change the password for the 'admin' account or deactivate this account."""); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/monitoring/MetricsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/monitoring/MetricsAction.java index f64e8bb2c9c..2467b944575 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/monitoring/MetricsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/monitoring/MetricsAction.java @@ -38,9 +38,10 @@ public class MetricsAction extends SafeModeMonitoringMetricAction { public void define(WebService.NewController context) { context.createAction("metrics") .setSince("9.3") - .setDescription("Return monitoring metrics in Prometheus format. \n" + - "Support content type 'text/plain' (default) and 'application/openmetrics-text'.\n" + - "this endpoint can be access using a Bearer token, that needs to be defined in sonar.properties with the 'sonar.web.systemPasscode' key.") + .setDescription(""" + Return monitoring metrics in Prometheus format.\s + Support content type 'text/plain' (default) and 'application/openmetrics-text'. + this endpoint can be access using a Bearer token, that needs to be defined in sonar.properties with the 'sonar.web.systemPasscode' key.""") .setResponseExample(getClass().getResource("monitoring-metrics.txt")) .setHandler(this); |