I dropped two serializer files that were duplicated in creating a new version of our app’s API. The serializers were unused and causing bugs as other developers were adding new attributes to the wrong files.
I didn’t expect this exercise to be scary, but I’ve been bitten before when deleting unused code from java classes that were still in use by a JSP though, so it took some convincing myself to go ahead with it. I ended up deleting injected service classes that were not used by a controller for example.
I’m impressed - and I’m not even halfway done. Last week I had already deleted a few thousand lines of unused code and I was not expecting this.
Good Afternoon All
I used the the suggested tool and it highlighted a couple of graphql types that we still had sitting around since when we migrated over to graphql. They would have continued to sit there if i hadnt been pushed to check
Thanks Again and see you tomorrow
Executed on my codebase!
Tokens found: 202
Time to delete some non used code
This tool was not useful for my wordpress running on linux project.
Firstly, I had trouble installing it because I am not running on a mac.
Installation on Linux:
- Download binaries from the gitub repo
- put the executable in my path
- install ctags with sudo apt install
- run ctags -R in my root directory
Then I was able to run ‘unused’. However, it ate up so much RAM that it shut down after about a minute. Once all other programs were closed I was able to run it. However, the output was not helpful. It analyzed every file in the project including files in node_modules folders. There was no option to tell it to run only on a specific folder. Tracking down all the folder to ignore could take 20 min in itself. Running it in a specific directory was also not a solution.
I deleted two unused methods from my job project that had a comment:
Remove once DJ processes every remaining job from before the code change
Hi! Couldn’t really make unused work with NodeJS code I have in most of my projects.
However, there is an interesting package called depcheck (depcheck - npm) that will help identify unused dependencies.
I could not find any unused code in my side project but I added linting and set up a pre-push git hook so it should be harder to introduce
Bit of bad luck today. For some reason brew install
was very slow and I couldn’t achieve anything in the 20 minute timebox. Will give it another try tomorrow.
I used vulture on my work codebase, but from the looks of it, it threw quite a few false positives and I haven’t been at this job too long so today I was cautious of deleting anything. That said I know I am deleting some code in my current change which is nice
I wasn’t able to get unused to work on my m1 mac
zsh: segmentation fault unused
I’m assuming it is an arm architecture issue, but not really sure.
I did get unused to work on my linux machine though and so far haven’t really found anything that I could confidently identify as unused code.
Using unused in conjunction with universal ctags, we generated a report which pointed to a couple of writer methods. We had to act with caution because these referred to attr_accessors
which in most cases could not be removed or “downgraded” to readers/writers (for instance: when defined in controllers’ parameter classes that include ActiveModel::Model
).
We still ended up with a small refactoring as we could identify 2 service objects were accessors were actually overkill.
I’ll chime in as the PHP weirdo running Linux here… This was a great day because i’ve been meaning to cull much of of this.
I installed PHPMD (mess detector) and found a bit. But then installing the PHP Intellephense and going into my big models, I got even more.
Over 200 lines deleted… not bad… not bad at all!
It took a while for me to set it up but then I finally got it working. I had previously installed some other version of ctags and I forgot to source my shell to get the correct version.
I ran
/usr/local/bin/ctags -R . $(bundle list --paths)
then
unused --only-filetypes rb
and saw
== UNUSED SUMMARY ==
Tokens found: 845
Files found: 448
Applied language filters: only Ruby
Sort order: token (asc)
Usage likelihood: high
Configuration setting: Rails
I was looking at some randomly and Rails meta programming uses a lot of methods that are considered unused. I will have to revisit this challenge next month.
Nope – couldn’t get unused to work. I installed universal ctags, generated a tags
file, ran unused but no unused code was reported. I didn’t report unused code it purposefully added.
On IntelliJ (windows) I was Analyzing > Run Inspection By Name > Unused declaration and here’s the result: “No suspicious code found. 30 files processed in Project”
So late with this forum update, but anyway.
I didn’t find much unused code in the project I am working through, but there was a ton of code that was commented out. I killed it with fire.
I read through some of my projects and didn’t find any code that wasn’t being used. None of my projects got big enough to get to the point where I was refactoring and forgot to delete unused code. But I’ll keep this in mind for the future!