Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseline capability #751

Merged
merged 5 commits into from
Jun 9, 2024
Merged

Add baseline capability #751

merged 5 commits into from
Jun 9, 2024

Conversation

ileitch
Copy link
Contributor

@ileitch ileitch commented Jun 2, 2024

No description provided.

@ileitch ileitch changed the title Add basline capability Add baseline capability Jun 2, 2024
@ileitch ileitch requested a review from mildm8nnered June 2, 2024 16:42
@mildm8nnered
Copy link
Contributor

So one nice thing about saving the serialized ScanResults is that it makes it very easy to implement the baseline command, which allows easy inspection, and comparison of baselines, using the existing reporting mechanisms for violations (Formatters in periphery terminology, or Reporters in SwiftLint).

I've included the help from SwiftLint's baseline command below. This is probably a minority interest, but it does let you answer questions like "what violations am I ignoring?", and "how many more violations have been introduced for disabled rules since time T".

This doesn't effect the main baseline functionality during scans at all, and is definitely a nice to have. I'm not sure exactly what you'd need to save to be able to reproduce the reporting.

% swiftlint help baseline
OVERVIEW: Operations on existing baselines

USAGE: swiftlint baseline <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  report (default)        Reports the violations in a baseline.
  compare                 Reports the violations that are present in another baseline but not in the original baseline.

  See 'swiftlint help baseline <subcommand>' for detailed help.
%
% swiftlint help baseline report
OVERVIEW: Reports the violations in a baseline.

USAGE: swiftlint baseline report <baseline> [--reporter <reporter>] [--output <output>]

ARGUMENTS:
  <baseline>              The path to the baseline file.

OPTIONS:
  --reporter <reporter>   The reporter used to report violations. The 'summary' reporter can be useful to provide an overview.
  --output <output>       The file where violations should be saved. Prints to stdout by default.
  --version               Show the version.
  -h, --help              Show help information.

%
% swiftlint help baseline compare
OVERVIEW: Reports the violations that are present in another baseline but not in the original baseline.

USAGE: swiftlint baseline compare <baseline> --other-baseline <other-baseline> [--reporter <reporter>] [--output <output>]

ARGUMENTS:
  <baseline>              The path to the baseline file.

OPTIONS:
  --other-baseline <other-baseline>
                          The path to a second baseline to compare against the baseline. Violations in the second baseline that are not present in the original baseline will be reported.
  --reporter <reporter>   The reporter used to report violations. The 'summary' reporter can be useful to provide an overview.
  --output <output>       The file where violations should be saved. Prints to stdout by default.
  --version               Show the version.
  -h, --help              Show help information.

@mildm8nnered
Copy link
Contributor

Being able to set the baseline in the config file can also be very useful, so that people can just run periphery scan and not unexpectedly see lots of violations.

The SwiftLint implementation doesn't have this yet, but there is a PR open for it - realm/SwiftLint#5552

@ileitch ileitch merged commit e676e1a into master Jun 9, 2024
6 checks passed
@ileitch ileitch deleted the baseline branch June 9, 2024 09:45
@ileitch
Copy link
Contributor Author

ileitch commented Jun 9, 2024

So one nice thing about saving the serialized ScanResults is that it makes it very easy to implement the baseline command

Let's defer this to a future change. I think the fundemental function of using the USR for comparisson should remain the same, we'd just need to update the format to include some contextual information for each USR.

Being able to set the baseline in the config file can also be very useful, so that people can just run periphery scan and not unexpectedly see lots of violations.

Yep, this is supported with the baseline and write_baseline yaml keys.

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