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: same secret should be shown once in the results output for scan command #430

Merged
merged 2 commits into from
Nov 25, 2022

Conversation

alina-tuholukova-gg
Copy link
Contributor

Fixes issue #428

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2022

Codecov Report

Merging #430 (c278228) into main (76b47ba) will increase coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #430      +/-   ##
==========================================
+ Coverage   94.51%   94.53%   +0.02%     
==========================================
  Files          83       83              
  Lines        3534     3534              
==========================================
+ Hits         3340     3341       +1     
+ Misses        194      193       -1     
Flag Coverage Δ
unittests 94.53% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
ggshield/scan/repo.py 100.00% <ø> (ø)
ggshield/output/json/json_output_handler.py 91.13% <0.00%> (-1.27%) ⬇️
ggshield/cmd/secret/scan/docset.py 67.74% <0.00%> (-1.01%) ⬇️
ggshield/cmd/secret/scan/pypi.py 95.00% <0.00%> (-0.13%) ⬇️
ggshield/cmd/iac/scan.py 98.86% <0.00%> (ø)
ggshield/cmd/scan/__init__.py 100.00% <0.00%> (ø)
ggshield/cmd/secret/scan/ci.py 100.00% <0.00%> (ø)
ggshield/cmd/secret/scan/path.py 100.00% <0.00%> (ø)
ggshield/cmd/secret/scan/repo.py 100.00% <0.00%> (ø)
ggshield/cmd/secret/scan/range.py 100.00% <0.00%> (ø)
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment on lines 77 to 79
for commit in commits:
for file in commit.files:
commit_files_tuple.append((commit, file))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would rename commit_files_tuple to commit_files_tuples, since its a list of tuples and not a list.

Also, I think you can create it using a comprehension list, like this (untested):

commit_files_tuples = [(c, f) for c in commits for f in c.files]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, thanks !

for file in commit.files
)
]
for (commit, file), result in zip(commit_files_tuple, results.results):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we do not use file in this loop, so it can be replaced with _:

Suggested change
for (commit, file), result in zip(commit_files_tuple, results.results):
for (commit, _), result in zip(commit_files_tuple, results.results):

It's interesting that this new code is probably going to be faster! 😀

Copy link
Collaborator

Choose a reason for hiding this comment

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

@agateau-gg
Side note : if I am not mistaken we do not benchmark scan repo in the performance benchmark ? We could have seen it here. But it may be too long to include the repo option in the benchmark ?

Copy link
Collaborator

@agateau-gg agateau-gg Nov 24, 2022

Choose a reason for hiding this comment

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

We benchmark scan commit-range, which uses this code. But the benchmark does not show a significant change :/.

Copy link
Collaborator

@agateau-gg agateau-gg left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@agateau-gg agateau-gg merged commit 8669b23 into main Nov 25, 2022
@agateau-gg agateau-gg deleted the alina/cor-769/fix-double-policy-break-in-result branch November 25, 2022 12:41
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.

4 participants