Skip to content
Notifications
Clear all

How do I stop Kling from adding unnecessary comments to my refactored code?

2 Posts
2 Users
0 Reactions
4 Views
(@ci_cd_crusader_v2)
Estimable Member
Joined: 3 months ago
Posts: 135
Topic starter   [#2337]

I've been evaluating Kling for automating some refactoring tasks across our legacy codebase. The promise was solid: automate the grunt work, keep the logic. The reality? It's turning my PRs into a comment graveyard.

Every single change, no matter how trivial, gets annotated with a verbose explanation I didn't ask for. Refactor a loop? It inserts three lines about iterator patterns. Extract a method? Here's a paragraph on function cohesion. My team is now wasting more time reviewing Kling's unsolicited commentary than the actual code changes.

Here's a trivial example of what it's doing to a simple Java method:

```java
// Before
public String greet() {
return "Hello, " + this.name;
}

// After 'Kling Refactor'
public String greet() {
// Kling: Refactored to use a dedicated greeting assembler method for improved modularity.
return assembleGreeting(this.name);
}

/**
* Assembles a greeting string for the given name.
* Kling: This extracted method centralizes greeting logic, enhancing testability and separation of concerns.
*/
private String assembleGreeting(String name) {
return "Hello, " + name;
}
```

I'm not paying for a code reviewer, I'm paying for a refactoring tool. The logic extraction is fine, but the editorializing is pointless noise. It violates the principle of leaving the smallest possible diff. My self-hosted runners just apply the patch and move on; I don't need a documentation bot that can't be turned off.

I've scoured the config. There's a `--verbose` flag, but it's on by default with no way to disable the comments in the YAML workflow file. The documentation is useless on this, only explaining how to *enable* more insights. Has anyone found a workaround? A hidden config flag, a post-processing script to strip these lines? Or is this just another case of a tool overreaching because the developers think we need our hands held through every single change?


null


   
Quote
(@crmsurfer_43)
Estimable Member
Joined: 5 months ago
Posts: 102
 

Ugh, that sounds infuriating. It's like it's trained to justify its existence on every single line change, which defeats the whole purpose of automation saving you time.

I ran into something similar with an old Salesforce Apex refactoring tool a while back. It would prepend every renamed variable with a novel about naming conventions. I ended up having to write a simple post-processing script that stripped out any comment line containing the tool's signature tag, like your "Kling:" lines.

Maybe check if Kling has a config file or a CLI flag for "silent mode"? If not, a regex find-and-delete on the output before committing might be your only stopgap. So much for seamless automation, right?



   
ReplyQuote