Skip to content

refactor: remove dead and redundant code#135

Merged
hakandilek merged 6 commits into
mainfrom
refactor/dead-code
Jul 9, 2026
Merged

refactor: remove dead and redundant code#135
hakandilek merged 6 commits into
mainfrom
refactor/dead-code

Conversation

@hakandilek

Copy link
Copy Markdown
Collaborator

Summary

  • Remove unused is_valid_serial_number() helper.
  • Simplify defensive property guards while keeping CycloneDX collection initialization fallbacks.
  • Drop unused enum.auto branch from SbomNature.__new__.
  • Remove empty renovate.json; Dependabot remains configured.
  • Retarget ImmutableList length test to snapshot behavior.

Testing

  • poetry run tox run

@hakandilek hakandilek marked this pull request as ready for review July 8, 2026 11:04
@hakandilek hakandilek force-pushed the refactor/dead-code branch from 0d61b9a to 9cd6501 Compare July 8, 2026 14:41
@hakandilek hakandilek requested a review from leoreinmann July 8, 2026 14:42
@hakandilek hakandilek force-pushed the refactor/dead-code branch from 9cd6501 to 2fd4724 Compare July 9, 2026 07:04
hakandilek and others added 6 commits July 9, 2026 11:56
The `is_valid_serial_number()` function in `model.py` had no call sites
anywhere in the library or the test suite, so it was effectively dead code.

It also predated the current API: it accepts a `str | None` and checks for the
literal sentinel `"urn:uuid:None"`, whereas `StandardBom.serial_number` now
exposes a `UUID`. The helper no longer matched how serial numbers are
represented, so keeping it risked confusion.

Remove it to reduce dead surface area. No behavior or public API change; the
full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) still passes.
Keep the defensive None checks around CycloneDX-managed collections, so the code remains resilient if the upstream API changes its default initializers.

Simplify the author list getter by using an empty-list fallback directly, and remove the redundant `custom_property_key is not None` checks from custom property accessors. The key is typed as `str`, and all callers pass concrete property constants, so those clauses did not add protection.

No behavior change; the full tox matrix (lint, mypy strict, unit tests on Python 3.10-3.14) passes.
`SbomNature` defines explicit string values (`"source"`, `"binary"`), so the
`enum.auto` case in the `__new__` type check can never occur — members are
never generated via `auto()`. Narrow the guard to `isinstance(value, str)` and
remove the now-unused `import enum`.

No behavior or public API change; the type check still rejects non-string
values exactly as before. The full tox matrix (lint, mypy strict, unit tests on
Python 3.10-3.14) passes.
`renovate.json` only contained an empty object, so it did not configure
Renovate behavior.

Dependabot is already configured in `.github/dependabot.yml` for Poetry/pip and
GitHub Actions updates, making the empty Renovate file redundant repository
noise.

No runtime behavior change; the full tox matrix (lint, mypy strict, unit tests
on Python 3.10-3.14) passes.
`ImmutableList` does not store a `_length` attribute; length is derived from
the immutable `_items` tuple. The previous test passed by trying to assign a
nonexistent frozen dataclass field, which did not verify any real length state.

Replace it with a behavior-focused assertion: constructing from a mutable list
takes a tuple snapshot, so later mutations to the source list do not affect
`len()`.

No runtime behavior change; the full tox matrix (lint, mypy strict, unit tests
on Python 3.10-3.14) passes.
@hakandilek hakandilek force-pushed the refactor/dead-code branch from 2fd4724 to 58a7182 Compare July 9, 2026 09:57

@leoreinmann leoreinmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@hakandilek hakandilek merged commit 10c9e23 into main Jul 9, 2026
12 checks passed
@hakandilek hakandilek deleted the refactor/dead-code branch July 9, 2026 11:57
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.

2 participants