|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +@file run_lizard.py |
| 4 | +@brief Run lizard static analyzer. |
| 5 | +
|
| 6 | +@kaspersky_support David P. |
| 7 | +@license Apache 2.0 License. |
| 8 | +@copyright © 2026 AO Kaspersky Lab |
| 9 | +@date 13.03.2026 |
| 10 | +
|
| 11 | +Licensed under the Apache License, Version 2.0 (the 'License'); |
| 12 | +you may not use this file except in compliance with the License. |
| 13 | +You may obtain a copy of the License at |
| 14 | +
|
| 15 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | +
|
| 17 | +Unless required by applicable law or agreed to in writing, software |
| 18 | +distributed under the License is distributed on an 'AS IS' BASIS, |
| 19 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | +See the License for the specific language governing permissions and |
| 21 | +limitations under the License. |
| 22 | +""" |
| 23 | + |
| 24 | + |
| 25 | +import subprocess |
| 26 | +import json |
| 27 | + |
| 28 | + |
| 29 | +def run_lizard(path: str, nloc: int, complexity: int, token_count: int, arguments: int) -> None: |
| 30 | + print(f'Running lizard in {path}') |
| 31 | + command = [ |
| 32 | + 'lizard', |
| 33 | + path, |
| 34 | + '-T', |
| 35 | + f'nloc={nloc}', |
| 36 | + '-T', |
| 37 | + f'cyclomatic_complexity={complexity}', |
| 38 | + '-T', |
| 39 | + f'token_count={token_count}', |
| 40 | + '-T', |
| 41 | + f'parameter_count={arguments}', |
| 42 | + '-w', |
| 43 | + ] |
| 44 | + subprocess.run(command, check=False) |
| 45 | + print() |
| 46 | + |
| 47 | + |
| 48 | +# Parse config. |
| 49 | +with open('ci/lizard_config.json', encoding='UTF-8') as config_file: |
| 50 | + config = json.load(config_file) |
| 51 | + for directory in config['directories']: |
| 52 | + run_lizard( |
| 53 | + directory['directory'], |
| 54 | + directory['nloc'], |
| 55 | + directory['cyclomatic_complexity'], |
| 56 | + directory['token_count'], |
| 57 | + directory['parameter_count'], |
| 58 | + ) |
0 commit comments