thailint 0.4.4__tar.gz → 0.4.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {thailint-0.4.4 → thailint-0.4.6}/PKG-INFO +31 -30
  2. {thailint-0.4.4 → thailint-0.4.6}/README.md +29 -28
  3. {thailint-0.4.4 → thailint-0.4.6}/pyproject.toml +2 -2
  4. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/python_analyzer.py +148 -39
  5. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/token_hasher.py +63 -9
  6. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/typescript_analyzer.py +7 -5
  7. thailint-0.4.6/src/linters/file_header/__init__.py +24 -0
  8. thailint-0.4.6/src/linters/file_header/atemporal_detector.py +87 -0
  9. thailint-0.4.6/src/linters/file_header/config.py +66 -0
  10. thailint-0.4.6/src/linters/file_header/field_validator.py +69 -0
  11. thailint-0.4.6/src/linters/file_header/linter.py +313 -0
  12. thailint-0.4.6/src/linters/file_header/python_parser.py +86 -0
  13. thailint-0.4.6/src/linters/file_header/violation_builder.py +78 -0
  14. {thailint-0.4.4 → thailint-0.4.6}/CHANGELOG.md +0 -0
  15. {thailint-0.4.4 → thailint-0.4.6}/LICENSE +0 -0
  16. {thailint-0.4.4 → thailint-0.4.6}/src/__init__.py +0 -0
  17. {thailint-0.4.4 → thailint-0.4.6}/src/analyzers/__init__.py +0 -0
  18. {thailint-0.4.4 → thailint-0.4.6}/src/analyzers/typescript_base.py +0 -0
  19. {thailint-0.4.4 → thailint-0.4.6}/src/api.py +0 -0
  20. {thailint-0.4.4 → thailint-0.4.6}/src/cli.py +0 -0
  21. {thailint-0.4.4 → thailint-0.4.6}/src/config.py +0 -0
  22. {thailint-0.4.4 → thailint-0.4.6}/src/core/__init__.py +0 -0
  23. {thailint-0.4.4 → thailint-0.4.6}/src/core/base.py +0 -0
  24. {thailint-0.4.4 → thailint-0.4.6}/src/core/cli_utils.py +0 -0
  25. {thailint-0.4.4 → thailint-0.4.6}/src/core/config_parser.py +0 -0
  26. {thailint-0.4.4 → thailint-0.4.6}/src/core/linter_utils.py +0 -0
  27. {thailint-0.4.4 → thailint-0.4.6}/src/core/registry.py +0 -0
  28. {thailint-0.4.4 → thailint-0.4.6}/src/core/rule_discovery.py +0 -0
  29. {thailint-0.4.4 → thailint-0.4.6}/src/core/types.py +0 -0
  30. {thailint-0.4.4 → thailint-0.4.6}/src/core/violation_builder.py +0 -0
  31. {thailint-0.4.4 → thailint-0.4.6}/src/linter_config/__init__.py +0 -0
  32. {thailint-0.4.4 → thailint-0.4.6}/src/linter_config/ignore.py +0 -0
  33. {thailint-0.4.4 → thailint-0.4.6}/src/linter_config/loader.py +0 -0
  34. {thailint-0.4.4 → thailint-0.4.6}/src/linters/__init__.py +0 -0
  35. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/__init__.py +0 -0
  36. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/base_token_analyzer.py +0 -0
  37. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/block_filter.py +0 -0
  38. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/block_grouper.py +0 -0
  39. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/cache.py +0 -0
  40. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/cache_query.py +0 -0
  41. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/config.py +0 -0
  42. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/config_loader.py +0 -0
  43. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/deduplicator.py +0 -0
  44. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/duplicate_storage.py +0 -0
  45. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/file_analyzer.py +0 -0
  46. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/inline_ignore.py +0 -0
  47. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/linter.py +0 -0
  48. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/storage_initializer.py +0 -0
  49. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/violation_builder.py +0 -0
  50. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/violation_filter.py +0 -0
  51. {thailint-0.4.4 → thailint-0.4.6}/src/linters/dry/violation_generator.py +0 -0
  52. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/__init__.py +0 -0
  53. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/config_loader.py +0 -0
  54. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/directory_matcher.py +0 -0
  55. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/linter.py +0 -0
  56. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/path_resolver.py +0 -0
  57. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/pattern_matcher.py +0 -0
  58. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/pattern_validator.py +0 -0
  59. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/rule_checker.py +0 -0
  60. {thailint-0.4.4 → thailint-0.4.6}/src/linters/file_placement/violation_factory.py +0 -0
  61. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/__init__.py +0 -0
  62. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/config.py +0 -0
  63. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/context_analyzer.py +0 -0
  64. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/linter.py +0 -0
  65. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/python_analyzer.py +0 -0
  66. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/typescript_analyzer.py +0 -0
  67. {thailint-0.4.4 → thailint-0.4.6}/src/linters/magic_numbers/violation_builder.py +0 -0
  68. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/__init__.py +0 -0
  69. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/config.py +0 -0
  70. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/linter.py +0 -0
  71. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/python_analyzer.py +0 -0
  72. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/typescript_analyzer.py +0 -0
  73. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/typescript_function_extractor.py +0 -0
  74. {thailint-0.4.4 → thailint-0.4.6}/src/linters/nesting/violation_builder.py +0 -0
  75. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/__init__.py +0 -0
  76. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/class_analyzer.py +0 -0
  77. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/config.py +0 -0
  78. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/heuristics.py +0 -0
  79. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/linter.py +0 -0
  80. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/metrics_evaluator.py +0 -0
  81. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/python_analyzer.py +0 -0
  82. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/typescript_analyzer.py +0 -0
  83. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/typescript_metrics_calculator.py +0 -0
  84. {thailint-0.4.4 → thailint-0.4.6}/src/linters/srp/violation_builder.py +0 -0
  85. {thailint-0.4.4 → thailint-0.4.6}/src/orchestrator/__init__.py +0 -0
  86. {thailint-0.4.4 → thailint-0.4.6}/src/orchestrator/core.py +0 -0
  87. {thailint-0.4.4 → thailint-0.4.6}/src/orchestrator/language_detector.py +0 -0
  88. {thailint-0.4.4 → thailint-0.4.6}/src/templates/thailint_config_template.yaml +0 -0
  89. {thailint-0.4.4 → thailint-0.4.6}/src/utils/__init__.py +0 -0
  90. {thailint-0.4.4 → thailint-0.4.6}/src/utils/project_root.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thailint
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: The AI Linter - Enterprise-grade linting and governance for AI-generated code across multiple languages
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -28,7 +28,7 @@ Requires-Dist: pyprojroot (>=0.3.0,<0.4.0)
28
28
  Requires-Dist: pyyaml (>=6.0,<7.0)
