gazebosim / gazebosim/sdformat

Enforce required elements

Open
#1,002 2 comments 0 reactions 0 assignees View on GitHub
documentation help wanted
Dominant language
C++
Stars
216
Forks
125
Avg merge
1d 14h
Merged PRs (30d)
14

Description

The "required" field of the spec accepts 5 different values. They're not documented very prominently (#496 ), but there's a definition for them here:

https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/include/sdf/Element.hh#L109-L113

### Current enforcement

Looking through the code, I found some places that make use of them:

1. Deprecated elements (`-1`) issue errors:

https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1491-L1495

1. Elements that must have exactly `1` or must have at least one `+` issue errors:

https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1504-L1509
https://github.com/ignitionrobotics/sdformat/blob/12e77821af7c2810c4d9d532ee8cb833cbb8e318/src/parser.cc#L1903

But that 's only part of it.

### Missing enforcement

Should these also cause errors (they're all currently valid according to `ign sdf -k`)?

---

More than one element when it should have exactly one (`1`):

SDF

```

a
b

```

---

The difference between `0` and `*` should be clarified in the documentation and also in the enforcement. I assume that the existence of `*` implies that `0` means "either none or one". In that case, this should be an error:

SDF

```

```

Contributor guide

Open the contributing guide

Research direction

Start with the required-value definitions in include/sdf/Element.hh and the existing checks in src/parser.cc around the cited lines. Reproduce the examples with `ign sdf -k`, then inspect the parser tests and documentation related to required elements. Done means the intended `1`, `0`, and `*` semantics are documented and consistently enforced with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.