Coverage for analyzers / go.py: 92%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-08 15:04 -0800

1"""Go source file analyzer -- assembles all metrics.""" 

2 

3from __future__ import annotations 

4 

5from analyzers.shared import create_analyzer_file_fn, create_analyzer_source_fn 

6from parsers.go import parse, collect_functions, func_name 

7from metrics.lloc.go import count_lloc 

8from metrics.halstead.go import compute_halstead_go 

9from metrics.npath.go import compute_npath_go 

10from metrics.dtd.go import compute_dtd_go 

11from metrics.cognitive.go import compute_cognitive_go 

12from metrics.cyclomatic.go import compute_cyclomatic_go 

13from metrics.duplication.config import GO_CONFIG 

14 

15analyze_source = create_analyzer_source_fn( 

16 parse_fn=parse, 

17 collect_functions_fn=collect_functions, 

18 func_name_fn=func_name, 

19 compute_cognitive_fn=compute_cognitive_go, 

20 compute_halstead_fn=compute_halstead_go, 

21 compute_npath_fn=compute_npath_go, 

22 compute_dtd_fn=compute_dtd_go, 

23 compute_cyclomatic_fn=compute_cyclomatic_go, 

24 count_lloc_fn=count_lloc, 

25 dup_config=GO_CONFIG, 

26) 

27 

28 

29def analyze_file(filepath, timing_manager=None): 

30 """Analyze a Go file and return cognitive complexity scores.""" 

31 return create_analyzer_file_fn(analyze_source)( 

32 filepath, timing_manager=timing_manager 

33 )