From the course: Refactoring with GitHub Copilot

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Considerations refactoring large code bases

Considerations refactoring large code bases - Github Copilot Tutorial

From the course: Refactoring with GitHub Copilot

Considerations refactoring large code bases

Thus far, all of my examples have been very concise and short. The idea is to show the effects and before/after state of a refactor. But most projects are more than a dozen lines of code. How do you approach refactoring then? I'm going to download a large legacy project, WordPress. I want to be clear that I'm not picking on WordPress, it's a long-lived codebase and perfect for the example here. And I'll unzip. Most of the logic in WordPress is in wp-includes. I don't have any files open, so I just open wp-includes and ask, is there any code in here that is not DRY? Hmm. This isn't helpful. Copilot is answering questions for a closed file. I'm going to rephrase my prompt. Scan the open directory and tell me what files are not DRY. DRY, of course, stands for Don't Repeat Yourself, duplicated code. Now, here's a bit of a gotcha. Copilot cannot and does not scan the file system. The only context it has is what is open in the IDE and what it can infer from that. If I were to open all the…

Contents