flowbber.plugins.sources.sloc

SLOC

This source count source lines of code. It scans a directory for source code files, identify their language and count the number of code, comments and empty lines. It is highly tunable using include and exclude patterns as explained below. It is implemented on top of pygount, which is very accurate, but not the fastest. Benchmark on HUGE code bases.

Data collected:

{
    "sloc": {
        "html": {
            "string": 0,
            "empty": 59,
            "code": 129,
            "documentation": 7
        },
        "python": {
            "string": 362,
            "empty": 1532,
            "code": 2262,
            "documentation": 4291
        },
        "restructuredtext": {
            "string": 73,
            "empty": 619,
            "code": 1133,
            "documentation": 19
        },
    },
    "files": {
        "setup.py": "python",
        "lib/flowbber/main.py": "python",
        "... more collected files ...": "<language detected>"
    }
}

Dependencies:

pip3 install flowbber[sloc]

Usage:

[[sources]]
type = "sloc"
id = "..."

    [sources.config]
    directory = "{git.root}"
    include = ["*"]
    exclude = []
{
    "sources": [
        {
            "type": "sloc",
            "id": "...",
            "config": {
                "directory": "{git.root}",
                "include": ["*"],
                "exclude": []
            }
        }
    ]
}

directory

Root directory to search for files.

  • Default: '.'

  • Optional: True

  • Schema:

    {
        'type': 'string',
        'empty': False,
    }
    
  • Secret: False

include

List of patterns of files to include.

Matching is performed using Python’s fnmatch.

  • Default: ['*']

  • Optional: True

  • Schema:

    {
        'type': 'list',
        'schema': {
            'type': 'string',
        },
    }
    
  • Secret: False

exclude

List of patterns of files to exclude.

Matching is performed using Python’s fnmatch.

  • Default:

    [
        '.tox', '.git', '.cache',
        '__pycache__', '**/__pycache__',
        '*.pyc', '*.egg-info'
    ]
    
  • Optional: True

  • Schema:

    {
        'type': 'list',
        'schema': {
            'type': 'string',
        },
    }
    
  • Secret: False

Classes

  • SLOCSource: Main base class to implement a Source.
class flowbber.plugins.sources.sloc.SLOCSource(index, type_, id_, optional=False, timeout=None, config=None)

Inheritance

Inheritance diagram of SLOCSource