How to use the dlint.linters.BadInputUseLinter function in dlint

To help you get started, we’ve selected a few dlint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
def test_bad_input_usage(self):
        python_node = self.get_ast_node(
            """
            var = 1

            result = input('var + 1')
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [] if not IS_PYTHON_2 else [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=9,
                message=dlint.linters.BadInputUseLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
def test_six_moves_input_usage(self):
        python_node = self.get_ast_node(
            """
            from six.moves import input

            var = 1

            result = input('var + 1')
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
def test_empty(self):
        python_node = self.get_ast_node(
            """
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
"""
            var = 1

            result = input('var + 1')
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [] if not IS_PYTHON_2 else [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=9,
                message=dlint.linters.BadInputUseLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
def test_bad_input_variable_usage(self):
        python_node = self.get_ast_node(
            """
            input = 1
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected
github duo-labs / dlint / tests / test_bad_input_use.py View on Github external
def test_no_input_usage(self):
        python_node = self.get_ast_node(
            """
            import os

            var = 'test'

            os.path.join(var)
            """
        )

        linter = dlint.linters.BadInputUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected