Skip to content

Comments

Do not allow anymore to create Variables or Attributes with an empty name#53

Merged
jeandet merged 1 commit intoSciQLop:mainfrom
jeandet:error_on_empty_names
Feb 18, 2026
Merged

Do not allow anymore to create Variables or Attributes with an empty name#53
jeandet merged 1 commit intoSciQLop:mainfrom
jeandet:error_on_empty_names

Conversation

@jeandet
Copy link
Member

@jeandet jeandet commented Feb 18, 2026

This pull request introduces input validation to ensure that variable and attribute names cannot be empty throughout the CDF library, improving data integrity and preventing subtle bugs. It also adds corresponding Python unit tests to verify these constraints. Additionally, the pull request includes a minor improvement to the variable output streaming function.

Input validation improvements:

  • Added checks in the constructors of Variable, Attribute, and VariableAttribute (in variable.hpp and attribute.hpp) to throw an exception if the name is empty, enforcing that all variable and attribute names must be non-empty. [1] [2] [3] [4]

Testing enhancements:

  • Added a new Python test class (PycdfEmptyNamesAreNotAllowed in test.py) that verifies an exception is raised when attempting to create variables or attributes with empty names, ensuring the new validation logic is covered.

Code maintainability:

  • Improved the operator<< for cdf_map<std::string, cdf::Variable> in cdf-file.hpp by using std::for_each for cleaner and more modern iteration over variables.

Closes #48

…name.

While technically legal (no mention in the official format doc), others CDF implementations consider the file corrupted if a name is empty.

Fixes SciQLop#48
@jeandet jeandet added the enhancement New feature or request label Feb 18, 2026
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.18%. Comparing base (4edf261) to head (49fb44c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
include/cdfpp/cdf-file.hpp 0.00% 1 Missing ⚠️
include/cdfpp/variable.hpp 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
- Coverage   88.27%   88.18%   -0.09%     
==========================================
  Files          56       56              
  Lines        3198     3209      +11     
==========================================
+ Hits         2823     2830       +7     
- Misses        375      379       +4     
Flag Coverage Δ
unittests 88.18% <77.77%> (-0.09%) ⬇️

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

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

@jeandet jeandet merged commit ef764ed into SciQLop:main Feb 18, 2026
46 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not allow entries with an empty name

1 participant