Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Note that it is possible to manually create a Python Analysis Unit if necessary:

  • In the Current Version tab, add a new Analysis Unit specifically for your Python source code, selecting the Add new Universal Analysis Unit option:

  • Edit the new Analysis Unit and configure in the Source Settings tab:
    • a name for the Analysis Unit
    • ensure you tick the Python option
    • define the location of the deployed Python source code (the CAST Management Studio will locate this automatically in the Deployment folder):

Automatic skipping of unit-test code and external libraries

The analyzer skips files that are recognized as forming part of testing code, i.e., in principle, code not pertaining to production code. The reason to avoid inclusion of testing code is that many Quality Rule violations are overrepresented in test code, either because code tends to be of poorer quality (certainly not critical) or prevalence of particular testing patterns. Accounting for test code would negatively impact the total score of the project.

Similarly we skip folders that contain external python libraries. Currently we only skip the canonical folders site-packages and dist-packages (the latter being used in certain Linux distributions). Not only analyzing external libraries is discouraged, but it can interfere with correct interpretation of supported libraries and frameworks, and have a serious impact in memory consumption and overall analysis performance.

The heuristics used by the analyzer are based on detecting unit-test library imports, and file and path naming conventions as summarized in the table below: 

TypeValueHeaderLinesMinimumCount
FilePath**/test_*.py

FilePath**/*_test.py

FilePath**/*_test_*.py

FilePath**/test/*.py

FilePath**/tests/*.py

FileContentimport unittest12
FileContentfrom unittest import12
FileContentfrom nose.tools import12
FileContentself.assert
2

...





FilePath

...

**/site-packages/**

FilePath**/dist-packages/**


Info
The ** symbol represents any arbitrary path string, whereas * represents any string without directory slashes.

...

The following structural rules are provided:

...