Python Scrutinizer

Python Scrutinizer goes beyond simple style checks for whether you make use of certain language features. We track how data flows through your application to find issues, compute intelligence, and much more.

Configuring Python Scrutinizer

Python Scrutinizer can be enabled in your configuration as follows:

build:
    nodes:
        analysis:
            project_setup:
                override: true
            tests:
                override: [py-scrutinizer-run]

Python Scrutinizer is triggered by the py-scrutinizer-run command.

List Dependency Paths

By default, Scrutinizer will inspect all files in your project directory excluding files found in site-packages. This might include files which you installed (f.e. dependencies). You can fine tune them using the filter configuration:

filter:
    excluded_paths:
        - "tests/"
        # Everything in a root level "tests" directory will be excluded
    dependency_paths:
        - "lib/"
        # Everything in a root level "lib" directory will be excluded from analysis
        # but treated as a dependency

The differences between excluded files and dependencies is that the analyzer will still consider modules defined in dependencies if they are used somewhere in your source code. Modules defined in excluded files however will not be found by the analyzer.

Controlling Analysis Speed

If you analyze a large project with thousands of files, there are basically two ways to speed up the analysis:

1) Reducing the scope of the analysis

You can move some of the files to dependency paths as documented above. This will prevent the analysis from searching for issues in those files, but at the same time, the analysis will still be aware of any classes or functions that are defined there and potentially used by other parts of your code.

This option usually makes sense if you embed dependencies in your project and not for code that you actively develop.

2) Increasing the number of CPU cores

By default, the analysis environment runs with a single CPU core. You can increase that number and the analysis will automatically take advantage of additional cores and parallelize the different internal tasks. This can be done in your configuration as follows:

build:
    nodes:
        analysis:
            resources:
                cpus: 4

With the above configuration, the analysis would use 4 CPU cores.

Note: The maximum number of CPUs you can use is equal to the number of containers your subscription has. If you only have a single container in your subscription, you can only use a single CPU for the analysis.