Skip to content

Commit e34a606

Browse files
committed
feat(256): check for inner objects
1 parent 4666ee3 commit e34a606

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

src/main/resources/org/eolang/lints/refs/base-must-be-merged.xsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
~ SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
44
~ SPDX-License-Identifier: MIT
55
-->
6-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:eo="https://www.eolang.org" id="base-must-be-merged" version="2.0">
6+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="base-must-be-merged" version="2.0">
77
<xsl:import href="/org/eolang/parser/_funcs.xsl"/>
88
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
99
<xsl:import href="/org/eolang/funcs/defect-context.xsl"/>
1010
<xsl:output encoding="UTF-8" method="xml"/>
1111
<xsl:template match="/">
1212
<defects>
1313
<xsl:for-each select="//o[not(eo:abstract(.)) and parent::o[starts-with(@base, '.')] and not(starts-with(@base, '.')) and not(text())]">
14+
<xsl:message select="."/>
1415
<defect>
1516
<xsl:variable name="line" select="eo:lineno(@line)"/>
1617
<xsl:attribute name="line">

src/main/resources/org/eolang/motives/refs/base-must-be-merged.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ conditions are met:
77
2. Attribute `@base` of parent object should start with dot
88
3. Attribute `@base` object should not start with dot
99
4. Object should not have data
10+
5. Object should not have inner objects
1011

1112
Incorrect:
1213

1314
```xml
1415
<o base=".foo">
15-
<o base=".bar">
16-
<o base="x"/>
17-
</o>
16+
<o base=".bar">
17+
<o base="x"/>
18+
</o>
1819
</o>
1920
```
2021

@@ -28,33 +29,35 @@ Correct:
2829

2930
```xml
3031
<o base=".foo">
31-
<o base=".bar"/>
32+
<o base=".bar"/>
3233
</o>
3334
```
3435

3536
Correct:
3637

3738
```xml
3839
<o base=".foo">
39-
<o/>
40+
<o/>
4041
</o>
4142
```
4243

4344
Correct:
4445

4546
```xml
4647
<o base=".foo">
47-
<o base="bar">
48-
A1-B2-C3-D4-E5
49-
</o>
48+
<o base="bar">
49+
A1-B2-C3-D4-E5
50+
</o>
5051
</o>
5152
```
5253

5354
Correct:
5455

5556
```xml
56-
<o base="foo">
57-
<o base=".bar"/>
57+
<o base=".foo">
58+
<o base="bar">
59+
<o base="baz"/>
60+
</o>
5861
</o>
5962
```
6063

src/test/resources/org/eolang/lints/packs/single/base-must-be-merged/no-merge-if-object-has-data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ document: |
99
<object>
1010
<o base=".foo">
1111
<o base="bar">
12-
A1-B2-C3-D4-E5
12+
A1-B2-C3-D4-E5
1313
</o>
1414
</o>
1515
</object>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
2+
# SPDX-License-Identifier: MIT
3+
---
4+
sheets:
5+
- /org/eolang/lints/refs/base-must-be-merged.xsl
6+
asserts:
7+
- /defects[count(defect[@severity='warning'])=0]
8+
document: |
9+
<object>
10+
<o base=".foo">
11+
<o base="bar">
12+
<o base="baz"/>
13+
</o>
14+
</o>
15+
</object>

0 commit comments

Comments
 (0)