Skip to content

Commit

Permalink
Removing depricated flags --include-paths and --exclude-paths (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuriesha authored Nov 10, 2021
1 parent e319a51 commit c15330a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 68 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Features:
* [#254](https://github.com/godaddy/tartufo/pull/260) - Changes the default value of
`--regex/--no-regex` to True.

Misc:

* [#255](https://github.com/godaddy/tartufo/issues/255) -- Removed deprecated flags
--include-paths and --exclude-paths

v2.9.0 - 19 October 2021
------------------------

Expand Down
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ Options:
Check the names of files being scanned as well as their contents.
[default: True]

-i, --include-paths FILENAME [DEPRECATED] Use `--include-path-patterns`.
File with regular expressions (one per
line), at least one of which must match a
Git object path in order for it to be
scanned; lines starting with '#' are treated
as comments and are ignored. If empty or not
provided (default), all Git object paths are
included unless otherwise excluded via the
--exclude-paths option.

-ip, --include-path-patterns TEXT
Specify a regular expression which matches
Git object paths to include in the scan.
Expand All @@ -78,16 +68,6 @@ Options:
included unless otherwise excluded via the
--exclude-path-patterns option.

-x, --exclude-paths FILENAME [DEPRECATED] Use `--exclude-path-patterns`.
File with regular expressions (one per
line), none of which may match a Git object
path in order for it to be scanned; lines
starting with '#' are treated as comments
and are ignored. If empty or not provided
(default), no Git object paths are excluded
unless effectively excluded via the
--include-paths option.

-xp, --exclude-path-patterns TEXT
Specify a regular expression which matches
Git object paths to exclude from the scan.
Expand Down
21 changes: 0 additions & 21 deletions tartufo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Comma
show_default=True,
help="Check the names of files being scanned as well as their contents.",
)
@click.option(
"-i",
"--include-paths",
type=click.File("r"),
help="""[DEPRECATED] Use `--include-path-patterns`. File with regular
expressions (one per line), at least one of which must match a Git object
path in order for it to be scanned; lines starting with '#' are treated as
comments and are ignored. If empty or not provided (default), all Git object
paths are included unless otherwise excluded via the --exclude-paths
option.""",
)
@click.option(
"-ip",
"--include-path-patterns",
Expand All @@ -101,16 +90,6 @@ def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Comma
included unless otherwise excluded via the --exclude-path-patterns
option.""",
)
@click.option(
"-x",
"--exclude-paths",
type=click.File("r"),
help="""[DEPRECATED] Use `--exclude-path-patterns`. File with regular
expressions (one per line), none of which may match a Git object path in
order for it to be scanned; lines starting with '#' are treated as comments
and are ignored. If empty or not provided (default), no Git object paths are
excluded unless effectively excluded via the --include-paths option.""",
)
@click.option(
"-xp",
"--exclude-path-patterns",
Expand Down
15 changes: 0 additions & 15 deletions tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Set,
Tuple,
)
import warnings

import click
import git
Expand Down Expand Up @@ -188,13 +187,6 @@ def included_paths(self) -> List[Pattern]:
if self._included_paths is None:
self.logger.info("Initializing included paths")
patterns = list(self.global_options.include_path_patterns or ())
if self.global_options.include_paths:
warnings.warn(
"--include-paths is deprecated and will be removed in v3.0. Use --include-path-patterns instead.",
DeprecationWarning,
)
patterns += self.global_options.include_paths.readlines()
self.global_options.include_paths.close()
self._included_paths = (
config.compile_path_rules(set(patterns)) if patterns else []
)
Expand Down Expand Up @@ -227,13 +219,6 @@ def excluded_paths(self) -> List[Pattern]:
if self._excluded_paths is None:
self.logger.info("Initializing excluded paths")
patterns = list(self.global_options.exclude_path_patterns or ())
if self.global_options.exclude_paths:
warnings.warn(
"--exclude-paths is deprecated and will be removed in v3.0. Use --exclude-path-patterns instead.",
DeprecationWarning,
)
patterns += self.global_options.exclude_paths.readlines()
self.global_options.exclude_paths.close()
self._excluded_paths = (
config.compile_path_rules(set(patterns)) if patterns else []
)
Expand Down
4 changes: 0 additions & 4 deletions tartufo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ class GlobalOptions:
"entropy",
"regex",
"scan_filenames",
"include_paths",
"include_path_patterns",
"exclude_paths",
"exclude_path_patterns",
"exclude_entropy_patterns",
"exclude_signatures",
Expand All @@ -34,9 +32,7 @@ class GlobalOptions:
entropy: bool
regex: bool
scan_filenames: bool
include_paths: Optional[TextIO]
include_path_patterns: Tuple[str, ...]
exclude_paths: Optional[TextIO]
exclude_path_patterns: Tuple[str, ...]
exclude_entropy_patterns: Tuple[str, ...]
exclude_signatures: Tuple[str, ...]
Expand Down
10 changes: 2 additions & 8 deletions tests/test_base_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,10 @@ def test_included_paths_is_empty_if_not_specified(self):
def test_include_paths_are_calculated_if_specified(
self, mock_compile: mock.MagicMock
):
mock_include = mock.MagicMock()
mock_include.readlines.return_value = ["bar"]
self.options.include_paths = mock_include
self.options.include_path_patterns = ("foo",)
test_scanner = TestScanner(self.options)
test_scanner.included_paths # pylint: disable=pointless-statement
mock_compile.assert_called_once_with({"foo", "bar"})
mock_compile.assert_called_once_with({"foo"})

@mock.patch("tartufo.config.compile_path_rules")
def test_populated_excluded_paths_list_does_not_recompute(
Expand All @@ -208,13 +205,10 @@ def test_excluded_paths_is_empty_if_not_specified(self):
def test_exclude_paths_are_calculated_if_specified(
self, mock_compile: mock.MagicMock
):
mock_exclude = mock.MagicMock()
mock_exclude.readlines.return_value = ["Pipfile.lock\n"]
self.options.exclude_paths = mock_exclude
self.options.exclude_path_patterns = ("foo",)
test_scanner = TestScanner(self.options)
test_scanner.excluded_paths # pylint: disable=pointless-statement
mock_compile.assert_called_once_with({"foo", "Pipfile.lock\n"})
mock_compile.assert_called_once_with({"foo"})

def test_should_scan_treats_included_paths_as_exclusive(self):
test_scanner = TestScanner(self.options)
Expand Down

0 comments on commit c15330a

Please sign in to comment.