Skip to content

Commit ba1becf

Browse files
authored
Merge pull request #895 from oracle/sonar
Address CheckStyle and Sonar issues
2 parents 24f9729 + 86bddfc commit ba1becf

File tree

113 files changed

+1056
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1056
-680
lines changed

docs/domains/Domain.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
]
178178
},
179179
"image": {
180-
"description": "The Weblogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3.",
180+
"description": "The WebLogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3.",
181181
"type": "string"
182182
},
183183
"imagePullPolicy": {
@@ -239,7 +239,7 @@
239239
"$ref": "#/definitions/KubernetesResource"
240240
},
241241
"domainHome": {
242-
"description": "The folder for the Weblogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
242+
"description": "The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
243243
"type": "string"
244244
},
245245
"logHomeEnabled": {

docs/domains/Domain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ DomainSpec is a description of a domain.
2020
| clusters | array of [Cluster](#cluster) | Configuration for the clusters. |
2121
| configOverrides | string | The name of the config map for optional WebLogic configuration overrides. |
2222
| configOverrideSecrets | array of string | A list of names of the secrets for optional WebLogic configuration overrides. |
23-
| domainHome | string | The folder for the Weblogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true |
23+
| domainHome | string | The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true |
2424
| domainHomeInImage | boolean | True if this domain's home is defined in the docker image for the domain. Defaults to true. |
2525
| domainUID | string | Domain unique identifier. Must be unique across the Kubernetes cluster. Not required. Defaults to the value of metadata.name |
26-
| image | string | The Weblogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3. |
26+
| image | string | The WebLogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3. |
2727
| imagePullPolicy | string | The image pull policy for the WebLogic Docker image. Legal values are Always, Never and IfNotPresent. Defaults to Always if image ends in :latest, IfNotPresent otherwise. |
2828
| imagePullSecrets | array of [Local Object Reference](k8s1.9.0.md#local-object-reference) | A list of image pull secrets for the WebLogic Docker image. |
2929
| includeServerOutInPodLog | boolean | If true (the default), the server .out file will be included in the pod's stdout. |

docs/domains/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@
10971097
]
10981098
},
10991099
"image": {
1100-
"description": "The Weblogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3.",
1100+
"description": "The WebLogic Docker image; required when domainHomeInImage is true; otherwise, defaults to store/oracle/weblogic:12.2.1.3.",
11011101
"type": "string"
11021102
},
11031103
"imagePullPolicy": {
@@ -1159,7 +1159,7 @@
11591159
"$ref": "#/definitions/KubernetesResource"
11601160
},
11611161
"domainHome": {
1162-
"description": "The folder for the Weblogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
1162+
"description": "The folder for the WebLogic Domain. Not required. Defaults to /shared/domains/domains/domainUID if domainHomeInImage is false Defaults to /u01/oracle/user_projects/domains/ if domainHomeInImage is true",
11631163
"type": "string"
11641164
},
11651165
"logHomeEnabled": {

json-schema-maven-plugin/src/main/java/oracle/kubernetes/json/mojo/Main.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface Main {
2020
void setKubernetesVersion(String kubernetesVersion) throws IOException;
2121

2222
/**
23-
* Defines an external schema URL to be used for object definitions
23+
* Defines an external schema URL to be used for object definitions.
2424
*
2525
* @param schemaURL the schema URL
2626
* @param cacheUrl a file url specifying a local cache of the schema
@@ -38,7 +38,7 @@ public interface Main {
3838

3939
/**
4040
* Specifies that the "additionalProperties" property will be added to the schema for each object
41-
* and set to false, to forbid any unspecified properties
41+
* and set to false, to forbid any unspecified properties.
4242
*
4343
* @param includeAdditionalProperties true if unspecified properties should cause validation to
4444
* fail
@@ -55,7 +55,7 @@ public interface Main {
5555
void setSupportObjectReferences(boolean supportObjectReferences);
5656

5757
/**
58-
* Specify the classpath for the class whose schema is to be built
58+
* Specify the classpath for the class whose schema is to be built.
5959
*
6060
* @param classpathElements a list of elements of a classpath
6161
*/
@@ -82,9 +82,9 @@ Map<String, Object> generateSchema(String className, File outputFile)
8282
/**
8383
* Generates markdown for the newly-generated schema to the specified output file.
8484
*
85-
* @param rootName
85+
* @param rootName Root name
8686
* @param outputFile the file to generate
87-
* @param schema
87+
* @param schema Schema
8888
* @throws MojoExecutionException if an exception occurred during the markdown generation
8989
*/
9090
void generateMarkdown(String rootName, File outputFile, Map<String, Object> schema)

json-schema/src/main/java/oracle/kubernetes/json/Description.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@
1515
@Retention(RetentionPolicy.RUNTIME)
1616
@Target({TYPE, FIELD})
1717
public @interface Description {
18+
19+
/**
20+
* Description value.
21+
*
22+
* @return description value
23+
*/
1824
String value();
1925
}

json-schema/src/main/java/oracle/kubernetes/json/EnumClass.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@
1414
@Retention(RetentionPolicy.RUNTIME)
1515
@Target(FIELD)
1616
public @interface EnumClass {
17+
18+
/**
19+
* Enum class.
20+
*
21+
* @return enum class
22+
*/
1723
Class<? extends java.lang.Enum> value();
1824

25+
/**
26+
* Enum qualifier.
27+
*
28+
* @return enum qualifier
29+
*/
1930
String qualifier() default "";
2031
}

json-schema/src/main/java/oracle/kubernetes/json/Pattern.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@
1414
@Retention(RetentionPolicy.RUNTIME)
1515
@Target(FIELD)
1616
public @interface Pattern {
17+
18+
/**
19+
* Pattern value.
20+
*
21+
* @return pattern value
22+
*/
1723
String value();
1824
}

json-schema/src/main/java/oracle/kubernetes/json/Range.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@
1414
@Retention(RetentionPolicy.RUNTIME)
1515
@Target(FIELD)
1616
public @interface Range {
17+
18+
/**
19+
* Minimum value.
20+
*
21+
* @return minimum value
22+
*/
1723
int minimum() default Integer.MIN_VALUE;
1824

25+
/**
26+
* Maximum value.
27+
*
28+
* @return maximum value
29+
*/
1930
int maximum() default Integer.MAX_VALUE;
2031
}

json-schema/src/main/java/oracle/kubernetes/json/SchemaGenerator.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class SchemaGenerator {
6060
private boolean includeSchemaReference = true;
6161

6262
/**
63-
* Returns a pretty-printed string corresponding to a generated schema
63+
* Returns a pretty-printed string corresponding to a generated schema.
6464
*
6565
* @param schema a schema generated by a call to #generate
6666
* @return a string version of the schema
@@ -83,6 +83,13 @@ public void useKubernetesVersion(String version) throws IOException {
8383
addExternalSchema(reference.getKubernetesSchemaUrl(), cacheUrl);
8484
}
8585

86+
/**
87+
* Adds external schema.
88+
*
89+
* @param schemaUrl Schema URL
90+
* @param cacheUrl Cached URL
91+
* @throws IOException IO exception
92+
*/
8693
public void addExternalSchema(URL schemaUrl, URL cacheUrl) throws IOException {
8794
Map<String, Map<String, Object>> objectObjectMap = loadCachedSchema(cacheUrl);
8895
Map<String, Object> definitions = objectObjectMap.get("definitions");
@@ -118,7 +125,7 @@ private boolean isDeprecated(Object description) {
118125
}
119126

120127
/**
121-
* Specifies whether deprecated fields should be included in the schema
128+
* Specifies whether deprecated fields should be included in the schema.
122129
*
123130
* @param includeDeprecated true to include deprecated fields. Defaults to false.
124131
*/
@@ -128,7 +135,7 @@ public void setIncludeDeprecated(boolean includeDeprecated) {
128135

129136
/**
130137
* Specifies whether the "additionalProperties" property will be specified to forbid properties
131-
* not in the schema
138+
* not in the schema.
132139
*
133140
* @param includeAdditionalProperties true to forbid unknown properties
134141
*/
@@ -147,7 +154,7 @@ public void setSupportObjectReferences(boolean supportObjectReferences) {
147154
}
148155

149156
/**
150-
* Specifies whether top-level schema reference is included
157+
* Specifies whether top-level schema reference is included.
151158
*
152159
* @param includeSchemaReference true to include schema reference
153160
*/
@@ -158,16 +165,16 @@ public void setIncludeSchemaReference(boolean includeSchemaReference) {
158165
/**
159166
* Generates an object representing a JSON schema for the specified class.
160167
*
161-
* @param aClass the class for which the schema should be generated
168+
* @param someClass the class for which the schema should be generated
162169
* @return a map of maps, representing the computed JSON
163170
*/
164-
public Map<String, Object> generate(Class aClass) {
171+
public Map<String, Object> generate(Class someClass) {
165172
Map<String, Object> result = new HashMap<>();
166173

167174
if (includeSchemaReference) {
168175
result.put("$schema", JSON_SCHEMA_REFERENCE);
169176
}
170-
generateObjectTypeIn(result, aClass);
177+
generateObjectTypeIn(result, someClass);
171178
if (!definedObjects.isEmpty()) {
172179
Map<String, Object> definitions = new TreeMap<>();
173180
result.put("definitions", definitions);
@@ -239,6 +246,11 @@ private String getDescription(Field field) {
239246
return description != null ? description.value() : null;
240247
}
241248

249+
private String getDescription(Class<?> someClass) {
250+
Description description = someClass.getAnnotation(Description.class);
251+
return description != null ? description.value() : null;
252+
}
253+
242254
private void addStringRestrictions(Map<String, Object> result, Field field) {
243255
Class<? extends Enum> enumClass = getEnumClass(field);
244256
if (enumClass != null) addEnumValues(result, enumClass, getEnumQualifier(field));
@@ -426,11 +438,6 @@ private void generateObjectTypeIn(Map<String, Object> result, Class<?> type) {
426438
}
427439
}
428440

429-
private String getDescription(Class<?> aClass) {
430-
Description description = aClass.getAnnotation(Description.class);
431-
return description != null ? description.value() : null;
432-
}
433-
434441
private Collection<Field> getPropertyFields(Class<?> type) {
435442
Set<Field> result = new HashSet<>();
436443
for (Class<?> cl = type; cl != null && !cl.equals(Object.class); cl = cl.getSuperclass())

json-schema/src/main/java/oracle/kubernetes/json/YamlDocGenerator.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,23 @@ public YamlDocGenerator(Map<String, Object> schema) {
3030
this.schema = schema;
3131
}
3232

33+
/**
34+
* Generate YAML documentation.
35+
*
36+
* @param schemaName Schema name
37+
* @return documentation
38+
*/
3339
public String generate(String schemaName) {
3440
return generate(schemaName, schema);
3541
}
3642

43+
/**
44+
* Generate YAML documentation.
45+
*
46+
* @param reference Reference
47+
* @param schema Schema
48+
* @return documentation
49+
*/
3750
public String generate(String reference, Map<String, Object> schema) {
3851
referencesNeeded.remove(reference);
3952
StringBuilder sb = new StringBuilder("### ");
@@ -50,6 +63,13 @@ private String getDescription(Map<String, Object> schema) {
5063
return (String) schema.get("description");
5164
}
5265

66+
private String getDescription(String fieldName, Map<String, Object> subSchema) {
67+
if (subSchema == null) return "";
68+
Map<String, Object> fieldMap = subMap(subSchema, fieldName);
69+
String rawDescription = (String) fieldMap.get("description");
70+
return rawDescription == null ? "" : rawDescription.replace("\n", "<br/>");
71+
}
72+
5373
private void generateForDefinition(StringBuilder sb, String reference) {
5474
Map<String, Object> definitions = subMap(schema, "definitions");
5575
Map<String, Object> definition = subMap(definitions, reference);
@@ -99,13 +119,12 @@ private String getType(String fieldName, Map<String, Object> subSchema) {
99119
return type.getString();
100120
}
101121

102-
private String getDescription(String fieldName, Map<String, Object> subSchema) {
103-
if (subSchema == null) return "";
104-
Map<String, Object> fieldMap = subMap(subSchema, fieldName);
105-
String rawDescription = (String) fieldMap.get("description");
106-
return rawDescription == null ? "" : rawDescription.replace("\n", "<br/>");
107-
}
108-
122+
/**
123+
* Assigns kubernetes version to use.
124+
*
125+
* @param k8sVersion Kubernetes version
126+
* @throws IOException IO exception
127+
*/
109128
public void useKubernetesVersion(String k8sVersion) throws IOException {
110129
kubernetesReference = KubernetesSchemaReference.create(k8sVersion);
111130
URL cacheUrl = kubernetesReference.getKubernetesSchemaCacheUrl();
@@ -273,7 +292,7 @@ private Map<String, Object> subMap(Map<String, Object> schemaMap, String name) {
273292
return (Map<String, Object>) Optional.ofNullable(schemaMap.get(name)).orElse(new HashMap<>());
274293
}
275294

276-
private String emptyIfNull(String aString) {
277-
return aString == null ? "" : aString;
295+
private String emptyIfNull(String someString) {
296+
return someString == null ? "" : someString;
278297
}
279298
}

0 commit comments

Comments
 (0)