29
29
  Requires-Dist: tree-sitter (>=0.25.2,<0.26.0)
30
30
  Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
31
- Project-URL: Documentation, https://github.com/be-wise-be-kind/thai-lint#readme
31
+ Project-URL: Documentation, https://thai-lint.readthedocs.io/
32
32
  Project-URL: Homepage, https://github.com/be-wise-be-kind/thai-lint
33
33
  Project-URL: Repository, https://github.com/be-wise-be-kind/thai-lint
34
34
  Description-Content-Type: text/markdown
@@ -37,19 +37,20 @@ Description-Content-Type: text/markdown
37
37
 
38
38
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
39
  [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
40
- [![Tests](https://img.shields.io/badge/tests-296%2F296%20passing-brightgreen.svg)](tests/)
40
+ [![Tests](https://img.shields.io/badge/tests-356%2F356%20passing-brightgreen.svg)](tests/)
41
41
  [![Coverage](https://img.shields.io/badge/coverage-87%25-brightgreen.svg)](htmlcov/)
42
+ [![Documentation Status](https://readthedocs.org/projects/thai-lint/badge/?version=latest)](https://thai-lint.readthedocs.io/en/latest/?badge=latest)
42
43
 
43
44
  The AI Linter - Enterprise-ready linting and governance for AI-generated code across multiple languages.
44
45
 
45
46
  ## Documentation
46
47
 
47
48
  **New to thailint?** Start here:
48
- - **[Quick Start Guide](docs/quick-start.md)** - Get running in 5 minutes
49
- - **[Configuration Reference](docs/configuration.md)** - Complete config options for all linters
50
- - **[Troubleshooting Guide](docs/troubleshooting.md)** - Common issues and solutions
49
+ - **[Quick Start Guide](https://thai-lint.readthedocs.io/en/latest/quick-start/)** - Get running in 5 minutes
50
+ - **[Configuration Reference](https://thai-lint.readthedocs.io/en/latest/configuration/)** - Complete config options for all linters
51
+ - **[Troubleshooting Guide](https://thai-lint.readthedocs.io/en/latest/troubleshooting/)** - Common issues and solutions
51
52
 
52
- **Full Documentation:** Browse the **[docs/](docs/)** folder for comprehensive guides covering installation, all linters, configuration patterns, and integration examples.
53
+ **Full Documentation:** Browse the **[documentation site](https://thai-lint.readthedocs.io/)** for comprehensive guides covering installation, all linters, configuration patterns, and integration examples.
53
54
 
54
55
  ## Overview
55
56
 
@@ -66,7 +67,7 @@ We're not trying to replace the wonderful existing linters like Pylint, ESLint,
66
67
 
67
68
  thailint complements your existing linting stack by catching the patterns AI tools repeatedly miss.
68
69
 
69
- **Complete documentation available in the [docs/](docs/) folder** covering installation, configuration, all linters, and troubleshooting.
70
+ **Complete documentation available at [thai-lint.readthedocs.io](https://thai-lint.readthedocs.io/)** covering installation, configuration, all linters, and troubleshooting.
70
71
 
71
72
  ## Features
72
73
 
@@ -164,7 +165,7 @@ thailint dry --config .thailint.yaml src/
164
165
  thailint dry --format json src/
165
166
  ```
166
167
 
167
- **New to thailint?** See the **[Quick Start Guide](docs/quick-start.md)** for a complete walkthrough including config generation, understanding output, and next steps.
168
+ **New to thailint?** See the **[Quick Start Guide](https://thai-lint.readthedocs.io/en/latest/quick-start/)** for a complete walkthrough including config generation, understanding output, and next steps.
168
169
 
169
170
  ### Library Mode
170
171
 
@@ -356,9 +357,9 @@ magic-numbers:
356
357
  }
357
358
  ```
358
359
 
359
- See [Configuration Guide](docs/configuration.md) for complete reference.
360
+ See [Configuration Guide](https://thai-lint.readthedocs.io/en/latest/configuration/) for complete reference.
360
361
 
361
- **Need help with ignores?** See **[How to Ignore Violations](docs/how-to-ignore-violations.md)** for complete guide to all ignore levels (line, method, class, file, repository).
362
+ **Need help with ignores?** See **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** for complete guide to all ignore levels (line, method, class, file, repository).
362
363
 
363
364
  ## Nesting Depth Linter
364
365
 
@@ -444,7 +445,7 @@ Common patterns to reduce nesting:
444
445
  - **TypeScript**: Full support (if/for/while/try/switch)
445
446
  - **JavaScript**: Supported via TypeScript parser
446
447
 
447
- See [Nesting Linter Guide](docs/nesting-linter.md) for comprehensive documentation and refactoring patterns.
448
+ See [Nesting Linter Guide](https://thai-lint.readthedocs.io/en/latest/nesting-linter/) for comprehensive documentation and refactoring patterns.
448
449
 
449
450
  ## Single Responsibility Principle (SRP) Linter
450
451
 
@@ -561,7 +562,7 @@ Common patterns to fix SRP violations (discovered during dogfooding):
561
562
  - **After**: Extract Class pattern applied - 5 focused classes (ConfigLoader, PatternValidator, RuleChecker, PathResolver, FilePlacementLinter)
562
563
  - **Result**: Each class ≤8 methods, ≤150 LOC, single responsibility
563
564
 
564
- See [SRP Linter Guide](docs/srp-linter.md) for comprehensive documentation and refactoring patterns.
565
+ See [SRP Linter Guide](https://thai-lint.readthedocs.io/en/latest/srp-linter/) for comprehensive documentation and refactoring patterns.
565
566
 
566
567
  ## DRY Linter (Don't Repeat Yourself)
567
568
 
@@ -714,7 +715,7 @@ Built-in filters automatically exclude common non-duplication patterns:
714
715
  3. **Extract Utility Module**: Move helper functions to shared utilities
715
716
  4. **Template Method**: Use function parameters for variations
716
717
 
717
- See [DRY Linter Guide](docs/dry-linter.md) for comprehensive documentation, storage modes, and refactoring patterns.
718
+ See [DRY Linter Guide](https://thai-lint.readthedocs.io/en/latest/dry-linter/) for comprehensive documentation, storage modes, and refactoring patterns.
718
719
 
719
720
  ## Magic Numbers Linter
720
721
 
@@ -866,7 +867,7 @@ def get_ports(): # thailint: ignore[magic-numbers] - Standard ports
866
867
  # thailint: ignore-file[magic-numbers]
867
868
  ```
868
869
 
869
- See **[How to Ignore Violations](docs/how-to-ignore-violations.md)** and **[Magic Numbers Linter Guide](docs/magic-numbers-linter.md)** for complete documentation.
870
+ See **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** and **[Magic Numbers Linter Guide](https://thai-lint.readthedocs.io/en/latest/magic-numbers-linter/)** for complete documentation.
870
871
 
871
872
  ## Pre-commit Hooks
872
873
 
@@ -928,7 +929,7 @@ repos:
928
929
  pass_filenames: true
929
930
  ```
930
931
 
931
- See **[Pre-commit Hooks Guide](docs/pre-commit-hooks.md)** for complete documentation, troubleshooting, and advanced configuration.
932
+ See **[Pre-commit Hooks Guide](https://thai-lint.readthedocs.io/en/latest/pre-commit-hooks/)** for complete documentation, troubleshooting, and advanced configuration.
932
933
 
933
934
  ## Common Use Cases
934
935
 
@@ -1145,20 +1146,20 @@ docker run --rm -v /path/to/workspace:/workspace \
1145
1146
 
1146
1147
  ### Comprehensive Guides
1147
1148
 
1148
- - **[Getting Started](docs/getting-started.md)** - Installation, first lint, basic config
1149
- - **[Configuration Reference](docs/configuration.md)** - Complete config options (YAML/JSON)
1150
- - **[How to Ignore Violations](docs/how-to-ignore-violations.md)** - Complete guide to all ignore levels
1151
- - **[API Reference](docs/api-reference.md)** - Library API documentation
1152
- - **[CLI Reference](docs/cli-reference.md)** - All CLI commands and options
1153
- - **[Deployment Modes](docs/deployment-modes.md)** - CLI, Library, and Docker usage
1154
- - **[File Placement Linter](docs/file-placement-linter.md)** - Detailed linter guide
1155
- - **[Magic Numbers Linter](docs/magic-numbers-linter.md)** - Magic numbers detection guide
1156
- - **[Nesting Depth Linter](docs/nesting-linter.md)** - Nesting depth analysis guide
1157
- - **[SRP Linter](docs/srp-linter.md)** - Single Responsibility Principle guide
1158
- - **[DRY Linter](docs/dry-linter.md)** - Duplicate code detection guide
1159
- - **[Pre-commit Hooks](docs/pre-commit-hooks.md)** - Automated quality checks
1160
- - **[Publishing Guide](docs/releasing.md)** - Release and publishing workflow
1161
- - **[Publishing Checklist](docs/publishing-checklist.md)** - Post-publication validation
1149
+ - **[Getting Started](https://thai-lint.readthedocs.io/en/latest/getting-started/)** - Installation, first lint, basic config
1150
+ - **[Configuration Reference](https://thai-lint.readthedocs.io/en/latest/configuration/)** - Complete config options (YAML/JSON)
1151
+ - **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** - Complete guide to all ignore levels
1152
+ - **[API Reference](https://thai-lint.readthedocs.io/en/latest/api-reference/)** - Library API documentation
1153
+ - **[CLI Reference](https://thai-lint.readthedocs.io/en/latest/cli-reference/)** - All CLI commands and options
1154
+ - **[Deployment Modes](https://thai-lint.readthedocs.io/en/latest/deployment-modes/)** - CLI, Library, and Docker usage
1155
+ - **[File Placement Linter](https://thai-lint.readthedocs.io/en/latest/file-placement-linter/)** - Detailed linter guide
1156
+ - **[Magic Numbers Linter](https://thai-lint.readthedocs.io/en/latest/magic-numbers-linter/)** - Magic numbers detection guide
1157
+ - **[Nesting Depth Linter](https://thai-lint.readthedocs.io/en/latest/nesting-linter/)** - Nesting depth analysis guide
1158
+ - **[SRP Linter](https://thai-lint.readthedocs.io/en/latest/srp-linter/)** - Single Responsibility Principle guide
1159
+ - **[DRY Linter](https://thai-lint.readthedocs.io/en/latest/dry-linter/)** - Duplicate code detection guide
1160
+ - **[Pre-commit Hooks](https://thai-lint.readthedocs.io/en/latest/pre-commit-hooks/)** - Automated quality checks
1161
+ - **[Publishing Guide](https://thai-lint.readthedocs.io/en/latest/releasing/)** - Release and publishing workflow
1162
+ - **[Publishing Checklist](https://thai-lint.readthedocs.io/en/latest/publishing-checklist/)** - Post-publication validation
1162
1163
 
1163
1164
  ### Examples
1164
1165
 
@@ -2,19 +2,20 @@
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
  [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
5
- [![Tests](https://img.shields.io/badge/tests-296%2F296%20passing-brightgreen.svg)](tests/)
5
+ [![Tests](https://img.shields.io/badge/tests-356%2F356%20passing-brightgreen.svg)](tests/)
6
6
  [![Coverage](https://img.shields.io/badge/coverage-87%25-brightgreen.svg)](htmlcov/)
7
+ [![Documentation Status](https://readthedocs.org/projects/thai-lint/badge/?version=latest)](https://thai-lint.readthedocs.io/en/latest/?badge=latest)
7
8
 
8
9
  The AI Linter - Enterprise-ready linting and governance for AI-generated code across multiple languages.
9
10
 
10
11
  ## Documentation
11
12
 
12
13
  **New to thailint?** Start here:
13
- - **[Quick Start Guide](docs/quick-start.md)** - Get running in 5 minutes
14
- - **[Configuration Reference](docs/configuration.md)** - Complete config options for all linters
15
- - **[Troubleshooting Guide](docs/troubleshooting.md)** - Common issues and solutions
14
+ - **[Quick Start Guide](https://thai-lint.readthedocs.io/en/latest/quick-start/)** - Get running in 5 minutes
15
+ - **[Configuration Reference](https://thai-lint.readthedocs.io/en/latest/configuration/)** - Complete config options for all linters
16
+ - **[Troubleshooting Guide](https://thai-lint.readthedocs.io/en/latest/troubleshooting/)** - Common issues and solutions
16
17
 
17
- **Full Documentation:** Browse the **[docs/](docs/)** folder for comprehensive guides covering installation, all linters, configuration patterns, and integration examples.
18
+ **Full Documentation:** Browse the **[documentation site](https://thai-lint.readthedocs.io/)** for comprehensive guides covering installation, all linters, configuration patterns, and integration examples.
18
19
 
19
20
  ## Overview
20
21
 
@@ -31,7 +32,7 @@ We're not trying to replace the wonderful existing linters like Pylint, ESLint,
31
32
 
32
33
  thailint complements your existing linting stack by catching the patterns AI tools repeatedly miss.
33
34
 
34
- **Complete documentation available in the [docs/](docs/) folder** covering installation, configuration, all linters, and troubleshooting.
35
+ **Complete documentation available at [thai-lint.readthedocs.io](https://thai-lint.readthedocs.io/)** covering installation, configuration, all linters, and troubleshooting.
35
36
 
36
37
  ## Features
37
38
 
@@ -129,7 +130,7 @@ thailint dry --config .thailint.yaml src/
129
130
  thailint dry --format json src/
130
131
  ```
131
132
 
132
- **New to thailint?** See the **[Quick Start Guide](docs/quick-start.md)** for a complete walkthrough including config generation, understanding output, and next steps.
133
+ **New to thailint?** See the **[Quick Start Guide](https://thai-lint.readthedocs.io/en/latest/quick-start/)** for a complete walkthrough including config generation, understanding output, and next steps.
133
134
 
134
135
  ### Library Mode
135
136
 
@@ -321,9 +322,9 @@ magic-numbers:
321
322
  }
322
323
  ```
323
324
 
324
- See [Configuration Guide](docs/configuration.md) for complete reference.
325
+ See [Configuration Guide](https://thai-lint.readthedocs.io/en/latest/configuration/) for complete reference.
325
326
 
326
- **Need help with ignores?** See **[How to Ignore Violations](docs/how-to-ignore-violations.md)** for complete guide to all ignore levels (line, method, class, file, repository).
327
+ **Need help with ignores?** See **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** for complete guide to all ignore levels (line, method, class, file, repository).
327
328
 
328
329
  ## Nesting Depth Linter
329
330
 
@@ -409,7 +410,7 @@ Common patterns to reduce nesting:
409
410
  - **TypeScript**: Full support (if/for/while/try/switch)
410
411
  - **JavaScript**: Supported via TypeScript parser
411
412
 
412
- See [Nesting Linter Guide](docs/nesting-linter.md) for comprehensive documentation and refactoring patterns.
413
+ See [Nesting Linter Guide](https://thai-lint.readthedocs.io/en/latest/nesting-linter/) for comprehensive documentation and refactoring patterns.
413
414
 
414
415
  ## Single Responsibility Principle (SRP) Linter
415
416
 
@@ -526,7 +527,7 @@ Common patterns to fix SRP violations (discovered during dogfooding):
526
527
  - **After**: Extract Class pattern applied - 5 focused classes (ConfigLoader, PatternValidator, RuleChecker, PathResolver, FilePlacementLinter)
527
528
  - **Result**: Each class ≤8 methods, ≤150 LOC, single responsibility
528
529
 
529
- See [SRP Linter Guide](docs/srp-linter.md) for comprehensive documentation and refactoring patterns.
530
+ See [SRP Linter Guide](https://thai-lint.readthedocs.io/en/latest/srp-linter/) for comprehensive documentation and refactoring patterns.
530
531
 
531
532
  ## DRY Linter (Don't Repeat Yourself)
532
533
 
@@ -679,7 +680,7 @@ Built-in filters automatically exclude common non-duplication patterns:
679
680
  3. **Extract Utility Module**: Move helper functions to shared utilities
680
681
  4. **Template Method**: Use function parameters for variations
681
682
 
682
- See [DRY Linter Guide](docs/dry-linter.md) for comprehensive documentation, storage modes, and refactoring patterns.
683
+ See [DRY Linter Guide](https://thai-lint.readthedocs.io/en/latest/dry-linter/) for comprehensive documentation, storage modes, and refactoring patterns.
683
684
 
684
685
  ## Magic Numbers Linter
685
686
 
@@ -831,7 +832,7 @@ def get_ports(): # thailint: ignore[magic-numbers] - Standard ports
831
832
  # thailint: ignore-file[magic-numbers]
832
833
  ```
833
834
 
834
- See **[How to Ignore Violations](docs/how-to-ignore-violations.md)** and **[Magic Numbers Linter Guide](docs/magic-numbers-linter.md)** for complete documentation.
835
+ See **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** and **[Magic Numbers Linter Guide](https://thai-lint.readthedocs.io/en/latest/magic-numbers-linter/)** for complete documentation.
835
836
 
836
837
  ## Pre-commit Hooks
837
838
 
@@ -893,7 +894,7 @@ repos:
893
894
  pass_filenames: true
894
895
  ```
895
896
 
896
- See **[Pre-commit Hooks Guide](docs/pre-commit-hooks.md)** for complete documentation, troubleshooting, and advanced configuration.
897
+ See **[Pre-commit Hooks Guide](https://thai-lint.readthedocs.io/en/latest/pre-commit-hooks/)** for complete documentation, troubleshooting, and advanced configuration.
897
898
 
898
899
  ## Common Use Cases
899
900
 
@@ -1110,20 +1111,20 @@ docker run --rm -v /path/to/workspace:/workspace \
1110
1111
 
1111
1112
  ### Comprehensive Guides
1112
1113
 
1113
- - **[Getting Started](docs/getting-started.md)** - Installation, first lint, basic config
1114
- - **[Configuration Reference](docs/configuration.md)** - Complete config options (YAML/JSON)
1115
- - **[How to Ignore Violations](docs/how-to-ignore-violations.md)** - Complete guide to all ignore levels
1116
- - **[API Reference](docs/api-reference.md)** - Library API documentation
1117
- - **[CLI Reference](docs/cli-reference.md)** - All CLI commands and options
1118
- - **[Deployment Modes](docs/deployment-modes.md)** - CLI, Library, and Docker usage
1119
- - **[File Placement Linter](docs/file-placement-linter.md)** - Detailed linter guide
1120
- - **[Magic Numbers Linter](docs/magic-numbers-linter.md)** - Magic numbers detection guide
1121
- - **[Nesting Depth Linter](docs/nesting-linter.md)** - Nesting depth analysis guide
1122
- - **[SRP Linter](docs/srp-linter.md)** - Single Responsibility Principle guide
1123
- - **[DRY Linter](docs/dry-linter.md)** - Duplicate code detection guide
1124
- - **[Pre-commit Hooks](docs/pre-commit-hooks.md)** - Automated quality checks
1125
- - **[Publishing Guide](docs/releasing.md)** - Release and publishing workflow
1126
- - **[Publishing Checklist](docs/publishing-checklist.md)** - Post-publication validation
1114
+ - **[Getting Started](https://thai-lint.readthedocs.io/en/latest/getting-started/)** - Installation, first lint, basic config
1115
+ - **[Configuration Reference](https://thai-lint.readthedocs.io/en/latest/configuration/)** - Complete config options (YAML/JSON)
1116
+ - **[How to Ignore Violations](https://thai-lint.readthedocs.io/en/latest/how-to-ignore-violations/)** - Complete guide to all ignore levels
1117
+ - **[API Reference](https://thai-lint.readthedocs.io/en/latest/api-reference/)** - Library API documentation
1118
+ - **[CLI Reference](https://thai-lint.readthedocs.io/en/latest/cli-reference/)** - All CLI commands and options
1119
+ - **[Deployment Modes](https://thai-lint.readthedocs.io/en/latest/deployment-modes/)** - CLI, Library, and Docker usage
1120
+ - **[File Placement Linter](https://thai-lint.readthedocs.io/en/latest/file-placement-linter/)** - Detailed linter guide
1121
+ - **[Magic Numbers Linter](https://thai-lint.readthedocs.io/en/latest/magic-numbers-linter/)** - Magic numbers detection guide
1122
+ - **[Nesting Depth Linter](https://thai-lint.readthedocs.io/en/latest/nesting-linter/)** - Nesting depth analysis guide
1123
+ - **[SRP Linter](https://thai-lint.readthedocs.io/en/latest/srp-linter/)** - Single Responsibility Principle guide
1124
+ - **[DRY Linter](https://thai-lint.readthedocs.io/en/latest/dry-linter/)** - Duplicate code detection guide
1125
+ - **[Pre-commit Hooks](https://thai-lint.readthedocs.io/en/latest/pre-commit-hooks/)** - Automated quality checks
1126
+ - **[Publishing Guide](https://thai-lint.readthedocs.io/en/latest/releasing/)** - Release and publishing workflow
1127
+ - **[Publishing Checklist](https://thai-lint.readthedocs.io/en/latest/publishing-checklist/)** - Post-publication validation
1127
1128
 
1128
1129
  ### Examples
1129
1130
 
@@ -17,14 +17,14 @@ build-backend = "poetry.core.masonry.api"
17
17
 
18
18
  [tool.poetry]
19
19
  name = "thailint"
20
- version = "0.4.4"
20
+ version = "0.4.6"
21
21
  description = "The AI Linter - Enterprise-grade linting and governance for AI-generated code across multiple languages"
22
22
  authors = ["Steve Jackson"]
23
23
  license = "MIT"
24
24
  readme = "README.md"
25
25
  homepage = "https://github.com/be-wise-be-kind/thai-lint"
26
26
  repository = "https://github.com/be-wise-be-kind/thai-lint"
27
- documentation = "https://github.com/be-wise-be-kind/thai-lint#readme"
27
+ documentation = "https://thai-lint.readthedocs.io/"
28
28
  keywords = [
29
29
  "linter",
30
30
  "ai",
@@ -65,8 +65,12 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
65
65
  # Performance optimization: Cache parsed AST to avoid re-parsing for each hash window
66
66
  self._cached_ast: ast.Module | None = None
67
67
  self._cached_content: str | None = None
68
+ # Performance optimization: Line-to-node index for O(1) lookups instead of O(n) ast.walk()
69
+ self._line_to_nodes: dict[int, list[ast.AST]] | None = None
68
70
 
69
- def analyze(self, file_path: Path, content: str, config: DRYConfig) -> list[CodeBlock]:
71
+ def analyze( # thailint: ignore[nesting.excessive-depth]
72
+ self, file_path: Path, content: str, config: DRYConfig
73
+ ) -> list[CodeBlock]:
70
74
  """Analyze Python file for duplicate code blocks, excluding docstrings.
71
75
 
72
76
  Args:
@@ -81,6 +85,9 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
81
85
  self._cached_ast = self._parse_content_safe(content)
82
86
  self._cached_content = content
83
87
 
88
+ # Performance optimization: Build line-to-node index for O(1) lookups
89
+ self._line_to_nodes = self._build_line_to_node_index(self._cached_ast)
90
+
84
91
  try:
85
92
  # Get docstring line ranges
86
93
  docstring_ranges = self._get_docstring_ranges_from_content(content)
@@ -89,34 +96,58 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
89
96
  lines_with_numbers = self._tokenize_with_line_numbers(content, docstring_ranges)
90
97
 
91
98
  # Generate rolling hash windows
92
- windows = self._rolling_hash_with_tracking(lines_with_numbers, config.min_duplicate_lines)
93
-
94
- blocks = []
95
- for hash_val, start_line, end_line, snippet in windows:
96
- # Skip blocks that are single logical statements
97
- # Check the original source code, not the normalized snippet
98
- if self._is_single_statement_in_source(content, start_line, end_line):
99
- continue
100
-
101
- block = CodeBlock(
102
- file_path=file_path,
103
- start_line=start_line,
104
- end_line=end_line,
105
- snippet=snippet,
106
- hash_value=hash_val,
107
- )
108
-
109
- # Apply extensible filters (keyword arguments, imports, etc.)
110
- if self._filter_registry.should_filter_block(block, content):
111
- continue
112
-
113
- blocks.append(block)
99
+ windows = self._rolling_hash_with_tracking(
100
+ lines_with_numbers, config.min_duplicate_lines
101
+ )
114
102
 
115
- return blocks
103
+ return self._filter_valid_blocks(windows, file_path, content)
116
104
  finally:
117
105
  # Clear cache after analysis to avoid memory leaks
118
106
  self._cached_ast = None
119
107
  self._cached_content = None
108
+ self._line_to_nodes = None
109
+
110
+ def _filter_valid_blocks(
111
+ self,
112
+ windows: list[tuple[int, int, int, str]],
113
+ file_path: Path,
114
+ content: str,
115
+ ) -> list[CodeBlock]:
116
+ """Filter hash windows and create valid CodeBlock instances."""
117
+ blocks = []
118
+ for hash_val, start_line, end_line, snippet in windows:
119
+ block = self._create_block_if_valid(
120
+ file_path, content, hash_val, start_line, end_line, snippet
121
+ )
122
+ if block:
123
+ blocks.append(block)
124
+ return blocks
125
+
126
+ def _create_block_if_valid( # pylint: disable=too-many-arguments,too-many-positional-arguments
127
+ self,
128
+ file_path: Path,
129
+ content: str,
130
+ hash_val: int,
131
+ start_line: int,
132
+ end_line: int,
133
+ snippet: str,
134
+ ) -> CodeBlock | None:
135
+ """Create CodeBlock if it passes all validation checks."""
136
+ if self._is_single_statement_in_source(content, start_line, end_line):
137
+ return None
138
+
139
+ block = CodeBlock(
140
+ file_path=file_path,
141
+ start_line=start_line,
142
+ end_line=end_line,
143
+ snippet=snippet,
144
+ hash_value=hash_val,
145
+ )
146
+
147
+ if self._filter_registry.should_filter_block(block, content):
148
+ return None
149
+
150
+ return block
120
151
 
121
152
  def _get_docstring_ranges_from_content(self, content: str) -> set[int]:
122
153
  """Extract line numbers that are part of docstrings.
@@ -184,20 +215,21 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
184
215
  List of (original_line_number, normalized_code) tuples
185
216
  """
186
217
  lines_with_numbers = []
218
+ in_multiline_import = False
187
219
 
188
220
  for line_num, line in enumerate(content.split("\n"), start=1):
189
- # Skip docstring lines
190
221
  if line_num in docstring_lines:
191
222
  continue
192
223
 
193
- # Use hasher's existing tokenization logic
194
- line = self._hasher._strip_comments(line) # pylint: disable=protected-access
195
- line = " ".join(line.split())
196
-
224
+ line = self._hasher._normalize_line(line) # pylint: disable=protected-access
197
225
  if not line:
198
226
  continue
199
227
 
200
- if self._hasher._is_import_statement(line): # pylint: disable=protected-access
228
+ # Update multi-line import state and check if line should be skipped
229
+ in_multiline_import, should_skip = self._hasher._should_skip_import_line( # pylint: disable=protected-access
230
+ line, in_multiline_import
231
+ )
232
+ if should_skip:
201
233
  continue
202
234
 
203
235
  lines_with_numbers.append((line_num, line))
@@ -243,6 +275,7 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
243
275
  to avoid re-parsing the entire file for each hash window check.
244
276
  """
245
277
  # Use cached AST if available and content matches
278
+ tree: ast.Module | None
246
279
  if self._cached_ast is not None and content == self._cached_content:
247
280
  tree = self._cached_ast
248
281
  else:
@@ -261,23 +294,99 @@ class PythonDuplicateAnalyzer(BaseTokenAnalyzer): # thailint: ignore[srp.violat
261
294
  except SyntaxError:
262
295
  return None
263
296
 
264
- def _check_overlapping_nodes(self, tree: ast.Module, start_line: int, end_line: int) -> bool:
265
- """Check if any AST node overlaps and matches single-statement pattern.
297
+ @staticmethod
298
+ def _build_line_to_node_index(tree: ast.Module | None) -> dict[int, list[ast.AST]] | None:
299
+ """Build an index mapping each line number to overlapping AST nodes.
300
+
301
+ Performance optimization: This allows O(1) lookups instead of O(n) ast.walk() calls.
302
+ For a file with 5,144 nodes and 673 hash windows, this reduces 3.46M node operations
303
+ to just ~3,365 relevant node checks (99.9% reduction).
266
304
 
267
- Performance optimization: Pre-filter nodes by line range before expensive pattern checks.
305
+ Args:
306
+ tree: Parsed AST tree (None if parsing failed)
307
+
308
+ Returns:
309
+ Dictionary mapping line numbers to list of AST nodes overlapping that line,
310
+ or None if tree is None
268
311
  """
312
+ if tree is None:
313
+ return None
314
+
315
+ line_to_nodes: dict[int, list[ast.AST]] = {}
269
316
  for node in ast.walk(tree):
270
- # Quick line range check to skip nodes that don't overlap
271
- if not hasattr(node, "lineno") or not hasattr(node, "end_lineno"):
272
- continue
273
- if node.end_lineno < start_line or node.lineno > end_line:
274
- continue # No overlap, skip expensive pattern matching
317
+ if PythonDuplicateAnalyzer._node_has_line_info(node):
318
+ PythonDuplicateAnalyzer._add_node_to_index(node, line_to_nodes)
319
+
320
+ return line_to_nodes
275
321
 
276
- # Node overlaps - check if it matches single-statement pattern
322
+ @staticmethod
323
+ def _node_has_line_info(node: ast.AST) -> bool:
324
+ """Check if node has valid line number information."""
325
+ if not hasattr(node, "lineno") or not hasattr(node, "end_lineno"):
326
+ return False
327
+ return node.lineno is not None and node.end_lineno is not None
328
+
329
+ @staticmethod
330
+ def _add_node_to_index(node: ast.AST, line_to_nodes: dict[int, list[ast.AST]]) -> None:
331
+ """Add node to all lines it overlaps in the index."""
332
+ for line_num in range(node.lineno, node.end_lineno + 1): # type: ignore[attr-defined]
333
+ if line_num not in line_to_nodes:
334
+ line_to_nodes[line_num] = []
335
+ line_to_nodes[line_num].append(node)
336
+
337
+ def _check_overlapping_nodes(self, tree: ast.Module, start_line: int, end_line: int) -> bool:
338
+ """Check if any AST node overlaps and matches single-statement pattern.
339
+
340
+ Performance optimization: Use line-to-node index for O(1) lookups instead of O(n) ast.walk().
341
+ """
342
+ if self._line_to_nodes is not None:
343
+ return self._check_nodes_via_index(start_line, end_line)
344
+ return self._check_nodes_via_walk(tree, start_line, end_line)
345
+
346
+ def _check_nodes_via_index(self, start_line: int, end_line: int) -> bool:
347
+ """Check nodes using line-to-node index for O(1) lookups."""
348
+ candidates = self._collect_candidate_nodes_from_index(start_line, end_line)
349
+ return self._any_node_matches_pattern(candidates, start_line, end_line)
350
+
351
+ def _collect_candidate_nodes_from_index(self, start_line: int, end_line: int) -> set[ast.AST]:
352
+ """Collect unique nodes that overlap with the line range from index."""
353
+ candidate_nodes: set[ast.AST] = set()
354
+ for line_num in range(start_line, end_line + 1):
355
+ if self._line_to_nodes and line_num in self._line_to_nodes:
356
+ candidate_nodes.update(self._line_to_nodes[line_num])
357
+ return candidate_nodes
358
+
359
+ def _any_node_matches_pattern(
360
+ self, nodes: set[ast.AST], start_line: int, end_line: int
361
+ ) -> bool:
362
+ """Check if any node matches single-statement pattern."""
363
+ for node in nodes:
277
364
  if self._is_single_statement_pattern(node, start_line, end_line):
278
365
  return True
279
366
  return False
280
367
 
368
+ def _check_nodes_via_walk(self, tree: ast.Module, start_line: int, end_line: int) -> bool:
369
+ """Check nodes using ast.walk() fallback for tests or standalone calls."""
370
+ for node in ast.walk(tree):
371
+ if self._node_matches_via_walk(node, start_line, end_line):
372
+ return True
373
+ return False
374
+
375
+ def _node_matches_via_walk(self, node: ast.AST, start_line: int, end_line: int) -> bool:
376
+ """Check if a single node overlaps and matches pattern."""
377
+ if not self._node_overlaps_range(node, start_line, end_line):
378
+ return False
379
+ return self._is_single_statement_pattern(node, start_line, end_line)
380
+
381
+ @staticmethod
382
+ def _node_overlaps_range(node: ast.AST, start_line: int, end_line: int) -> bool:
383
+ """Check if node overlaps with the given line range."""
384
+ if not hasattr(node, "lineno") or not hasattr(node, "end_lineno"):
385
+ return False
386
+ node_end = node.end_lineno
387
+ node_start = node.lineno
388
+ return not (node_end < start_line or node_start > end_line)
389
+
281
390
  def _node_overlaps_and_matches(self, node: ast.AST, start_line: int, end_line: int) -> bool:
282
391
  """Check if node overlaps with range and matches single-statement pattern."""
283
392
  if not hasattr(node, "lineno") or not hasattr(node, "end_lineno"):
@@ -33,26 +33,80 @@ class TokenHasher:
33
33
  List of normalized code lines (non-empty, comments removed, imports filtered)
34
34
  """
35
35
  lines = []
36
+ in_multiline_import = False
36
37
 
37
38
  for line in code.split("\n"):
38
- # Remove comments (language-specific logic can be added)
39
- line = self._strip_comments(line)
40
-
41
- # Normalize whitespace (collapse to single space)
42
- line = " ".join(line.split())
43
-
44
- # Skip empty lines
39
+ line = self._normalize_line(line)
45
40
  if not line:
46
41
  continue
47
42
 
48
- # Skip import statements (common false positive)
49
- if self._is_import_statement(line):
43
+ # Update multi-line import state and check if line should be skipped
44
+ in_multiline_import, should_skip = self._should_skip_import_line(
45
+ line, in_multiline_import
46
+ )
47
+ if should_skip:
50
48
  continue
51
49
 
52
50
  lines.append(line)
53
51
 
54
52
  return lines
55
53
 
54
+ def _normalize_line(self, line: str) -> str:
55
+ """Normalize a line by removing comments and excess whitespace.
56
+
57
+ Args:
58
+ line: Raw source code line
59
+
60
+ Returns:
61
+ Normalized line (empty string if line has no content)
62
+ """
63
+ line = self._strip_comments(line)
64
+ return " ".join(line.split())
65
+
66
+ def _should_skip_import_line(self, line: str, in_multiline_import: bool) -> tuple[bool, bool]:
67
+ """Determine if an import line should be skipped.
68
+
69
+ Args:
70
+ line: Normalized code line
71
+ in_multiline_import: Whether we're currently inside a multi-line import
72
+
73
+ Returns:
74
+ Tuple of (new_in_multiline_import_state, should_skip_line)
75
+ """
76
+ if self._is_multiline_import_start(line):
77
+ return True, True
78
+
79
+ if in_multiline_import:
80
+ return self._handle_multiline_import_continuation(line)
81
+
82
+ if self._is_import_statement(line):
83
+ return False, True
84
+
85
+ return False, False
86
+
87
+ def _is_multiline_import_start(self, line: str) -> bool:
88
+ """Check if line starts a multi-line import statement.
89
+
90
+ Args:
91
+ line: Normalized code line
92
+
93
+ Returns:
94
+ True if line starts a multi-line import (has opening paren but no closing)
95
+ """
96
+ return self._is_import_statement(line) and "(" in line and ")" not in line
97
+
98
+ def _handle_multiline_import_continuation(self, line: str) -> tuple[bool, bool]:
99
+ """Handle a line that's part of a multi-line import.
100
+
101
+ Args:
102
+ line: Normalized code line inside a multi-line import
103
+
104
+ Returns:
105
+ Tuple of (still_in_import, should_skip)
106
+ """
107
+ closes_import = ")" in line
108
+ return not closes_import, True
109
+
56
110
  def _strip_comments(self, line: str) -> str:
57
111
  """Remove comments from line (Python # and // style).
58
112