List of files with high LOC – lines of code

This post will help you to analyze large files. It will list files based on number of lines in the file.

We usually come across lengthy code. When you have lengthy files, the compilation time increases. Though opcode caching mechanisms may save your compilation time for such big files but those big files will always be in your memory. The changes of that file being a badly written is very high.

This makes the classes and objects fatty. Whenever you make the object of such class or include such file, you are unnecessarily increasing your memory footprint.

Here is the unix command that would give you list of top 25 lengthy, heavy files.

wc -l `find your/code_dir_path -type f -name *.php` | sort -nrk2 | head -n 25
  • wc -l will give you names and count
  • sort -nrk2 will sort it based on 2nd column (i.e.: count of lines of code)