Tip for evaluating file size with linux command
Xun Zhou
Posted on June 10, 2022
I wanna just know the code size of current folder and wanna share this cod snippet with u. Give a try in your src folder . You will see there are some candidates, which might be too large and need to be refactored in the future.
For example: Service/Import.php with 1185 lines, and it does definitively too much and should be refactored.
cd src
find . -name '*.php' | xargs wc -l | sort -nr
20844 total
1791 ./Service/PageGenerator.php
1185 ./Modules/Importer/Service/Import.php
542 ./Entity/Base/Area.php
447 ./Entity/PublicInfo.php
363 ./Controller/FrontendController.php
339 ./Modules/MyAPI/Provider/Dto/AreasDto.php
307 ./Entity/Base/OpeningTime.php
298 ./Entity/Opening.php
290 ./Entity/SpecialSale.php
289 ./Modules/Exporter/Model/ExportStoresModel.php
258 ./Entity/User.php
232 ./Modules/MyAPI/Provider/Dto/PublicInfoDto.php
230 ./Repository/StoreRepositoryDBAL.php
221 ./Repository/StoreRepository.php
214 ./Entity/Base/TemporaryClosing.php
205 ./Controller/OpeningController.php
196 ./Entity/Base/Competitor.php
178 ./Form/PublicInfoType.php
177 ./Modules/Exporter/Api/Bing/Stores.php
177 ./Form/OpeningType.php
173 ./Form/SpecialSaleType.php
166 ./Entity/Base/StatusDevelopment.php
[UPDATED] for the users, who is using zsh
, can just use this shortcut:
$ cd src
$ wc -l **/*.php | sort -nr
Sure, there are lots of code static tools that can do the same job. But this command is just handy 💫
💖 💪 🙅 🚩
Xun Zhou
Posted on June 10, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.