Coverage for lintro / parsers / shfmt / shfmt_issue.py: 100%

10 statements  

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

1"""Shfmt issue model. 

2 

3This module defines a lightweight dataclass used to represent shfmt findings 

4in a normalized form that Lintro formatters can consume. 

5""" 

6 

7from __future__ import annotations 

8 

9from dataclasses import dataclass, field 

10from typing import ClassVar 

11 

12from lintro.enums.severity_level import SeverityLevel 

13from lintro.parsers.base_issue import BaseIssue 

14 

15 

16@dataclass 

17class ShfmtIssue(BaseIssue): 

18 """Represents a shfmt formatting issue. 

19 

20 Shfmt detects shell script formatting issues and outputs them in diff 

21 format. This class captures the file and line information along with 

22 the diff content showing what needs to be changed. 

23 

24 Attributes: 

25 DEFAULT_SEVERITY: Defaults to INFO (pure formatter). 

26 diff_content: The diff content showing the formatting change needed. 

27 Empty string if not available (e.g., when only file-level info 

28 is reported). 

29 fixable: Whether this issue can be auto-fixed by shfmt. Defaults to 

30 True since shfmt can fix all formatting issues it detects. 

31 """ 

32 

33 DEFAULT_SEVERITY: ClassVar[SeverityLevel] = SeverityLevel.INFO 

34 

35 diff_content: str = field(default="") 

36 fixable: bool = field(default=True)