1: ---
2: title: "Example"
3: ---
4:
5: This file contains some issues for the linter to identify.
6:
7: ```{python}
8: # Function with low complexity
9: def simple_addition(a, b):
10: return a + b
11: ```
12:
13: There's another function to check below:
14:
15: ```{python}
16: # Function with moderate complexity
17: def check_number(num, flag, extra):
18: if num > 100:
19: if flag:
20: if extra:
21: return "Huge and flagged and extra"
22: else:
23: return "Huge and flagged"
24: else:
25: if extra:
26: return "Huge and extra"
27: else:
28: return "Huge"
29: elif num > 50:
30: if flag:
31: return "Medium and flagged"
32: else:
33: return "Medium"
34: elif num > 10:
35: if extra:
36: return "Small and extra"
37: else:
38: return "Small"
39: else:
40: if flag or extra:
41: return "Tiny but special"
42: else:
43: return "Tiny"
44: ```
radon
Computes code metrics - lintquarto
supports calculating complexity metrics.
Example Quarto .qmd
file:
Run radon using lintquarto
lintquarto -l radon -p complexity_example.qmd
=============================================================
Running radon...
=============================================================
/home/runner/work/lintquarto/lintquarto/docs/pages/tools/examples/complexity_example.qmd
F 17:0 check_number - C
F 9:0 simple_addition - A