Skip to content

Commit

Permalink
Fixing sonar findings
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Aug 23, 2023
1 parent 6fdf1cf commit 2b8ddfd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static List<String> asStringList(Object value) {
return Collections.emptyList();
}
List<String> result = new ArrayList<>();
if (value instanceof Iterable iterable) {
if (value instanceof Iterable<?> iterable) {
iterable.forEach(item -> result.addAll(asStringList(item)));
} else {
result.add(value.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public String getProperty(final String key) {
* "yaml", empty Optional otherwise.
*/
public static Optional<YamlConfigurationProvider> createFromFile(FileLoader source) {
if (null == source || isEmpty(source.getFileName().getOriginalName())) {
if ((null == source) || isEmpty(source.getFileName().getOriginalName())) {
log.debug("Nothing to load found");
return Optional.empty();
}
Expand All @@ -179,7 +179,7 @@ public static Optional<YamlConfigurationProvider> createFromFile(FileLoader sour
* "yaml", empty Optional otherwise.
*/
public static Optional<YamlConfigurationProvider> createFromFile(FileConfigurationSource source) {
if (null == source || isEmpty(source.getPath())) {
if ((null == source) || isEmpty(source.getPath())) {
log.debug("Nothing to load found");
return Optional.empty();
}
Expand Down Expand Up @@ -269,7 +269,7 @@ private static void buildFlattenedMap(final Map<String, Object> result, final Ma
@SuppressWarnings("unchecked")
final var map = (Map<String, Object>) value;
buildFlattenedMap(result, map, key);
} else if (value instanceof Collection collection) {
} else if (value instanceof Collection<?> collection) {
var count = 0;
for (final Object object : collection) {
buildFlattenedMap(result, Collections.singletonMap("[" + count + "]", object), key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public void filter(final ClientRequestContext reqContext) throws IOException {

var body = "";
if (reqContext.hasEntity()) {
if (reqContext.getEntity() instanceof Form) {
body = ((Form) reqContext.getEntity()).asMap().toString();
if (reqContext.getEntity() instanceof Form form) {
body = form.asMap().toString();
} else {
body = reqContext.getEntity().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ public SortedSet<MetricID> getMetricIDs() {
public SortedMap<MetricID, Gauge> getGauges() {
final SortedMap<MetricID, Gauge> result = new TreeMap<>();
for (final Map.Entry<MetricID, Metric> entry : metricMap.entrySet()) {
if (entry.getValue() instanceof Gauge) {
result.put(entry.getKey(), (Gauge) entry.getValue());
if (entry.getValue() instanceof Gauge gauge) {
result.put(entry.getKey(), gauge);
}
}
return result;
Expand Down Expand Up @@ -525,8 +525,8 @@ public SortedMap<MetricID, Meter> getMeters(final MetricFilter filter) {
public SortedMap<MetricID, Timer> getTimers() {
final SortedMap<MetricID, Timer> out = new TreeMap<>();
for (final Map.Entry<MetricID, Metric> entry : metricMap.entrySet()) {
if (entry.getValue() instanceof Timer) {
out.put(entry.getKey(), (Timer) entry.getValue());
if (entry.getValue() instanceof Timer timer) {
out.put(entry.getKey(), timer);
}
}
return out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
*
* @author Sven Haag
*/
final public class PropertiesDefaultConfigSource extends PropertiesConfigSource {
public final class PropertiesDefaultConfigSource extends PropertiesConfigSource {

public static final String META_INF_LOCATION = "META-INF/microprofile-config.properties";
@SuppressWarnings("java:S1075") // owolff: the delimiter is correct for classpath-resources
public static final String CLASSPATH_LOCATION = FileTypePrefix.CLASSPATH.getPrefix() + "/" + META_INF_LOCATION;

/**
Expand Down

0 comments on commit 2b8ddfd

Please sign in to comment.