CodeQL queries 1.25
There are a number of problems associated with a high number of lines of code:
- It can be difficult to understand and maintain, even with good tool support.
- It increases the likelihood of multiple developers needing to work on the same file at once, and it therefore increases the likelihood of merge conflicts.
- It may increase network traffic if you use a version control system that requires the whole file to be transmitted even for a tiny change.
- It may arise as a result of bundling many unrelated things into the same file, and so it can indicate weak code organization.
The solution depends on the reason for the high number of lines:
- If the file contains one or more very large functions, you should decompose them into smaller functions by means of the Extract Function refactoring.
- If the file contains many smaller functions, you should try to split up the file into multiple smaller files.
- If the file has been automatically generated by a tool, no changes are required because the file will not be maintained by a programmer.
- M. Fowler, Refactoring. Addison-Wesley, 1999.