# Path: src/tidypy/tools/base.py
# class Tool:
#     """
#     The base class for TidyPy tools.
#     """
# 
#     @classmethod
#     def can_be_used(cls):
#         """
#         Indicates whether or not this tool can be executed now. Useful when you
#         need to check for certain environmental conditions (e.g., Python
#         version, dependency availability, etc).
# 
#         Unless overridden, always returns ``True``.
# 
#         :rtype: bool
#         """
# 
#         return True
# 
#     @classmethod
#     def get_default_config(cls):
#         """
#         Produces a tool configuration stanza that acts as the base/default for
#         this tool.
# 
#         rtype: dict
#         """
# 
#         return {
#             'use': True,
#             'filters': [],
#             'disabled': [],
#             'options': {},
#         }
# 
#     @classmethod
#     def get_all_codes(cls):
#         """
#         Produces a sequence of all the issue codes this tool is capable of
#         generating. Elements in this sequence must all be 2-element tuples,
#         where the first element is the code, and the second is a textual
#         description of what the code means.
# 
#         Must be implemented by concrete classes.
# 
#         :returns: tuple of tuples containing two strings each
#         """
# 
#         raise NotImplementedError()
# 
#     def __init__(self, config):
#         """
#         :param config: the tool configuration to use during execution
#         :type config: dict
#         """
# 
#         #: The tool's configuration to use during its execution.
#         self.config = config
# 
#     def execute(self, finder):
#         """
#         Analyzes the project and generates a list of issues found during that
#         analysis.
# 
#         Must be implemented by concrete classes.
# 
#         :param finder:
#             the Finder class that should be used to identify the files or
#             directories that the tool will analyze.
#         :type finder: tidypy.Finder
#         :rtype: list(tidypy.Issue)
#         """
# 
#         raise NotImplementedError()
# 
# class Issue:
#     """
#     A class that encapsulates an issue found during the analysis of a project.
#     """
# 
#     #: A string containing name of the tool that found the issue.
#     tool = None
# 
#     #: A string containing a code that identifies the type of issue found.
#     code = None
# 
#     #: A string containing a description of the issue.
#     message = None
# 
#     #: A string containing the full path to the file where the issue was found.
#     filename = None
# 
#     #: The line number within the file where the issue was found (if known).
#     #: The first line in a file is notated as 1 (not zero).
#     line = None
# 
#     #: The character number within the line of the file where the issue was
#     #: found (if known). The first column in a line is notated as 1 (not zero).
#     character = None
# 
#     #: A character indicating the comparable pylint category this issue would
#     #: fall into: E=error, W=warning, R=refactor, C=convention
#     pylint_type = 'E'
# 
#     def __init__(
#             self,
#             code=None,
#             message=None,
#             filename=None,
#             line=None,
#             character=None):
#         self.code = code
#         self.message = message
#         self.filename = filename
#         self.line = line if line is not None else 1
#         self.character = character or None
# 
#     def __repr__(self):
#         return '%s(%s)' % (
#             self.__class__.__name__,
#             ', '.join([
#                 repr(self.code),
#                 repr(self.message),
#                 repr(self.filename),
#                 repr(self.line),
#                 repr(self.character),
#             ]),
#         )
# 
# class AccessIssue(TidyPyIssue):
#     """
#     An issue indicating that a file/directory cannot be accessed (typically
#     due to permissions).
#     """
# 
#     def __init__(self, exc, filename):
#         super().__init__(
#             'access',
#             'Cannot access file (%s)' % (exc,),
#             filename,
#         )
# 
# class UnknownIssue(TidyPyIssue):
#     """
#     A completely unanticipated exception/problem was encountered during the
#     execution of a tool.
#     """
# 
#     def __init__(self, exc, filename):
#         super().__init__(
#             'unexpected',
#             'Unexpected error (%s)' % (exc,),
#             filename,
#         )


from detect_secrets import SecretsCollection
from detect_secrets.core.potential_secret import PotentialSecret
from detect_secrets.core.plugins.util import \
    get_mapping_from_secret_type_to_class
from detect_secrets.settings import transient_settings
from .base import Tool, Issue, AccessIssue, UnknownIssue
        detector = SecretsCollection()
        with transient_settings(settings):
            for filepath in finder.files(self.config['filters']):
                try:
                    detector.scan_file(filepath)
                except Exception as exc:  # pylint: disable=broad-except
                    issues.append(self.make_issue(exc, filepath))

            for filepath, problem in detector:
                issues.append(self.make_issue(problem, filepath))

        return issues

    def make_issue(self, problem, filename):
        if isinstance(problem, PotentialSecret):
            plugin = [
                plugin
                for plugin in PLUGINS
                if plugin.secret_type == problem.type
            ][0]
            return DetectSecretsIssue(
                plugin.__name__,
                DESCRIPTION.format(description=problem.type),
                filename,
                problem.line_number,
            )

        if isinstance(problem, EnvironmentError):
            return AccessIssue(problem, filename)


