Skip to content

Commit bce5030

Browse files
committed
address copilot review
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
1 parent 94a1e60 commit bce5030

6 files changed

Lines changed: 11 additions & 9 deletions

File tree

bundles/org.openhab.io.yamlcomposer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For a general introduction to YAML, see [YAML Basics](doc/basics.md).
3737

3838
## Packaging Example
3939

40-
**CONF/yamlcompose/LivingRoom.yaml:**
40+
**CONF/yamlcomposer/LivingRoom.yaml:**
4141

4242
```yaml
4343
version: 1
@@ -62,7 +62,7 @@ packages:
6262
<<: *LIGHT_VARS
6363
```
6464
65-
**CONF/yamlcompose/pkg/zigbee_light.inc.yaml:**
65+
**CONF/yamlcomposer/pkg/zigbee_light.inc.yaml:**
6666
6767
```yaml
6868
# This is the package file, i.e. the template for a zigbee light

bundles/org.openhab.io.yamlcomposer/doc/include.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`!include` inserts the referenced file or structure exactly at the position where the include appears.
44

5-
YAML Composer supports including external YAML files to facilitate modular, reusable, and maintainable configurations.****
5+
YAML Composer supports including external YAML files to facilitate modular, reusable, and maintainable configurations.
66
This is especially useful for modular reuse, creating device [packages](packages.md), or separating concerns across multiple files.
77

88
[[toc]]

bundles/org.openhab.io.yamlcomposer/doc/merge-keys.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ server:
161161
port: 8080
162162
<<: !if
163163
if: is_prod
164-
value: { ssl: true, cache: true }
164+
then: { ssl: true, cache: true }
165165
```
166166

167167
### Substitution

bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/core/SourceLocator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package org.openhab.io.yamlcomposer.internal.core;
1414

1515
import java.io.ByteArrayInputStream;
16+
import java.nio.charset.StandardCharsets;
1617
import java.util.Scanner;
1718

1819
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -56,7 +57,7 @@ public FilePosition findPosition(String... keys) {
5657
return FilePosition.empty();
5758
}
5859

59-
try (Scanner scanner = new Scanner(new ByteArrayInputStream(yamlBytes))) {
60+
try (Scanner scanner = new Scanner(new ByteArrayInputStream(yamlBytes), StandardCharsets.UTF_8)) {
6061
int lineNumber = 1;
6162
int keyIndex = 0;
6263

bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/expression/filters/DigFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* Custom Jinjava filter to dig into nested maps/lists.
26-
* Supports negative indices for lists to acess elements from the end.
26+
* Supports negative indices for lists to access elements from the end.
2727
*
2828
* Usage: variable|dig("key1", "key2", 0) to access variable["key1"]["key2"][0]
2929
* Also supports dot-notation in a single argument: variable|dig("key1.key2.0")

bundles/org.openhab.io.yamlcomposer/src/main/java/org/openhab/io/yamlcomposer/internal/processors/FragmentUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public static record Parameters(@Nullable String name, Map<String, @Nullable Obj
4747
}
4848

4949
private static @Nullable Parameters parseMapParameters(Map<?, ?> paramsMap, String objectName) {
50-
@Nullable
51-
String name = (String) paramsMap.get(objectName);
50+
if (!(paramsMap.get(objectName) instanceof String name)) {
51+
return null;
52+
}
5253
if (!(paramsMap.get("vars") instanceof Map<?, ?> varsMap)) {
5354
return new Parameters(name, Map.of());
5455
}
@@ -95,7 +96,7 @@ private static Parameters parseStringParameters(String input, String objectName)
9596
return new Parameters(finalName, vars);
9697
}
9798

98-
private static void parsePair(String input, int start, int end, Map<String, Object> vars) {
99+
private static void parsePair(String input, int start, int end, Map<String, @Nullable Object> vars) {
99100
int eq = input.indexOf('=', start);
100101

101102
// If eq is outside our current segment, there is no value

0 commit comments

Comments
 (0)