-
Notifications
You must be signed in to change notification settings - Fork 73
Adding --recurse / --no-recurse option #283
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't mind a little more tweaking...
It would be more consistent with existing behavior to look at the value of global_options.recurse
instead of extracting it in the caller and then passing recurse
as a separate parameter. Additionally, you can then just check self.global_options.recurse
within the class instead of needing to add self.recurse
.
Also, the more I look at this, the more I can't see where the recurse
parameter to scan_folder.main()
is coming from. The crazy thing is that I play-tested it and it obviously works, so I guess I'm good with things as-is if nobody else has complaints -- I just can't understand what is happening!
cf0e252
to
5bcbc50
Compare
I believe About the parameter |
README.md
Outdated
@@ -159,6 +159,7 @@ Commands: | |||
pre-commit Scan staged changes in a pre-commit hook. | |||
scan-local-repo Scan a repository already cloned to your local system. | |||
scan-remote-repo Automatically clone and scan a remote git repository. | |||
scan-folder Scan a folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
scan-folder Scan a folder. | |
scan-folder Scan a folder on your local system. |
tests/test_folder_scanner.py
Outdated
self.assertEqual(2, len(issues)) | ||
self.assertEqual("KQ0I97OBuPlGB9yPRxoSxnX52zE=", issues[0].matched_string) | ||
self.assertEqual(IssueType.Entropy, issues[0].issue_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a similar assertions for the new issue.
CHANGELOG.md
Outdated
@@ -20,6 +20,8 @@ Features: | |||
`--scan-filenames/--no-scan-filenames` flag which allows users to enable or disable file name scanning. | |||
* [#254](https://github.com/godaddy/tartufo/pull/260) - Changes the default value of | |||
`--regex/--no-regex` to True. | |||
* [#268](https://github.com/godaddy/tartufo/issues/268) - Adds a new | |||
`--recurse / --no-recurse` flag which allows users scan entire directory or just the root directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`--recurse / --no-recurse` flag which allows users scan entire directory or just the root directory | |
`--recurse / --no-recurse` flag which allows users to recursively scan the entire directory or just the root directory |
9adaee0
to
49d6adb
Compare
49d6adb
to
09c349b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🦅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No hard blockers here; overall it looks great! Just a few suggestions to improve the tests with some Python-isms. 😄
Thank you!
tests/test_folder_scanner.py
Outdated
actual_issues = [] | ||
for issue in issues: | ||
actual_issues.append(issue.matched_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but cases like this are ideal for list comprehensions 😄
actual_issues = [] | |
for issue in issues: | |
actual_issues.append(issue.matched_string) | |
actual_issues = [issue.matched_string for issue in issues] |
tests/test_folder_scanner.py
Outdated
|
||
with patch("pathlib.Path.open", side_effect=OSError()): | ||
with self.assertRaises(click.FileError): | ||
list(test_scanner.scan()) | ||
|
||
def test_scan_all_the_files_recursively(self): | ||
folder_path = pathlib.Path(__file__).parent / "data/scan_folder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All path separators should be outside the string, so that we can be absolutely certain they are OS-independent.
folder_path = pathlib.Path(__file__).parent / "data/scan_folder" | |
folder_path = pathlib.Path(__file__).parent / "data" / "scan_folder" |
tests/test_folder_scanner.py
Outdated
actual_issues = [] | ||
for issue in issues: | ||
actual_issues.append(issue.matched_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same list comprehension trick can be applied here
actual_issues = [] | |
for issue in issues: | |
actual_issues.append(issue.matched_string) | |
actual_issues = [issue.matched_string for issue in issues] |
tests/test_folder_scanner.py
Outdated
) | ||
|
||
def test_scan_only_root_level_files(self): | ||
folder_path = pathlib.Path(__file__).parent / "data/scan_folder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
folder_path = pathlib.Path(__file__).parent / "data/scan_folder" | |
folder_path = pathlib.Path(__file__).parent / "data" / "scan_folder" |
tests/test_folder_scanner.py
Outdated
actual_issues = [] | ||
for issue in issues: | ||
actual_issues.append(issue.matched_string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual_issues = [] | |
for issue in issues: | |
actual_issues.append(issue.matched_string) | |
actual_issues = [issue.matched_string for issue in issues] |
To help us get this pull request reviewed and merged quickly, please be sure to include the following items:
PR Type
What kind of change does this PR introduce?
Backward Compatibility
Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?
Issue Linking
Closes #268
What's new?