Skip to content

Refactor: reduce complexity in Bump and remove duplicate config parsing #2129

Done

Description

@MrBubune

Description

DPy (DesignitePython, a static analysis tool) reports Bump.call in commitizen/commands/bump.py as a long method (172 lines) and a complex method (cyclomatic complexity 27). JsonConfig, TomlConfig and YAMLConfig also repeat the same _parse_setting steps. This makes Bump hard to read and change one step at a time.

Possible Solution

  1. Bump.call: rename the reused variable c, name the tag sign/annotate conditions, extract the duplicate "not eligible for bump" check and the commit retry check, and extract the changelog step into _update_changelog.
  2. Config: pull up the shared _parse_setting steps into BaseConfig.
  3. Move smart_open and EOLType from commitizen.git to a new commitizen.eol module. commitizen.git keeps exporting both names.
  4. Extract the git commit/tag steps from Bump into a GitReleasePublisher class.

No change to CLI flags, output or exit codes.

Additional context

I can open the PR. Is this welcome?

Related issues

No response

Activity

  1. added
    type: feature
    on Nov 25, 2026
  2. woile commented on Nov 26, 2026

    @woile
    Member

    Hi thanks for this but it doesn't add any value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions