Skip to content

Commit 3ca6bc2

Browse files
authored
[sonar] Java 11, use -nsu, exclude maven/online projects (#7459)
1 parent 35d4272 commit 3ca6bc2

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.github/workflows/sonar.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v1
16-
- name: Set up JDK 1.8
16+
- name: Set up JDK 11
1717
uses: actions/setup-java@v1
1818
with:
19-
java-version: 1.8
19+
java-version: 11
2020
- name: Compile with Maven
21-
run: mvn clean package jacoco:report
21+
run: mvn -B -q clean install jacoco:report
2222
- name: Jacoco Aggregate
2323
run: mvn jacoco:report-aggregate
2424
- name: Publish to Sonar
25-
run: mvn -B -q sonar:sonar -Dsonar.projectKey=OpenAPITools_openapi-generator -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_LOGIN }} -Dsonar.branch.name=${GITHUB_REF##*/}
25+
run: mvn -B -q -nsu sonar:sonar -Dsonar.projectKey=OpenAPITools_openapi-generator -Dsonar.organization=openapitools -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_LOGIN }} -Dsonar.branch.name=${GITHUB_REF##*/}

modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/ConfigHelp.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@
3939
import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4;
4040
import static org.apache.commons.lang3.StringUtils.isEmpty;
4141

42-
@SuppressWarnings({"unused","java:S106"})
42+
@SuppressWarnings({"unused","java:S106", "java:S1192"})
4343
@Command(name = "config-help", description = "Config help for chosen lang")
4444
public class ConfigHelp extends OpenApiGeneratorCommand {
4545

46-
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
46+
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigHelp.class);
4747

4848
private static final String FORMAT_TEXT = "text";
4949
private static final String FORMAT_MARKDOWN = "markdown";
5050
private static final String FORMAT_YAMLSAMPLE = "yamlsample";
51+
private static final int FEATURE_SET_DISPLAY_WIDTH= 20;
5152

5253
@Option(name = {"-g",
5354
"--generator-name"}, title = "generator name", description = "generator to get config help for")
@@ -147,7 +148,7 @@ public void execute() {
147148
LOGGER.error("[error] Check the spelling of the generator's name and try again.");
148149
System.exit(1);
149150
} catch (IOException e) {
150-
e.printStackTrace();
151+
LOGGER.error("Unexpected error", e);
151152
}
152153
}
153154

@@ -396,7 +397,7 @@ private void generatePlainTextHelp(StringBuilder sb, CodegenConfig config) {
396397
String definedByKey = "Defined By";
397398
int maxNameLength = flattened.stream().map(FeatureSet.FeatureSetFlattened::getFeatureName).mapToInt(String::length).max().orElse(nameKey.length());
398399
int maxSupportedLength = supportedKey.length();
399-
int definedInLength = 20;
400+
int definedInLength = FEATURE_SET_DISPLAY_WIDTH;
400401
String format = "%-" + maxNameLength + "s\t%-" + maxSupportedLength + "s\t%-" + definedInLength + "s";
401402

402403
flattened.forEach(featureSet -> {

modules/openapi-generator-maven-plugin/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<description>maven plugin to build modules from OpenAPI Generator</description>
1616
<properties>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<sonar.exclusions>**/src/main/java/org/openapitools/codegen/plugin/**/*</sonar.exclusions>
1819
</properties>
1920
<dependencies>
2021
<dependency>

modules/openapi-generator-online/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<springfox-version>3.0.0</springfox-version>
2020
<junit-version>4.13</junit-version>
2121
<jackson-version>2.10.2</jackson-version>
22+
<sonar.exclusions>**/org/openapitools/codegen/online/**/*</sonar.exclusions>
2223
</properties>
2324
<dependencyManagement>
2425
<dependencies>

0 commit comments

Comments
 (0)