Skip to content

--fix=false behavior could be improved #197

@rubberduck203

Description

@rubberduck203

Currently, when the --fix=false flag is passed, it will stop at the first failing check.
Ideally, when --fix=false is passed, it would run all the checks, regardless of status so the user can see all of the problems/which fixes would be run.

Consider the following doctor group.

apiVersion: scope.github.com/v1alpha
kind: ScopeDoctorGroup
metadata:
  name: fix-false
spec:
  include: when-required
  actions:
    - name: succeeds
      check:
        commands:
          - echo "succeeds"
      fix:
        commands:
          - echo "fix ran"
    - name: run-always-not-required
      required: false
      check: {}
      fix:
        commands:
          - echo "this always runs but isn't critical"
    - name: run-always-required
      check: {}
      fix:
        commands:
          - echo "this always runs but *is* critical"
    - name: another-action
      check:
        commands:
          - echo "another action"
      fix:
        commands:
          - echo "this is another action"

Currently this is the output

scope doctor run --fix=false --working-dir examples --progress=plain --only fix-false
 INFO Check was successful, group: "fix-false", name: "succeeds"
 INFO Check failed, fix was not run, group: "fix-false", name: "run-always-not-required"
 INFO Check failed, fix was not run, group: "fix-false", name: "run-always-required"
Summary: 0 groups succeeded, 1 groups failed

As you can see, some of this can be worked around by marking fixes that should always run (because they don't have a check) with required: false but that may or may not be appropriate depending on the action.

Ideally, we would get the following output.

scope doctor run --fix=false --working-dir examples --progress=plain --only fix-false
 INFO Check was successful, group: "fix-false", name: "succeeds"
 WARN Check failed, fix was not run, group: "fix-false", name: "run-always-not-required"
 WARN Check failed, fix was not run, group: "fix-false", name: "run-always-required"
 INFO Check was successful, group: "fix-false", name: "another-action"
Summary: 0 groups succeeded, 1 groups failed

Not the use of WARN to bring the user's attention to the failing checks and that all of the checks were run and reported.

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