refactron 0.1.0b1__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 (51) hide show
  1. refactron-0.1.0b1/LICENSE +22 -0
  2. refactron-0.1.0b1/MANIFEST.in +10 -0
  3. refactron-0.1.0b1/PKG-INFO +234 -0
  4. refactron-0.1.0b1/README.md +198 -0
  5. refactron-0.1.0b1/examples/bad_code_example.py +101 -0
  6. refactron-0.1.0b1/examples/cli_tool_example.py +166 -0
  7. refactron-0.1.0b1/examples/data_science_example.py +136 -0
  8. refactron-0.1.0b1/examples/demo.py +139 -0
  9. refactron-0.1.0b1/examples/flask_api_example.py +96 -0
  10. refactron-0.1.0b1/examples/good_code_example.py +171 -0
  11. refactron-0.1.0b1/examples/phase2_demo.py +300 -0
  12. refactron-0.1.0b1/examples/refactoring_demo.py +171 -0
  13. refactron-0.1.0b1/pyproject.toml +83 -0
  14. refactron-0.1.0b1/refactron/__init__.py +19 -0
  15. refactron-0.1.0b1/refactron/analyzers/__init__.py +2 -0
  16. refactron-0.1.0b1/refactron/analyzers/base_analyzer.py +42 -0
  17. refactron-0.1.0b1/refactron/analyzers/code_smell_analyzer.py +204 -0
  18. refactron-0.1.0b1/refactron/analyzers/complexity_analyzer.py +129 -0
  19. refactron-0.1.0b1/refactron/analyzers/dead_code_analyzer.py +300 -0
  20. refactron-0.1.0b1/refactron/analyzers/dependency_analyzer.py +349 -0
  21. refactron-0.1.0b1/refactron/analyzers/security_analyzer.py +323 -0
  22. refactron-0.1.0b1/refactron/analyzers/type_hint_analyzer.py +270 -0
  23. refactron-0.1.0b1/refactron/cli.py +344 -0
  24. refactron-0.1.0b1/refactron/core/__init__.py +2 -0
  25. refactron-0.1.0b1/refactron/core/analysis_result.py +97 -0
  26. refactron-0.1.0b1/refactron/core/config.py +95 -0
  27. refactron-0.1.0b1/refactron/core/models.py +99 -0
  28. refactron-0.1.0b1/refactron/core/refactor_result.py +91 -0
  29. refactron-0.1.0b1/refactron/core/refactron.py +231 -0
  30. refactron-0.1.0b1/refactron/refactorers/__init__.py +2 -0
  31. refactron-0.1.0b1/refactron/refactorers/add_docstring_refactorer.py +235 -0
  32. refactron-0.1.0b1/refactron/refactorers/base_refactorer.py +42 -0
  33. refactron-0.1.0b1/refactron/refactorers/extract_method_refactorer.py +92 -0
  34. refactron-0.1.0b1/refactron/refactorers/magic_number_refactorer.py +172 -0
  35. refactron-0.1.0b1/refactron/refactorers/reduce_parameters_refactorer.py +164 -0
  36. refactron-0.1.0b1/refactron/refactorers/simplify_conditionals_refactorer.py +130 -0
  37. refactron-0.1.0b1/refactron.egg-info/PKG-INFO +234 -0
  38. refactron-0.1.0b1/refactron.egg-info/SOURCES.txt +49 -0
  39. refactron-0.1.0b1/refactron.egg-info/dependency_links.txt +1 -0
  40. refactron-0.1.0b1/refactron.egg-info/entry_points.txt +2 -0
  41. refactron-0.1.0b1/refactron.egg-info/requires.txt +14 -0
  42. refactron-0.1.0b1/refactron.egg-info/top_level.txt +1 -0
  43. refactron-0.1.0b1/requirements-dev.txt +17 -0
  44. refactron-0.1.0b1/requirements.txt +8 -0
  45. refactron-0.1.0b1/setup.cfg +4 -0
  46. refactron-0.1.0b1/tests/__init__.py +2 -0
  47. refactron-0.1.0b1/tests/test_analyzers.py +70 -0
  48. refactron-0.1.0b1/tests/test_cli.py +435 -0
  49. refactron-0.1.0b1/tests/test_phase2_analyzers.py +398 -0
  50. refactron-0.1.0b1/tests/test_refactorers.py +595 -0
  51. refactron-0.1.0b1/tests/test_refactron.py +179 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Om Sherikar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,10 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ include requirements-dev.txt
