Skip to content

BNGUtils.pm has # TODO use strict; — foundational module runs without strict checking #299

Description

@akutuva21

Summary

BNGUtils.pm — arguably the most foundational utility module in the BioNetGen Perl codebase — has been running without use strict since its creation. Line 2 of the file reads:

# TODO use strict;

This means typos in variable names silently create new variables, undeclared variables don't raise errors, and symbolic references are unchecked throughout all 27 subroutines in this module.

Location

File: bng2/Perl2/BNGUtils.pm, line 2

Additionally, ComponentType.pm and HNauty.pm lack use strict entirely (not even a TODO comment).

Current behavior

package BNGUtils;
# TODO use strict;

# Perl Modules
use FindBin;

Impact

Without use strict:

  • A typo like $reuslt instead of $result silently creates a new variable initialized to undef
  • Variables can be used without declaration via my, making scope bugs invisible
  • Symbolic references (e.g., using a string as a variable name) are allowed, which can cause hard-to-trace errors

Since BNGUtils provides core utilities used across the entire codebase (error handling, version info, math helpers, file I/O wrappers), any latent bugs here propagate everywhere.

How to verify

head -5 bng2/Perl2/BNGUtils.pm
# Also check which other files lack use strict:
grep -rL 'use strict;' bng2/Perl2/*.pm

Suggested fix

Uncomment and enable strict:

package BNGUtils;
use strict;
use warnings;

This will likely surface undeclared variable warnings that need to be fixed, but that's the point — those are latent bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions