Skip to content

Restore normalization of library metadata #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2021
Merged

Restore normalization of library metadata #34

merged 2 commits into from
May 25, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 22, 2021

When the code was switched to using Arduino Lint for release validation (#18), the metadata.Validate() function was removed.
At a closer look, it turns out that this function did normalization in addition to validation of the metadata:

Make version semver-compliant

Arduino Lint's rule LP021 encourages semver compliance. However, violation of this rule in the mode used by the engine only results in a warning, so normalization is still needed.

Arduino Lint's rule LP020 enforces compliance with "relaxed semver", so it's only the normalization aspect that need be restored.

Populate maintainer field with author value if empty

Arduino Lint's rule LP026 requires the maintainer field to be defined and non-empty, and will cause any library release in violation of this rule to be rejected by the engine, so there is no need to restore the normalization code for this field.

Change invalid category value to "uncategorized"

Arduino Lint's rule LP038 encourages the use of valid categories. However, violation of this rule in the mode used by the engine only results in a warning, so normalization is still needed.


Rather than using bespoke code for normalization as was done before, I have utilized the same code as in Arduino CLI:

This introduces some new dependencies to the tool.

@per1234 per1234 added type: bug topic: code Related to content of the project itself labels May 22, 2021
per1234 added 2 commits May 25, 2021 00:35
When the code was switched to using Arduino Lint for release validation, the `metadata.Validate()` function was removed.
At a closer look, it turns out that this function did normalization in addition to validation of the metadata. One such
normalization was to convert the "relaxed semver" version format which is allowed to be used in Arduino Library metadata
to be compliant with the standardized "semver" version specification, which is used in the Library Manager index.

Here, the version normalization is restored. Rather than using bespoke code for this purpose as before, the
`go.bug.st/relaxed-semver` package is used, as in Arduino CLI and Arduino Lint. This will provide consistency and reduce
maintenance burden.
When the code was switched to using Arduino Lint for release validation, the `metadata.Validate()` function was removed.
At a closer look, it turns out that this function did normalization in addition to validation of the metadata. One such
normalization was to restrict the `category` field value in the library metadata to the allowed values listed in the
Arduino Library Specification, falling back to "Uncategorized" in the event the library has an unsupported value.

Here, the category normalization is restored. Rather than using bespoke code to define the valid categories as before, the
`github.com/arduino/arduino-cli/arduino/libraries` package is used, as in Arduino CLI. This will provide consistency and
reduce maintenance burden.
@per1234 per1234 merged commit b1af57e into arduino:main May 25, 2021
@per1234 per1234 deleted the normalize-metadata branch May 25, 2021 07:37
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants