cargo-crap: Finding Untested Complexity in AI-Generated Rust Code
14 points by mark
14 points by mark
I just tried cargo-crap on my rust project and it immediately surfaced 9 functions out 306 that exceeded the crap scope of 30. One had a crap score of 5256; it was a real "this method is bad and I should feel bad" moment for me. The rest were also bad, but I had already known they were bad.
The default formatting of errors into an ascii table complete with ╌╌╌╌ horizontal lines between each line was a tad annoying as it doubled how much I had to scroll to reach the top offenders.
A useful project and I will address its initial findings. I won't immediately make it part of my CI however, because I want to see my tools supported adequately over time first.
what you really want is the gradient (dCRAP/dCov , dCRAP/cComp), and act on that
On a TODO to try to integrate in CI and slop loops. Thought the code coverage is slow and heavy to compile and run, so might need to figure out some good ways to amortize?
i think it makes sense. I haven't used it fwiw, but it seems like it's a "good" way to try keep the slop less sloppy?
I've not got any serious ai app's on the go at the moment, but have a bunch of shitty utilities i get it to write to help me in my day to day (minify, pngquants, video trimmers, screen capture tools, etc.).
I did like the --fail-above --threshold 30 option though
If the score increased, ask the agent to either simplify the function or add meaningful branch coverage.
I wonder why you'd have uncovered lines at all if you're autogenerating tests. I would consider detecting garbage coverage (e.g., mutation testing) closer to a real issue in that context.