perl_lsp_diagnostics/lints/mod.rs
1//! Lint checks for Perl code analysis
2//!
3//! This module provides various linting checks for detecting deprecated syntax,
4//! strict/warnings issues, common mistakes, and security anti-patterns in Perl code.
5//!
6//! # Architecture
7//!
8//! Lints are organized into focused submodules:
9//!
10//! - **deprecated**: Deprecated syntax warnings (e.g., `defined(@array)`)
11//! - **strict_warnings**: Missing `use strict` / `use warnings` advisories and
12//! misspelled pragma detection
13//! - **common_mistakes**: Frequent programming errors (assignment in conditions, etc.)
14//! - **security**: Security anti-patterns (two-arg open, string eval, backtick execution)
15//!
16//! # Diagnostic Code Reference
17//!
18//! Every diagnostic carries a `code` field that IDEs can use for quick-fix
19//! integration, filtering, and documentation lookup.
20//!
21//! ## Parse errors (`diagnostics.rs`)
22//!
23//! | Code | Severity | Description |
24//! |------|----------|-------------|
25//! | `parse-error` | Error | Generic parse error from the parser |
26//!
27//! ## Scope issues (`scope.rs`)
28//!
29//! | Code | Severity | Description |
30//! |------|----------|-------------|
31//! | `undeclared-variable` | Error | Variable used without declaration |
32//! | `variable-redeclaration` | Error | Duplicate `my` in same scope |
33//! | `duplicate-parameter` | Error | Same parameter name twice |
34//! | `unquoted-bareword` | Error | Bareword not allowed under strict |
35//! | `variable-shadowing` | Warning | Inner variable hides outer |
36//! | `unused-variable` | Warning | Declared but never read |
37//! | `unused-parameter` | Warning | Subroutine parameter never used |
38//! | `parameter-shadows-global` | Warning | Parameter hides package var |
39//! | `uninitialized-variable` | Warning | Used before assignment |
40//!
41//! ## Deprecated syntax (`deprecated.rs`)
42//!
43//! | Code | Severity | Description |
44//! |------|----------|-------------|
45//! | `deprecated-defined` | Warning | `defined(@array)` or `defined(%hash)` |
46//! | `deprecated-array-base` | Warning | Use of `$[` variable |
47//!
48//! ## Strict / warnings (`strict_warnings.rs`)
49//!
50//! | Code | Severity | Description |
51//! |------|----------|-------------|
52//! | `missing-strict` | Information | `use strict` not found |
53//! | `missing-warnings` | Information | `use warnings` not found |
54//! | `misspelled-pragma` | Warning | Pragma name appears misspelled |
55//!
56//! ## Common mistakes (`common_mistakes.rs`)
57//!
58//! | Code | Severity | Description |
59//! |------|----------|-------------|
60//! | `assignment-in-condition` | Warning | `=` used where `==` likely intended |
61//! | `numeric-undef` | Warning | `==`/`!=` with potentially undef value |
62//!
63//! ## Security (`security.rs`)
64//!
65//! | Code | Severity | Description |
66//! |------|----------|-------------|
67//! | `security-two-arg-open` | Warning | `open(FH, ">file")` -- use 3-arg open |
68//! | `security-string-eval` | Warning | `eval "$string"` is a security risk |
69//! | `security-backtick-exec` | Information | Backtick/qx command execution detected |
70//!
71//! ## Package / subroutine (`package_subroutine.rs`)
72//!
73//! | Code | Severity | Description |
74//! |------|----------|-------------|
75//! | `PL200` | Warning | File has no package declaration |
76//! | `PL201` | Warning | Package name declared more than once |
77//! | `PL300` | Warning | Subroutine name defined more than once |
78//!
79//! ## Dead code (`dead_code.rs`)
80//!
81//! | Code | Severity | Description |
82//! |------|----------|-------------|
83//! | `dead-code-subroutine` | Hint | Subroutine with no callers |
84//! | `dead-code-variable` | Hint | Package variable with no references |
85//! | `dead-code-constant` | Hint | Constant with no references |
86//! | `dead-code-package` | Hint | Package with no references |
87//!
88//! # Severity Levels
89//!
90//! Each lint produces diagnostics with appropriate severity:
91//!
92//! - **Error**: Issues that will cause runtime failures
93//! - **Warning**: Potential bugs or deprecated patterns
94//! - **Information**: Best practice suggestions
95//! - **Hint**: Style recommendations
96//!
97//! # Integration
98//!
99//! Lints integrate with the diagnostics pipeline and provide:
100//!
101//! - Diagnostic codes for IDE quick-fix integration
102//! - Related information with suggestions and explanations
103//! - Diagnostic tags (Deprecated, Unnecessary) for IDE rendering
104
105pub mod common_mistakes;
106pub mod deprecated;
107/// Missing module detection (PL701)
108pub mod missing_module;
109/// Package and subroutine diagnostics (PL200, PL201, PL300)
110pub mod package_subroutine;
111/// printf/sprintf format specifier arity validation (PL405)
112pub mod printf_format;
113pub mod security;
114pub mod strict_warnings;
115/// Unused import detection
116pub mod unused_imports;
117/// Perl version compatibility warnings (PL900)
118pub mod version_compat;