Skip to content

Remove redundant and outdated validation from depends extraction regex #124

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 27, 2022
Merged

Remove redundant and outdated validation from depends extraction regex #124

merged 2 commits into from
May 27, 2022

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 26, 2022

Library dependencies may be specified in the depends field of the library.properties library metadata file.

A regular expression is used to separate the library dependency name and optional version constraint from each element of the field during parsing of the file to add new releases to the DB.

This regular expression is also configured to validate the library name as well as some minimal attempt at validating the version constraint.

The latter is not compatible with the recently introduced more powerful constraint syntax.

This project was originally solely responsible for validation of the library releases. Since that time, a dedicated tool was created for this purpose: Arduino Lint.

Since Arduino Lint already fully validates each release, including the depends field contents, and the DB entries are only added for releases which have passed that check, the validation via the extraction regular expression is superfluous and only increases the maintenance burden for no benefit.

The regular expression is now configured for its a single purpose: extracting the components of the depends field elements. This can be done via a more simple regular expression, given that the data being parsed has already been validated by Arduino Lint.

per1234 added 2 commits May 26, 2022 07:39
Library dependencies may be specified in the `depends` field of the library.properties library metadata file.

A regular expression is used to separate the dependency name and optional version constraint from each element of the
field during parsing of the file to add new releases to the DB.

The supported version constraint syntax for use in this field was recently expanded. This included adding support for
grouping constraints using parentheses. The previous regular expression did not allow parentheses in the constraint,
which unnecessarily limited the capabilities of the library dependencies system.

The updated regular expression will match against invalid constraint syntax (e.g., `depends=FooLib (>1.2.3)(<2.3.4)`).
However, this is not a problem because the syntax is already validated separately via the dedicated tool for such things:
Arduino Lint. The DB update only occurs after the release has passed full validation by Arduino Lint.

Given the data which has already been validated by Arduino Lint, this new regular expression will reliably extract the
dependency components from the field.
Library dependencies may be specified in the `depends` field of the library.properties library metadata file.

A regular expression is used to separate the dependency name and optional version constraint from each element of the
field during parsing of the file to add new releases to the DB.

A check is done to make sure the specified library names have a valid format. This project was originally solely
responsible for such checks. Since that time, a dedicated tool was created for validation of the library releases:
Arduino Lint.

Since Arduino Lint already does this check, and the DB entries are only added for releases which pass that check, the
validation via the extraction regular expression is superfluous and only increases the maintenance burden for no
benefit.

The regular expression has a single purpose: extracting the components of the depends field elements. This more simple
regular expression will accomplish that, given the data which has already been validated by Arduino Lint.
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 26, 2022
@per1234 per1234 requested review from cmaglie and umbynos May 26, 2022 14:58
@per1234 per1234 self-assigned this May 26, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #124 (a545bb1) into main (11de62f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #124   +/-   ##
=======================================
  Coverage   41.58%   41.58%           
=======================================
  Files          26       26           
  Lines        1450     1450           
=======================================
  Hits          603      603           
  Misses        790      790           
  Partials       57       57           
Flag Coverage Δ
unit 41.58% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/libraries/db/library.go 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1386c82...a545bb1. Read the comment docs.

@per1234 per1234 merged commit 4fd9cf7 into arduino:main May 27, 2022
@per1234 per1234 deleted the remove-depend-validation branch May 27, 2022 10:04
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