fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields#486
Open
ArmaanjeetSandhu wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
csv_output()inlizard_ext/csvoutput.pyonly appended extension columns when an extension declared exactly oneFUNCTION_INFOfield:Any extension with more than one field was skipped entirely, so
lizard --csv -Eioorlizard --csv -Eduplicated_param_listproduced the same CSV as a run with no extension at all. The metrics appeared correctly in the default table but vanished in CSV output.Fix
Replace the
len == 1guard with a plain loop over everyFUNCTION_INFOkey, accumulatingextension_variablesandextension_captionsin declared order. The downstream header and row-building code is unchanged.Single-field extensions (
-Eexitcount,-Egotocount, etc.) and no-extension runs produce byte-for-byte identical output to before.Tests
Two regression tests added to
test/testOutputCSV.py:test_csv_header_with_multi_field_extension: verifies the header contains all declared captionstest_csv_row_with_multi_field_extension: verifies both field values appear in the data rowThe tests use neutral field names (
metric_one,metric_two) rather than real extension attribute names to avoid collisions with theFunctionInfoproperties that extension modules install at import time.