5
+ recursive-include refactron *.py
6
+ recursive-include tests *.py
7
+ recursive-include examples *.py
8
+ recursive-exclude * __pycache__
9
+ recursive-exclude * *.py[co]
10
+
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: refactron
3
+ Version: 0.1.0b1
4
+ Summary: The Intelligent Code Refactoring Transformer - Analyze, refactor, and optimize Python code with AI-powered suggestions
5
+ Author-email: Om Sherikar <omsherikar@example.com>
6
+ License: MIT
7
+ Keywords: refactoring,code-quality,static-analysis,code-optimization,technical-debt,code-review,security-analysis
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Topic :: Software Development :: Quality Assurance
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: libcst>=1.1.0
23
+ Requires-Dist: click>=8.0.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: rich>=13.0.0
26
+ Requires-Dist: radon>=6.0.0
27
+ Requires-Dist: astroid>=3.0.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
31
+ Requires-Dist: black>=23.0.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
33
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
34
+ Requires-Dist: isort>=5.12.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # 🤖 Refactron
38
+
39
+ **The Intelligent Code Refactoring Transformer**
40
+
41
+ Refactron is a powerful Python library designed to eliminate technical debt, modernize legacy code, and automate code refactoring with intelligence and safety.
42
+
43
+ [![Tests](https://img.shields.io/badge/tests-98%20passed-brightgreen)]()
44
+ [![Coverage](https://img.shields.io/badge/coverage-90%25-brightgreen)]()
45
+ [![Python](https://img.shields.io/badge/python-3.8%2B-blue)]()
46
+ [![Version](https://img.shields.io/badge/version-0.1.0--beta-blue)]()
47
+ [![Status](https://img.shields.io/badge/status-beta-yellow)]()
48
+
49
+ ## ✨ Features
50
+
51
+ ### 🔍 **Comprehensive Analysis**
52
+ - **Security Scanning** - Detect `eval()`, `exec()`, SQL injection, shell injection, hardcoded secrets
53
+ - **Code Smells** - Find magic numbers, long functions, too many parameters, deep nesting
54
+ - **Complexity Metrics** - Cyclomatic complexity, maintainability index
55
+ - **Type Hints** - Identify missing or incomplete type annotations
56
+ - **Dead Code** - Detect unused functions, variables, and unreachable code
57
+ - **Dependencies** - Find circular imports, wildcard imports, deprecated modules
58
+
59
+ ### 🔧 **Intelligent Refactoring**
60
+ - **Extract Constants** - Replace magic numbers with named constants
61
+ - **Reduce Parameters** - Convert parameter lists into configuration objects
62
+ - **Simplify Conditionals** - Transform nested `if` statements into guard clauses
63
+ - **Add Docstrings** - Generate contextual documentation automatically
64
+ - **Before/After Previews** - See exactly what will change
65
+ - **Risk Scoring** - Know how safe each refactoring is (0.0 = perfectly safe, 1.0 = high risk)
66
+
67
+ ### 📊 **Rich Reporting**
68
+ - Multiple formats: Text, JSON, HTML
69
+ - Detailed issue categorization
70
+ - Technical debt quantification
71
+ - Export for CI/CD integration
72
+
73
+ ## 🚀 Quick Start
74
+
75
+ ### Installation
76
+
77
+ ```bash
78
+ pip install refactron
79
+ ```
80
+
81
+ ### Basic Usage
82
+
83
+ ```python
84
+ from refactron import Refactron
85
+
86
+ # Initialize Refactron
87
+ refactron = Refactron()
88
+
89
+ # Analyze your code
90
+ analysis = refactron.analyze("path/to/your/code.py")
91
+ print(analysis.report())
92
+
93
+ # Apply refactoring
94
+ result = refactron.refactor("path/to/your/code.py", preview=True)
95
+ result.show_diff()
96
+ result.apply()
97
+ ```
98
+
99
+ ### CLI Usage
100
+
101
+ ```bash
102
+ # Initialize configuration
103
+ refactron init
104
+
105
+ # Analyze a file or directory
106
+ refactron analyze myproject/ --detailed
107
+
108
+ # Generate a report
109
+ refactron report myproject/ --format json -o report.json
110
+
111
+ # Preview refactoring suggestions
112
+ refactron refactor myfile.py --preview
113
+
114
+ # Filter specific refactoring types
115
+ refactron refactor myfile.py --preview -t extract_constant -t add_docstring
116
+ ```
117
+
118
+ **Example Output:**
119
+ ```
120
+ 🔍 Refactron Analysis
121
+
122
+ Analysis Summary
123
+ ┏━━━━━━━━━━━━━━━━┳━━━━━━━┓
124
+ ┃ Metric ┃ Value ┃
125
+ ┡━━━━━━━━━━━━━━━━╇━━━━━━━┩
126
+ │ Files Analyzed │ 3 │
127
+ │ Total Issues │ 50 │
128
+ │ 🔴 Critical │ 3 │
129
+ │ ❌ Errors │ 0 │
130
+ │ ⚡ Warnings │ 8 │
131
+ │ ℹ️ Info │ 39 │
132
+ └────────────────┴───────┘
133
+
134
+ ⚠️ Found 3 critical issue(s) that need immediate attention!
135
+ ```
136
+
137
+ ## 🎯 What Makes Refactron Different?
138
+
139
+ Unlike traditional linters and formatters, Refactron:
140
+
141
+ - **Holistic Approach**: Combines analysis, refactoring, and optimization in one tool
142
+ - **Context-Aware**: Understands code semantics, not just syntax
143
+ - **Safe by Default**: Preview changes, risk scoring, and rollback support
144
+ - **Intelligent**: Learn from patterns and suggest contextual improvements
145
+ - **Business-Focused**: Quantify technical debt in actionable metrics
146
+
147
+ ## 💡 Real-World Examples
148
+
149
+ We've included practical examples in the `examples/` directory:
150
+
151
+ - **`flask_api_example.py`** - Common Flask API issues (security, code smells)
152
+ - **`data_science_example.py`** - Data science workflow improvements
153
+ - **`cli_tool_example.py`** - CLI application best practices
154
+
155
+ Try them out:
156
+ ```bash
157
+ # Analyze the Flask example
158
+ refactron analyze examples/flask_api_example.py --detailed
159
+
160
+ # Get refactoring suggestions
161
+ refactron refactor examples/flask_api_example.py --preview
162
+ ```
163
+
164
+ See `examples/DEMO_USAGE.md` for detailed walkthroughs!
165
+
166
+ ## 📚 Documentation
167
+
168
+ - [Getting Started (Dev)](GETTING_STARTED_DEV.md) - Development setup
169
+ - [Architecture](ARCHITECTURE.md) - Technical design
170
+ - [Case Study](CASE_STUDY.md) - Real-world testing results
171
+ - [Project Status](PROJECT_STATUS.md) - Complete feature matrix
172
+
173
+ ## 🛠️ Development Status
174
+
175
+ > **⚠️ Beta Release**: Refactron v0.1.0-beta is production-ready but still evolving. We welcome feedback and contributions!
176
+
177
+ **Current Metrics:**
178
+ - ✅ **98 tests passing** (100% success rate)
179
+ - ✅ **90% code coverage**
180
+ - ✅ **0 critical issues** in production code
181
+ - ✅ Real-world validated on 5,800+ lines
182
+
183
+ ### Roadmap
184
+
185
+ **Phase 1: Foundation** ✅ **COMPLETE**
186
+ - [x] Core architecture & CLI
187
+ - [x] Configuration system
188
+ - [x] Basic analyzers (complexity, code smells)
189
+ - [x] Refactoring suggestions with risk scoring
190
+ - [x] Before/after code previews
191
+
192
+ **Phase 2: Advanced Analysis** ✅ **COMPLETE**
193
+ - [x] Security vulnerability scanning
194
+ - [x] Dependency analysis
195
+ - [x] Dead code detection
196
+ - [x] Type hint analysis
197
+ - [x] Comprehensive test suite (87 tests, 89% coverage)
198
+
199
+ **Phase 3: Intelligence & Automation** 🚧 **NEXT**
200
+ - [ ] AI-powered pattern recognition
201
+ - [ ] Auto-fix capabilities
202
+ - [ ] Multi-file refactoring
203
+ - [ ] Custom rule engine
204
+ - [ ] Performance profiling
205
+
206
+ **Phase 4: Integration & Scale** 📋 **PLANNED**
207
+ - [ ] IDE plugins (VS Code, PyCharm)
208
+ - [ ] CI/CD integration (GitHub Actions, GitLab CI)
209
+ - [ ] Team collaboration features
210
+ - [ ] Historical trend analysis
211
+
212
+ ## 🤝 Contributing
213
+
214
+ We welcome contributions! Please see:
215
+ - [Contributing Guide](CONTRIBUTING.md) - How to contribute
216
+ - [Code of Conduct](CODE_OF_CONDUCT.md) - Community guidelines
217
+ - [Getting Started (Dev)](GETTING_STARTED_DEV.md) - Development setup
218
+
219
+ ## 📄 License
220
+
221
+ MIT License - see [LICENSE](LICENSE) file for details.
222
+
223
+ ## 🙏 Acknowledgments
224
+
225
+ Built with ❤️ using:
226
+ - [LibCST](https://github.com/Instagram/LibCST) - Concrete syntax tree parser
227
+ - [Radon](https://github.com/rubik/radon) - Complexity metrics
228
+ - [Astroid](https://github.com/PyCQA/astroid) - AST analysis
229
+ - [Rich](https://github.com/Textualize/rich) - Beautiful terminal output
230
+
231
+ ---
232
+
233
+ **Star ⭐ this repo if you find it helpful!**
234
+
@@ -0,0 +1,198 @@
1
+ # 🤖 Refactron
2
+
3
+ **The Intelligent Code Refactoring Transformer**
4
+
5
+ Refactron is a powerful Python library designed to eliminate technical debt, modernize legacy code, and automate code refactoring with intelligence and safety.
6
+
7
+ [![Tests](https://img.shields.io/badge/tests-98%20passed-brightgreen)]()
8
+ [![Coverage](https://img.shields.io/badge/coverage-90%25-brightgreen)]()
9
+ [![Python](https://img.shields.io/badge/python-3.8%2B-blue)]()
10
+ [![Version](https://img.shields.io/badge/version-0.1.0--beta-blue)]()
11
+ [![Status](https://img.shields.io/badge/status-beta-yellow)]()
12
+
13
+ ## ✨ Features
14
+
15
+ ### 🔍 **Comprehensive Analysis**
16
+ - **Security Scanning** - Detect `eval()`, `exec()`, SQL injection, shell injection, hardcoded secrets
17
+ - **Code Smells** - Find magic numbers, long functions, too many parameters, deep nesting
18
+ - **Complexity Metrics** - Cyclomatic complexity, maintainability index
19
+ - **Type Hints** - Identify missing or incomplete type annotations
20
+ - **Dead Code** - Detect unused functions, variables, and unreachable code
21
+ - **Dependencies** - Find circular imports, wildcard imports, deprecated modules
22
+
23
+ ### 🔧 **Intelligent Refactoring**
24
+ - **Extract Constants** - Replace magic numbers with named constants
25
+ - **Reduce Parameters** - Convert parameter lists into configuration objects
26
+ - **Simplify Conditionals** - Transform nested `if` statements into guard clauses
27
+ - **Add Docstrings** - Generate contextual documentation automatically
28
+ - **Before/After Previews** - See exactly what will change
29
+ - **Risk Scoring** - Know how safe each refactoring is (0.0 = perfectly safe, 1.0 = high risk)
30
+
31
+ ### 📊 **Rich Reporting**
32
+ - Multiple formats: Text, JSON, HTML
33
+ - Detailed issue categorization
34
+ - Technical debt quantification
35
+ - Export for CI/CD integration
36
+
37
+ ## 🚀 Quick Start
38
+
39
+ ### Installation
40
+
41
+ ```bash
42
+ pip install refactron
43
+ ```
44
+
45
+ ### Basic Usage
46
+
47
+ ```python
48
+ from refactron import Refactron
49
+
50
+ # Initialize Refactron
51
+ refactron = Refactron()
52
+
53
+ # Analyze your code
54
+ analysis = refactron.analyze("path/to/your/code.py")
55
+ print(analysis.report())
56
+
57
+ # Apply refactoring
58
+ result = refactron.refactor("path/to/your/code.py", preview=True)
59
+ result.show_diff()
60
+ result.apply()
61
+ ```
62
+
63
+ ### CLI Usage
64
+
65
+ ```bash
66
+ # Initialize configuration
67
+ refactron init
68
+
69
+ # Analyze a file or directory
70
+ refactron analyze myproject/ --detailed
71
+
72
+ # Generate a report
73
+ refactron report myproject/ --format json -o report.json
74
+
75
+ # Preview refactoring suggestions
76
+ refactron refactor myfile.py --preview
77
+
78
+ # Filter specific refactoring types
79
+ refactron refactor myfile.py --preview -t extract_constant -t add_docstring
80
+ ```
81
+
82
+ **Example Output:**
83
+ ```
84
+ 🔍 Refactron Analysis
85
+
86
+ Analysis Summary
87
+ ┏━━━━━━━━━━━━━━━━┳━━━━━━━┓
88
+ ┃ Metric ┃ Value ┃
89
+ ┡━━━━━━━━━━━━━━━━╇━━━━━━━┩
90
+ │ Files Analyzed │ 3 │
91
+ │ Total Issues │ 50 │
92
+ │ 🔴 Critical │ 3 │
93
+ │ ❌ Errors │ 0 │
94
+ │ ⚡ Warnings │ 8 │
95
+ │ ℹ️ Info │ 39 │
96
+ └────────────────┴───────┘
97
+
98
+ ⚠️ Found 3 critical issue(s) that need immediate attention!
99
+ ```
100
+
101
+ ## 🎯 What Makes Refactron Different?
102
+
103
+ Unlike traditional linters and formatters, Refactron:
104
+
105
+ - **Holistic Approach**: Combines analysis, refactoring, and optimization in one tool
106
+ - **Context-Aware**: Understands code semantics, not just syntax
107
+ - **Safe by Default**: Preview changes, risk scoring, and rollback support
108
+ - **Intelligent**: Learn from patterns and suggest contextual improvements
109
+ - **Business-Focused**: Quantify technical debt in actionable metrics
110
+
111
+ ## 💡 Real-World Examples
112
+
113
+ We've included practical examples in the `examples/` directory:
114
+
115
+ - **`flask_api_example.py`** - Common Flask API issues (security, code smells)
116
+ - **`data_science_example.py`** - Data science workflow improvements
117
+ - **`cli_tool_example.py`** - CLI application best practices
118
+
119
+ Try them out:
120
+ ```bash
121
+ # Analyze the Flask example
122
+ refactron analyze examples/flask_api_example.py --detailed
123
+
124
+ # Get refactoring suggestions
125
+ refactron refactor examples/flask_api_example.py --preview
126
+ ```
127
+
128
+ See `examples/DEMO_USAGE.md` for detailed walkthroughs!
129
+
130
+ ## 📚 Documentation
131
+
132
+ - [Getting Started (Dev)](GETTING_STARTED_DEV.md) - Development setup
133
+ - [Architecture](ARCHITECTURE.md) - Technical design
134
+ - [Case Study](CASE_STUDY.md) - Real-world testing results
135
+ - [Project Status](PROJECT_STATUS.md) - Complete feature matrix
136
+
137
+ ## 🛠️ Development Status
138
+
139
+ > **⚠️ Beta Release**: Refactron v0.1.0-beta is production-ready but still evolving. We welcome feedback and contributions!
140
+
141
+ **Current Metrics:**
142
+ - ✅ **98 tests passing** (100% success rate)
143
+ - ✅ **90% code coverage**
144
+ - ✅ **0 critical issues** in production code
145
+ - ✅ Real-world validated on 5,800+ lines
146
+
147
+ ### Roadmap
148
+
149
+ **Phase 1: Foundation** ✅ **COMPLETE**
150
+ - [x] Core architecture & CLI
151
+ - [x] Configuration system
152
+ - [x] Basic analyzers (complexity, code smells)
153
+ - [x] Refactoring suggestions with risk scoring
154
+ - [x] Before/after code previews
155
+
156
+ **Phase 2: Advanced Analysis** ✅ **COMPLETE**
157
+ - [x] Security vulnerability scanning
158
+ - [x] Dependency analysis
159
+ - [x] Dead code detection
160
+ - [x] Type hint analysis
161
+ - [x] Comprehensive test suite (87 tests, 89% coverage)
162
+
163
+ **Phase 3: Intelligence & Automation** 🚧 **NEXT**
164
+ - [ ] AI-powered pattern recognition
165
+ - [ ] Auto-fix capabilities
166
+ - [ ] Multi-file refactoring
167
+ - [ ] Custom rule engine
168
+ - [ ] Performance profiling
169
+
170
+ **Phase 4: Integration & Scale** 📋 **PLANNED**
171
+ - [ ] IDE plugins (VS Code, PyCharm)
172
+ - [ ] CI/CD integration (GitHub Actions, GitLab CI)
173
+ - [ ] Team collaboration features
174
+ - [ ] Historical trend analysis
175
+
176
+ ## 🤝 Contributing
177
+
178
+ We welcome contributions! Please see:
179
+ - [Contributing Guide](CONTRIBUTING.md) - How to contribute
180
+ - [Code of Conduct](CODE_OF_CONDUCT.md) - Community guidelines
181
+ - [Getting Started (Dev)](GETTING_STARTED_DEV.md) - Development setup
182
+
183
+ ## 📄 License
184
+
185
+ MIT License - see [LICENSE](LICENSE) file for details.
186
+
187
+ ## 🙏 Acknowledgments
188
+
189
+ Built with ❤️ using:
190
+ - [LibCST](https://github.com/Instagram/LibCST) - Concrete syntax tree parser
191
+ - [Radon](https://github.com/rubik/radon) - Complexity metrics
192
+ - [Astroid](https://github.com/PyCQA/astroid) - AST analysis
193
+ - [Rich](https://github.com/Textualize/rich) - Beautiful terminal output
194
+
195
+ ---
196
+
197
+ **Star ⭐ this repo if you find it helpful!**
198
+
@@ -0,0 +1,101 @@
1
+ """
2
+ Example of code with various issues that Refactron can detect.
3
+
4
+ This file intentionally contains code smells, complexity issues,
5
+ and other problems for demonstration purposes.
6
+ """
7
+
8
+
9
+ # Issue: Too many parameters
10
+ def calculate_total(price, tax, discount, shipping, handling_fee, insurance):
11
+ result = price + tax - discount + shipping + handling_fee + insurance
12
+ return result
13
+
14
+
15
+ # Issue: High complexity and deep nesting
16
+ def process_order(order_type, amount, customer_type, location, season):
17
+ if order_type == "online":
18
+ if amount > 100:
19
+ if customer_type == "premium":
20
+ if location == "domestic":
21
+ if season == "holiday":
22
+ return amount * 0.7
23
+ else:
24
+ return amount * 0.8
25
+ else:
26
+ return amount * 0.85
27
+ else:
28
+ return amount * 0.9
29
+ else:
30
+ return amount
31
+ else:
32
+ return amount * 1.05
33
+
34
+
35
+ # Issue: Magic numbers
36
+ def calculate_discount(price):
37
+ if price > 1000:
38
+ return price * 0.15
39
+ elif price > 500:
40
+ return price * 0.10
41
+ elif price > 100:
42
+ return price * 0.05
43
+ return 0
44
+
45
+
46
+ # Issue: No docstring
47
+ def mystery_function(x, y):
48
+ z = x * 42 + y * 3.14159
49
+ return z
50
+
51
+
52
+ # Issue: Very long function
53
+ def do_everything(data):
54
+ result = []
55
+ for item in data:
56
+ if item > 0:
57
+ temp = item * 2
58
+ result.append(temp)
59
+
60
+ filtered = []
61
+ for item in result:
62
+ if item > 10:
63
+ filtered.append(item)
64
+
65
+ sorted_data = sorted(filtered)
66
+
67
+ final = []
68
+ for item in sorted_data:
69
+ if item % 2 == 0:
70
+ final.append(item * 3)
71
+ else:
72
+ final.append(item * 2)
73
+
74
+ return final
75
+
76
+
77
+ class DataProcessor:
78
+ def process(self, a, b, c, d, e, f):
79
+ return a + b + c + d + e + f
80
+
81
+ def transform(self, data):
82
+ if data:
83
+ if isinstance(data, list):
84
+ if len(data) > 0:
85
+ if data[0] > 0:
86
+ return [x * 2 for x in data]
87
+ return data
88
+
89
+
90
+ # Duplicate-looking functions
91
+ def send_email1(recipient, subject, body):
92
+ print(f"Sending to {recipient}: {subject}")
93
+
94
+
95
+ def send_email2(recipient, subject, body):
96
+ print(f"Sending to {recipient}: {subject}")
97
+
98
+
99
+ def send_email3(recipient, subject, body):
100
+ print(f"Sending to {recipient}: {subject}")
101
+