-
Notifications
You must be signed in to change notification settings - Fork 73
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
Remove deprecated code #433
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.
Nits.
Mostly, beef up the changelog entry for people who have forgotten what things we dropped... The rest is complaints about the way you specified tuples in various test methods. Just specify the tuples like before, but with dict members instead of str members:
my_tuple = ({"my": "dict"},)
CHANGELOG.md
Outdated
@@ -2,6 +2,8 @@ vX.X.X - DD MMM YYYY | |||
-------------------- | |||
|
|||
Features: | |||
* [#433](https://github.com/godaddy/tartufo/pull/433) - Dropped support for deprecated flags from v3.0 |
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.
In this context, and in the interest of visibility, I would explicitly list the removed flags here again... for people who only read the CHANGELOG and not the error messages. ;-)
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.
+1
tests/test_base_scanner.py
Outdated
self.options.include_path_patterns = tuple( | ||
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}] | ||
) |
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.
This works but I had to read it 3 times and then try it myself to convince myself it did what was needed. How about:
self.options.include_path_patterns = tuple( | |
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}] | |
) | |
self.options.include_path_patterns = ( | |
{"path-pattern": "foo", "reason": "Testing exclude path pattern"}, | |
) |
tests/test_base_scanner.py
Outdated
self.options.exclude_path_patterns = tuple( | ||
[{"path-pattern": "foo", "reason": "Testing exclude path pattern"}] | ||
) |
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.
Ditto above. The only reason I comment is that it isn't obvious to the casual reader that you're getting a tuple consisting of a single dict vs a tuple consisting of a single list
tests/test_base_scanner.py
Outdated
self.options.exclude_signatures = tuple( | ||
[{"signature": "foo", "reason": "Testing exclude signature"}] | ||
) |
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.
...and again
tests/test_base_scanner.py
Outdated
self.options.exclude_signatures = tuple( | ||
[{"signature": "foo", "reason": "Testing exclude signature"}] | ||
) |
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.
again
tests/test_git_repo_scanner.py
Outdated
self.global_options.include_path_patterns = tuple( | ||
[{"path-pattern": "foo/", "reason": "Inclusion reason"}] |
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.
self.global_options.include_path_patterns = tuple( | |
[{"path-pattern": "foo/", "reason": "Inclusion reason"}] | |
self.global_options.include_path_patterns = ( | |
{"path-pattern": "foo/", "reason": "Inclusion reason"}, |
tests/test_git_repo_scanner.py
Outdated
self.global_options.exclude_path_patterns = tuple( | ||
[{"path-pattern": "bar/", "reason": "Exclusion reason"}] |
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.
self.global_options.exclude_path_patterns = tuple( | |
[{"path-pattern": "bar/", "reason": "Exclusion reason"}] | |
self.global_options.exclude_path_patterns = ( | |
{"path-pattern": "bar/", "reason": "Exclusion reason"}, |
tests/test_git_repo_scanner.py
Outdated
self.global_options.exclude_signatures = tuple( | ||
[{"signature": "bar", "reason": "Reason to exclude signature"}] |
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.
self.global_options.exclude_signatures = tuple( | |
[{"signature": "bar", "reason": "Reason to exclude signature"}] | |
self.global_options.exclude_signatures = ( | |
{"signature": "bar", "reason": "Reason to exclude signature"}, |
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.
You missed these:
Lines 190 to 194 in 7f3f026
warnings.warn( | |
"Storing rules in a separate file is deprecated and will be removed " | |
"in tartufo 4.x. Please use the 'rule-patterns' config " | |
" option instead.", | |
DeprecationWarning, |
Lines 606 to 610 in 7f3f026
warnings.warn( | |
f"Signature {old_signature} was generated by an old version of tartufo and is deprecated. " | |
"tartufo 4.x will not recognize this signature. " | |
f"Please update your configuration to use signature {new_signature} instead.", | |
DeprecationWarning, |
Working on addressing second comment here |
tests/test_git_repo_scanner.py
Outdated
test_scanner = scanner.GitRepoScanner( | ||
self.global_options, self.git_options, "." | ||
) | ||
self.assertEqual(test_scanner.excluded_signatures, ("bar/",)) | ||
|
||
def test_error_is_not_raised_when_two_styles_signatures_are_configured(self): | ||
def test_error_is_raised_when_two_styles_signatures_are_configured(self): |
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.
def test_error_is_raised_when_two_styles_signatures_are_configured(self): | |
def test_error_is_raised_when_string_signature_is_used(self): |
tests/test_git_repo_scanner.py
Outdated
test_scanner = scanner.GitRepoScanner( | ||
self.global_options, self.git_options, "." | ||
) | ||
self.assertEqual(test_scanner.included_paths, [re.compile("bar/")]) | ||
|
||
def test_error_is_not_raised_when_two_styles_included_paths_are_configured(self): | ||
def test_error_is_raised_when_two_styles_included_paths_are_configured(self): |
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.
def test_error_is_raised_when_two_styles_included_paths_are_configured(self): | |
def test_error_is_raised_when_string_included_path_is_used(self): |
tests/test_git_repo_scanner.py
Outdated
test_scanner = scanner.GitRepoScanner( | ||
self.global_options, self.git_options, "." | ||
) | ||
self.assertEqual(test_scanner.excluded_paths, [re.compile("bar/")]) | ||
|
||
@mock.patch("tartufo.scanner.GitScanner.filter_submodules", mock.MagicMock()) | ||
def test_error_is_not_raised_when_two_styles_excluded_paths_are_configured(self): | ||
def test_error_is_raised_when_two_styles_excluded_paths_are_configured(self): |
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.
def test_error_is_raised_when_two_styles_excluded_paths_are_configured(self): | |
def test_error_is_raised_when_string_exclude_path_is_used(self): |
tests/test_git_repo_scanner.py
Outdated
self.global_options.exclude_signatures = [ | ||
"foo/", | ||
{"signature": "bar/", "reason": "path pattern"}, | ||
] | ||
test_scanner = scanner.GitRepoScanner( | ||
self.global_options, self.git_options, "." | ||
) | ||
self.assertCountEqual(test_scanner.excluded_signatures, ("foo/", "bar/")) | ||
with self.assertRaisesRegex( | ||
ConfigException, "signature is illegal in exclude-signatures" |
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.
ConfigException, "signature is illegal in exclude-signatures" | |
ConfigException, "str signature is illegal in exclude-signatures" |
|
||
def evaluate_entropy_string( | ||
self, | ||
chunk: types.Chunk, | ||
line: str, | ||
string: str, | ||
min_entropy_score: float, | ||
backwards_compatibility_prefix: Optional[str], |
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.
Docstring and documentation should be updated
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.
Left a few suggestions. Otherwise looks good.
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
What's new?