Skip to content

feat: add IPACodesURL option to ParserConfig#352

Open
creed-bratton wants to merge 1 commit intoitalia:mainfrom
creed-bratton:ipa-codes-url-option
Open

feat: add IPACodesURL option to ParserConfig#352
creed-bratton wants to merge 1 commit intoitalia:mainfrom
creed-bratton:ipa-codes-url-option

Conversation

@creed-bratton
Copy link
Copy Markdown
Contributor

Fixes #348.

Adds ParserConfig.IPACodesURL: when set, NewParser fetches a fresh Italian IPA codes list from the given URL instead of using the embedded snapshot. The Agid export URL can be passed directly (one code per line, matches the existing embedded format).

p, err := publiccode.NewParser(publiccode.ParserConfig{
    IPACodesURL: "https://www.indicepa.gov.it/public-services/opendata-read-service.php?dstype=FS&filename=amministrazioni.txt",
})

Leave IPACodesURL empty (default) to keep using the embedded snapshot — no behaviour change for existing callers. WASM callers omit the option and continue to use the snapshot as before.

Implementation notes:

  • The validator is now per-Parser rather than a package-level global, so concurrent parsers with different code sets are safe.
  • MakeIsOrganisationURI builds its inner validator once per Parser (closure) instead of on every call to isOrganisationURI.
  • validators.New now takes the codes map; validators.DefaultIPACodes exposes the embedded set for callers that need it.

ParserConfig.IPACodesURL, when set, causes NewParser to download a
fresh Italian IPA codes list from the given URL instead of using the
embedded snapshot. The format matches the Agid export (one code per
line), so the Agid URL can be passed directly.

The validator is now per-Parser rather than a package-level global,
which also makes concurrent parsers with different IPA code sets safe.
As a side effect, MakeIsOrganisationURI now builds its inner validator
once per Parser (via closure) instead of on every validation call.

The embedded list remains the default; WASM callers omit the option
and continue to use it as before.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 90.62500% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.58%. Comparing base (6682066) to head (1707378).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
parser.go 81.25% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
- Coverage   84.76%   84.58%   -0.18%     
==========================================
  Files          15       15              
  Lines        1201     1226      +25     
==========================================
+ Hits         1018     1037      +19     
- Misses        155      158       +3     
- Partials       28       31       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPA codes update creates daily PR churn

1 participant