示例#1
0
def run_lint(file_path: str, json_output_file: str) -> None:
    lint_log_dir = os.path.dirname(json_output_file)
    logging_setup(verbose=3, quiet=False, log_path=lint_log_dir)
    lint_manager = LintManager(input=file_path,
                               git=False,
                               all_packs=False,
                               quiet=False,
                               verbose=1,
                               prev_ver='',
                               json_file_path=json_output_file)
    lint_manager.run_dev_packages(
        parallel=1,
        no_flake8=False,
        no_xsoar_linter=False,
        no_bandit=False,
        no_mypy=False,
        no_pylint=True,
        no_coverage=True,
        coverage_report='',
        no_vulture=False,
        no_test=True,
        no_pwsh_analyze=True,
        no_pwsh_test=True,
        keep_container=False,
        test_xml='',
        failure_report=lint_log_dir,
        docker_timeout=60,
    )
示例#2
0
def lint(input: str, git: bool, all_packs: bool, verbose: int, quiet: bool,
         parallel: int, no_flake8: bool, no_bandit: bool, no_mypy: bool,
         no_vulture: bool, no_pylint: bool, no_test: bool,
         no_pwsh_analyze: bool, no_pwsh_test: bool, keep_container: bool,
         test_xml: str, failure_report: str, log_path: str):
    """Lint command will perform:\n
        1. Package in host checks - flake8, bandit, mypy, vulture.\n
        2. Package in docker image checks -  pylint, pytest, powershell - test, powershell - analyze.\n
    Meant to be used with integrations/scripts that use the folder (package) structure. Will lookup up what
    docker image to use and will setup the dev dependencies and file in the target folder."""
    lint_manager = LintManager(input=input,
                               git=git,
                               all_packs=all_packs,
                               verbose=verbose,
                               quiet=quiet,
                               log_path=log_path)
    return lint_manager.run_dev_packages(parallel=parallel,
                                         no_flake8=no_flake8,
                                         no_bandit=no_bandit,
                                         no_mypy=no_mypy,
                                         no_vulture=no_vulture,
                                         no_pylint=no_pylint,
                                         no_test=no_test,
                                         no_pwsh_analyze=no_pwsh_analyze,
                                         no_pwsh_test=no_pwsh_test,
                                         keep_container=keep_container,
                                         test_xml=test_xml,
                                         failure_report=failure_report)
示例#3
0
 def test_no_outfile_set(self, create_failed_unittests_file,
                         get_dev_requirements):
     _ = get_dev_requirements  # unused
     from demisto_sdk.commands.lint.lint_manager import LintManager
     lint_manager = LintManager('../../../../tests')
     lint_manager._print_final_results(['test'], ['test2'])
     assert create_failed_unittests_file.call_count == 0
     assert not os.path.isfile(self.outfile)
示例#4
0
    def test_no_test_failures(self):
        from demisto_sdk.commands.lint.lint_manager import LintManager

        self.outfile = 'several_failed_packages.txt'

        LintManager.create_failed_unittests_file([], self.outfile)
        assert os.path.isfile(self.outfile)
        with open(self.outfile) as file_:
            file_content = file_.read()

        assert file_content == ''
示例#5
0
    def test_sanity(self):
        from demisto_sdk.commands.lint.lint_manager import LintManager

        self.outfile = 'single_failed_package.txt'

        LintManager.create_failed_unittests_file(['asdf'], self.outfile)
        assert os.path.isfile(self.outfile)
        with open(self.outfile) as file_:
            file_content = file_.read()

        assert file_content == 'asdf'
def mock_lint_manager(mocker):
    mocker.patch.object(LintManager, '_get_packages', return_value=[])
    mocker.patch.object(LintManager,
                        '_gather_facts',
                        return_value={'content_repo': ''})
    return LintManager(input='',
                       git=False,
                       all_packs=False,
                       quiet=False,
                       verbose=False,
                       prev_ver='master',
                       json_file_path='path')
示例#7
0
def lint(config, dir, **kwargs):
    linter = LintManager(configuration=config.configuration,
                         project_dir_list=dir,
                         **kwargs)
    return linter.run_dev_packages()