Skip to content

Split long Rust files into focused submodules #2566

Description

@marcoieni

Several Rust files are very long. This makes reviewing and editing the code harder.

We should refactor the longest files into smaller submodules based on responsibility.

Examples of long files

Current examples:

  • src/sync/github/mod.rs - ~2,839 lines
  • src/sync/github/tests/mod.rs - ~1,855 lines
  • src/validate.rs - ~1,515 lines
  • src/schema.rs - ~1,117 lines
  • src/sync/github/api/read.rs - ~845 lines
  • src/sync/github/api/mod.rs - ~807 lines
  • src/sync/github/api/write.rs - ~764 lines
  • src/main.rs - ~682 lines
  • src/static_api.rs - ~651 lines

Example: GitHub sync module

src/sync/github/mod.rs currently contains orchestration, repo diffs, team diffs, permissions, rulesets, pages, environments, custom properties, app installations, and formatting logic.
We should only keep the orchestration part.

A possible split:

src/sync/github/
  mod.rs                  # create_diff, SyncGitHub orchestration, shared exports
  apps.rs                 # GithubApp, app installation state/diffs
  teams.rs                # team diffing, team create/update/delete logic
  repos.rs                # RepoDiff, CreateRepoDiff, UpdateRepoDiff
  rulesets.rs             # construct_ruleset, RulesetDiff, ruleset formatting
  environments.rs         # EnvironmentDiff
  pages.rs                # PagesDiff and pages formatting
  custom_properties.rs    # CustomPropertyDiff and value matching
  api/
  tests/

How to solve this issue

Open small PRs that only extract one submodule at a time.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions