|
8 | 8 | @copyright © 2026 AO Kaspersky Lab |
9 | 9 | @date 13.03.2026 |
10 | 10 |
|
11 | | -Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | +Licensed under the Apache License, Version 2.0 (the 'License'); |
12 | 12 | you may not use this file except in compliance with the License. |
13 | 13 | You may obtain a copy of the License at |
14 | 14 |
|
15 | 15 | http://www.apache.org/licenses/LICENSE-2.0 |
16 | 16 |
|
17 | 17 | Unless required by applicable law or agreed to in writing, software |
18 | | -distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | +distributed under the License is distributed on an 'AS IS' BASIS, |
19 | 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
20 | 20 | See the License for the specific language governing permissions and |
21 | 21 | limitations under the License. |
22 | 22 | """ |
23 | 23 |
|
24 | 24 |
|
25 | 25 | import subprocess |
| 26 | +import json |
26 | 27 |
|
27 | 28 |
|
28 | 29 | def run_lizard(path: str, nloc: int, complexity: int, token_count: int, arguments: int) -> None: |
29 | | - print(f"Running lizard in {path}") |
| 30 | + print(f'Running lizard in {path}') |
30 | 31 | command = [ |
31 | | - "lizard", |
| 32 | + 'lizard', |
32 | 33 | path, |
33 | | - "-T", |
34 | | - f"nloc={nloc}", |
35 | | - "-T", |
36 | | - f"cyclomatic_complexity={complexity}", |
37 | | - "-T", |
38 | | - f"token_count={token_count}", |
39 | | - "-T", |
40 | | - f"parameter_count={arguments}", |
41 | | - "-w", |
| 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', |
42 | 43 | ] |
43 | 44 | subprocess.run(command, check=False) |
44 | 45 | print() |
45 | 46 |
|
46 | 47 |
|
47 | | -run_lizard("knp", 50, 10, 300, 4) |
48 | | -run_lizard("examples", 100, 15, 500, 6) |
| 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