Coverage for lintro / parsers / shellcheck / shellcheck_issue.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Shellcheck issue model. 

2 

3This module defines the dataclass for representing issues found by ShellCheck, 

4a static analysis tool for shell scripts. 

5""" 

6 

7from __future__ import annotations 

8 

9from dataclasses import dataclass, field 

10from typing import ClassVar 

11 

12from lintro.parsers.base_issue import BaseIssue 

13 

14 

15@dataclass 

16class ShellcheckIssue(BaseIssue): 

17 """Represents an issue found by shellcheck. 

18 

19 ShellCheck outputs issues in JSON format with the following structure: 

20 - file: Path to the file with the issue 

21 - line: Line number where the issue starts 

22 - column: Column number where the issue starts 

23 - endLine: Line number where the issue ends (optional) 

24 - endColumn: Column number where the issue ends (optional) 

25 - level: Severity level (error, warning, info, style) 

26 - code: SC code number (e.g., 2086) 

27 - message: Human-readable description of the issue 

28 

29 Attributes: 

30 DISPLAY_FIELD_MAP: Mapping of display field names to attribute names. 

31 level: Severity level (error, warning, info, style). 

32 code: SC code number as string (e.g., "SC2086"). 

33 end_line: Line number where the issue ends (0 if not available). 

34 end_column: Column number where the issue ends (0 if not available). 

35 """ 

36 

37 DISPLAY_FIELD_MAP: ClassVar[dict[str, str]] = { 

38 **BaseIssue.DISPLAY_FIELD_MAP, 

39 "severity": "level", 

40 } 

41 

42 level: str = field(default="error") 

43 code: str = field(default="") 

44 end_line: int = field(default=0) 

45 end_column: int = field(default=0)