Skip to content

fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields#486

Open
ArmaanjeetSandhu wants to merge 1 commit into
terryyin:masterfrom
ArmaanjeetSandhu:fix/csv-output-multi-field-extensions
Open

fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields#486
ArmaanjeetSandhu wants to merge 1 commit into
terryyin:masterfrom
ArmaanjeetSandhu:fix/csv-output-multi-field-extensions

Conversation

@ArmaanjeetSandhu

Copy link
Copy Markdown

Problem

csv_output() in lizard_ext/csvoutput.py only appended extension columns when an extension declared exactly one FUNCTION_INFO field:

if hasattr(extension, 'FUNCTION_INFO') and \
        len(list(extension.FUNCTION_INFO)) == 1:

Any extension with more than one field was skipped entirely, so lizard --csv -Eio or lizard --csv -Eduplicated_param_list produced 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 == 1 guard with a plain loop over every FUNCTION_INFO key, accumulating extension_variables and extension_captions in 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 captions
  • test_csv_row_with_multi_field_extension: verifies both field values appear in the data row

The tests use neutral field names (metric_one, metric_two) rather than real extension attribute names to avoid collisions with the FunctionInfo properties that extension modules install at import time.

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.

1 participant