Skip to content

ProjectChecker.scan_project() documentation #1722

@Brownies

Description

@Brownies

The doc is missing a positional argument source for scan_project() and running the example results in a TypeError: MyProjectChecker.scan_project() takes 2 positional arguments but 3 were given. Also, BaseChecker.report() doesn't accept str or even pathlib.Path types for the source argument. I did manage to work around this by instantiating a SourceFile. However, this seems somewhat cumbersome and feels like it might be a bug/missing feature instead of a documentation issue?

Here's what I came up with

from robocop.source_file import SourceFile

...

    def scan_project(self, source: SourceFile, config_manager: ConfigManager) -> None:
        files_count = 0
        for robot_file in config_manager.root.rglob("*.robot"):
            files_count += 1
            source_file = SourceFile(path=robot_file, config=config_manager.get_config_for_source_file(robot_file))
            self.report(self.project_checker, source=source_file)
        # files can be also parsed (with get_model) and checked here
        self.report(self.test_total_count, source=source, files=files_count)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions