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

fix: Include correct indentation in first line of policy breach context #237

Conversation

spdawson
Copy link
Contributor

Description

Previously, we would omit any and all content that precedes the match, on the first line of the match context. In particular, if the first line of a match has initial whitespace, then this would be trimmed in the output.

Unfortunately, in order to reconstruct the first line fully, we must re-read it from the originating file. This is done using a
line scanner, to avoid reading the entire file into memory. Nevertheless, this is sub-optimal; in the future, it may be worthwhile improving on this implementation.

Also: show only a single-line code extract, when the policy dictates that parent context be omitted.

Screenshots

Before

Before

After

After

Checklist

  • I've added test coverage that shows my fix or feature works as expected.
  • I've updated or added documentation if required.
  • I've included usage information in the description if CLI behavior was updated or added.
  • PR title follows Conventional Commits format

Previously, we would omit any and all content that precedes the
match, on the first line of the match context. In particular, if
the first line of a match has initial whitespace, then this would
be trimmed in the output.

Unfortunately, in order to reconstruct the first line fully, we
must re-read it from the originating file. This is done using a
line scanner, to avoid reading the entire file into memory.
Nevertheless, this is sub-optimal; in the future, it may be
worthwhile improving on this implementation.

Also: show only a single-line code extract, when the policy
dictates that parent context be omitted.
@spdawson spdawson force-pushed the AMA-3340-fix-indentation-of-first-line-of-code-excerpt-in-policy-report-we-are-trimming-the-indentation-of-the-first-line branch from d1e4bce to cf88322 Compare December 13, 2022 09:11
Copy link
Contributor

@elsapet elsapet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@spdawson spdawson force-pushed the AMA-3340-fix-indentation-of-first-line-of-code-excerpt-in-policy-report-we-are-trimming-the-indentation-of-the-first-line branch from cf88322 to 2400673 Compare December 13, 2022 09:43
@spdawson spdawson merged commit cf89a53 into main Dec 13, 2022
@spdawson spdawson deleted the AMA-3340-fix-indentation-of-first-line-of-code-excerpt-in-policy-report-we-are-trimming-the-indentation-of-the-first-line branch December 13, 2022 09:47
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