# Path: src/tidypy/tools/base.py
# class Tool:
#     """
#     The base class for TidyPy tools.
#     """
# 
#     @classmethod
#     def can_be_used(cls):
#         """
#         Indicates whether or not this tool can be executed now. Useful when you
#         need to check for certain environmental conditions (e.g., Python
#         version, dependency availability, etc).
# 
#         Unless overridden, always returns ``True``.
# 
#         :rtype: bool
#         """
# 
#         return True
# 
#     @classmethod
#     def get_default_config(cls):
#         """
#         Produces a tool configuration stanza that acts as the base/default for
#         this tool.
# 
#         rtype: dict
#         """
# 
#         return {
#             'use': True,
#             'filters': [],
#             'disabled': [],
#             'options': {},
#         }
# 
#     @classmethod
#     def get_all_codes(cls):
#         """
#         Produces a sequence of all the issue codes this tool is capable of
#         generating. Elements in this sequence must all be 2-element tuples,
#         where the first element is the code, and the second is a textual
#         description of what the code means.
# 
#         Must be implemented by concrete classes.
# 
#         :returns: tuple of tuples containing two strings each
#         """
# 
#         raise NotImplementedError()
# 
#     def __init__(self, config):
#         """
#         :param config: the tool configuration to use during execution
#         :type config: dict
#         """
# 
#         #: The tool's configuration to use during its execution.
#         self.config = config
# 
#     def execute(self, finder):
#         """
#         Analyzes the project and generates a list of issues found during that
#         analysis.
# 
#         Must be implemented by concrete classes.
# 
#         :param finder:
#             the Finder class that should be used to identify the files or
#             directories that the tool will analyze.
#         :type finder: tidypy.Finder
#         :rtype: list(tidypy.Issue)
#         """
# 
#         raise NotImplementedError()
# 
# class Issue:
#     """
#     A class that encapsulates an issue found during the analysis of a project.
#     """
# 
#     #: A string containing name of the tool that found the issue.
#     tool = None
# 
#     #: A string containing a code that identifies the type of issue found.
#     code = None
# 
#     #: A string containing a description of the issue.
#     message = None
# 
#     #: A string containing the full path to the file where the issue was found.
#     filename = None
# 
#     #: The line number within the file where the issue was found (if known).
#     #: The first line in a file is notated as 1 (not zero).
#     line = None
# 
#     #: The character number within the line of the file where the issue was
#     #: found (if known). The first column in a line is notated as 1 (not zero).
#     character = None
# 
#     #: A character indicating the comparable pylint category this issue would
#     #: fall into: E=error, W=warning, R=refactor, C=convention
#     pylint_type = 'E'
# 
#     def __init__(
#             self,
#             code=None,
#             message=None,
#             filename=None,
#             line=None,
#             character=None):
#         self.code = code
#         self.message = message
#         self.filename = filename
#         self.line = line if line is not None else 1
#         self.character = character or None
# 
#     def __repr__(self):
#         return '%s(%s)' % (
#             self.__class__.__name__,
#             ', '.join([
#                 repr(self.code),
#                 repr(self.message),
#                 repr(self.filename),
#                 repr(self.line),
#                 repr(self.character),
#             ]),
#         )
# 
# class AccessIssue(TidyPyIssue):
#     """
#     An issue indicating that a file/directory cannot be accessed (typically
#     due to permissions).
#     """
# 
#     def __init__(self, exc, filename):
#         super().__init__(
#             'access',
#             'Cannot access file (%s)' % (exc,),
#             filename,
#         )
# 
# class UnknownIssue(TidyPyIssue):
#     """
#     A completely unanticipated exception/problem was encountered during the
#     execution of a tool.
#     """
# 
#     def __init__(self, exc, filename):
#         super().__init__(
#             'unexpected',
#             'Unexpected error (%s)' % (exc,),
#             filename,
#         )


# Path: src/tidypy/tools/secrets.py
from detect_secrets import SecretsCollection
from detect_secrets.core.potential_secret import PotentialSecret
from detect_secrets.core.plugins.util import \
    get_mapping_from_secret_type_to_class
from detect_secrets.settings import transient_settings
from .base import Tool, Issue, AccessIssue, UnknownIssue

        detector = SecretsCollection()
        with transient_settings(settings):
            for filepath in finder.files(self.config['filters']):
                try:
                    detector.scan_file(filepath)
                except Exception as exc:  # pylint: disable=broad-except
                    issues.append(self.make_issue(exc, filepath))

            for filepath, problem in detector:
                issues.append(self.make_issue(problem, filepath))

        return issues

    def make_issue(self, problem, filename):
        if isinstance(problem, PotentialSecret):
            plugin = [
                plugin
                for plugin in PLUGINS
                if plugin.secret_type == problem.type
            ][0]
            return DetectSecretsIssue(
                plugin.__name__,
                DESCRIPTION.format(description=problem.type),
                filename,
                problem.line_number,
            )

        if isinstance(problem, EnvironmentError):
            return AccessIssue(problem, filename)


        return UnknownIssue(problem, filename)