Coverage for src/pylint_sort_functions/messages.py: 100%
1 statements
« prev ^ index » next coverage.py v7.10.1, created at 2025-08-12 16:06 +0200
« prev ^ index » next coverage.py v7.10.1, created at 2025-08-12 16:06 +0200
1"""Message definitions for the pylint-sort-functions plugin.
3The MESSAGES dict defines all warning/error codes that this PyLint plugin can report.
4Each entry creates a new PyLint message that users will see when running PyLint.
6Message Structure:
7 Key: Message ID (e.g., "W9001")
8 - First letter: Severity (W=Warning, E=Error, C=Convention, R=Refactor)
9 - Digits: Plugin's unique range (9001-9999 for custom plugins)
11 Value: Tuple of (template, symbol, description)
12 - Template: Actual message shown to users (supports %s formatting)
13 - Symbol: Human-readable name for disabling (e.g., unsorted-functions)
14 - Description: Longer explanation for documentation/help
16Usage Examples:
17 In checker: self.add_message("unsorted-functions", node=node, args=("module",))
18 PyLint output: W9001: Functions are not sorted alphabetically in module scope
19 (unsorted-functions)
20 User disabling: # pylint: disable=unsorted-functions
21"""
23# Message format: (message_template, message_symbol, message_description)
24MESSAGES: dict[str, tuple[str, str, str]] = {
25 "W9001": (
26 "Functions are not sorted alphabetically in %s scope",
27 "unsorted-functions",
28 "Functions should be organized alphabetically within their scope "
29 "(public functions first, then private functions with underscore prefix)",
30 ),
31 "W9002": (
32 "Methods are not sorted alphabetically in class %s",
33 "unsorted-methods",
34 "Class methods should be organized alphabetically within their "
35 "visibility scope (public methods first, then private methods "
36 "with underscore prefix)",
37 ),
38 "W9003": (
39 "Public and private functions are not properly separated in %s",
40 "mixed-function-visibility",
41 "Public functions (no underscore prefix) should come before private functions "
42 "(underscore prefix) with clear separation",
43 ),
44 "W9004": (
45 "Function '%s' should be private (prefix with underscore)",
46 "function-should-be-private",
47 "Functions that are only used within their defining module should be marked "
48 "as private by prefixing their name with an underscore. This rule detects "
49 "functions with helper/utility naming patterns (get_, validate_, process_, "
50 "helper, etc.) that are called only within the same module. Note: Cannot "
51 "detect cross-module usage, so functions used by other modules won't be "
52 "flagged (which reduces false positives).",
53 ),
54 "W9005": (
55 "Function '%s' should be public (remove underscore prefix)",
56 "function-should-be-public",
57 "Functions that are currently marked as private (underscore prefix) but are "
58 "used by other modules should be made public by removing the underscore "
59 "prefix. This rule detects cross-module imports and usage of private "
60 "functions, indicating they are part of the module's public API.",
61 ),
62 "W9006": (
63 "Method '%s' is in wrong section (expected: %s, found: %s)",
64 "method-wrong-section",
65 "Method appears under an incorrect section header. Methods should be "
66 "organized under section headers that match their categorization "
67 "(e.g., test methods under '# Test methods', properties under "
68 "'# Properties'). Enable section header enforcement with "
69 "enforce-section-headers=true.",
70 ),
71 "W9007": (
72 "Missing section header '%s' for methods in category '%s'",
73 "missing-section-header",
74 "A section header is required for methods in this category, but no "
75 "matching header was found. Add the appropriate section header comment "
76 "before methods of this type. Enable with require-section-headers=true.",
77 ),
78 "W9008": (
79 "Section header '%s' has no matching methods",
80 "empty-section-header",
81 "Section header exists but contains no methods underneath. Either add "
82 "methods to this section or remove the unnecessary header. Control with "
83 "allow-empty-sections configuration option.",
84 ),
85}