Example of Cody gone amok

On that call a few days ago, y’all asked for examples of where Cody could have done better.

func CreateHomeSystemTemplate(db *sqlc.DB, numberOfPlanets int) error {
	planets := generate_planets(100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,

The signature for generate_planets is

func generate_planets(star *star_data_t, num_planets int, earth_like, makeMiningEasier bool) [10]*planet_data_t

A better result would have been

func CreateHomeSystemTemplate(db *sqlc.DB, numberOfPlanets int) error {
	planets := generate_planets(nil, numberOfPlanets, true, true)

Guessing the values for those two bools would have been better than repeating the number 100 almost 50 times in a row.

JetBrains Goland, v7.0.18 of the plugin.

Hey @mdhender

Thank you for providing your observations.

Additionally, some questions:
Are these all autocompletes?
If not:

  1. may you provide the prompt and how you let Cody fetch the relevant context.
  2. Was this an on-going conversation or first-shot prompting?

Thank you.

Apologies if I mis-understood the request. This was not from a chat, it was from autocomplete.

The first snippet is what was suggested after I typed in “func CreateHomeSystemTemplate.”

The second snippet is a copy of the function signature (it is in the same file).

The suggestion inserted the db handle, parameter, return value, and the first line of the function. The parameters and return value were good. The line of code was not quite as good.