Skip to content

Prune empty sections in composer.json#1053

Merged
localheinz merged 1 commit intoergebnis:mainfrom
fredden:prune-empty-elements-in-composerjson
Apr 10, 2025
Merged

Prune empty sections in composer.json#1053
localheinz merged 1 commit intoergebnis:mainfrom
fredden:prune-empty-elements-in-composerjson

Conversation

@fredden
Copy link
Copy Markdown
Contributor

@fredden fredden commented Dec 31, 2023

This pull request removes empty sections from composer.json when they are defined as optional (or more specifically, not specified as required) according to the schema.

I have hidden this feature behind an optional constructor property, so that other users of this package can decide if they also want to have empty-and-optional elements removed during normalisation.

The removal happens after normalisation so we can process nesting properly.

I chose to not remove empty elements which are not defined in the schema.

Related to composer/composer#7691

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 31, 2023

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.26%. Comparing base (6d15399) to head (a2b58fc).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/SchemaNormalizer.php 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1053      +/-   ##
============================================
- Coverage     97.94%   97.26%   -0.69%     
- Complexity      196      203       +7     
============================================
  Files            32       32              
  Lines           828      840      +12     
============================================
+ Hits            811      817       +6     
- Misses           17       23       +6     

☔ 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.

@localheinz localheinz self-assigned this Jan 7, 2024
@localheinz localheinz force-pushed the prune-empty-elements-in-composerjson branch 3 times, most recently from 2f2c606 to 2a5e4d2 Compare February 17, 2024 14:02
@localheinz localheinz changed the title Prune empty sections in composer.json Prune empty sections in composer.json Feb 17, 2024
@localheinz localheinz force-pushed the prune-empty-elements-in-composerjson branch 2 times, most recently from 1699024 to f1747f3 Compare April 10, 2025 09:21
@localheinz localheinz force-pushed the prune-empty-elements-in-composerjson branch from f1747f3 to a2b58fc Compare April 10, 2025 09:27
@localheinz localheinz merged commit b05de24 into ergebnis:main Apr 10, 2025
25 of 27 checks passed
@localheinz
Copy link
Copy Markdown
Member

Thank you, @fredden!

@fredden fredden deleted the prune-empty-elements-in-composerjson branch April 10, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants