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 location of same-file findings-divider (--------) #3046

Merged
merged 3 commits into from May 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

### Fixed
- Empty yaml files do not crash

- Autofix printout is grouped with its own finding rather than the one below it
### Changed
- .git/ directories are ignored when scanning

Expand Down
13 changes: 7 additions & 6 deletions semgrep/semgrep/output.py
Expand Up @@ -257,6 +257,13 @@ def build_normal_output(
if rule_index != len(sorted_rule_matches) - 1
else None
)

if fix:
yield f"{BLUE_COLOR}autofix:{RESET_COLOR} {fix}"
elif rule_match.fix_regex:
fix_regex = rule_match.fix_regex
yield f"{BLUE_COLOR}autofix:{RESET_COLOR} s/{fix_regex.get('regex')}/{fix_regex.get('replacement')}/{fix_regex.get('count', 'g')}"

is_same_file = (
next_rule_match.path == rule_match.path if next_rule_match else False
)
Expand All @@ -267,12 +274,6 @@ def build_normal_output(
per_line_max_chars_limit,
is_same_file,
)

if fix:
yield f"{BLUE_COLOR}autofix:{RESET_COLOR} {fix}"
elif rule_match.fix_regex:
fix_regex = rule_match.fix_regex
yield f"{BLUE_COLOR}autofix:{RESET_COLOR} s/{fix_regex.get('regex')}/{fix_regex.get('replacement')}/{fix_regex.get('count', 'g')}"
if show_times:
yield from build_timing_summary(
filtered_rules, all_targets, match_time_matrix, color_output
Expand Down