Skip to content

Refactor distributionSelected parameter sprawl into options object #247

@ddeboer

Description

@ddeboer

`distributionSelected` on the `ProgressReporter` interface currently takes five positional parameters, three of which are optional and only meaningful together:

distributionSelected(
  dataset: Dataset,
  distribution: Distribution,
  importedFrom?: Distribution,
  importDuration?: number,
  tripleCount?: number,
): void

`importedFrom` acts as a discriminant — when present, `importDuration` and `tripleCount` apply; when absent, neither does. This makes the call sites fragile (callers must pass `undefined` in the right positions) and the signature hard to extend.

Proposed change

Replace the trailing optional parameters with an options object or explicit overloads, e.g.:

distributionSelected(
  dataset: Dataset,
  distribution: Distribution,
  imported?: {
    from: Distribution;
    duration?: number;
    tripleCount?: number;
  },
): void

This requires updating:

  1. `ProgressReporter` interface in `@lde/pipeline`
  2. `ConsoleReporter` in `@lde/pipeline-console-reporter`
  3. All call sites that invoke `distributionSelected`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions