Skip to content

Conversation

@gbq6
Copy link
Contributor

@gbq6 gbq6 commented Sep 29, 2025

No description provided.

@gbq6 gbq6 requested a review from blacelle as a code owner September 29, 2025 20:53
return false;
}

if (!(scope.get() instanceof MethodCallExpr) || !isAppendableScope(expression, scope)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code-snippet highlighting the typical concerned code would help ;).

@CompareMethods
public static class TwoIntegers {
public Object pre(StringBuilder builder) {
return builder.append(1).append(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about :

  • builder.append(1).append(2);
  • builder.append(123).append(456);
  • builder.append(2147483647).append(1);
  • builder.append(1).append(-2);
  • builder.append(0x1).append(0x2);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added them!

return false;
}

String argument = getStringValue(methodCall.getArgument(SMALLEST_SINGLE_DIGIT_NUMBER));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we really lack documentation to read through the main method (e.g. processExpression).

Typically, here, I have to:

  1. Scroll up to see what's SMALLEST_SINGLE_DIGIT_NUMBER
  2. Interprets we're parsing something like .append(12)
    ....

WAIT NO.

SMALLEST_SINGLE_DIGIT_NUMBER is irrelevant here, it is just some unexpected refactoring of 0 into SMALLEST_SINGLE_DIGIT_NUMBER.

This is my whole point about documentation: having to interpret the code due to lack of comments, I end interpreting an irrelevant code, while it is correct code. Having a snippet like extract 'someString' from '.append("someString")' would have helped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was unintentional, I’ve restored the zeros.

As for the documentation, I prefer to avoid “what” comments unless they’re absolutely necessary. Instead, I’d rather extract intent into well-named helper methods (e.g. extractArgumentFromMethodCall() in this case), so the code is self-explanatory without additional comments.

I'll try to come up with a solution that I gladly commit and you gladly merge.

@UnmodifiedMethod
public static class NonSingleDigitIntegers {
public Object pre(StringBuilder builder) {
return builder.append(123).append(456);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is UnmodifiedMethod. Is it for specific reason, or just it feels like a rare/not-very relevant case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think I just didn't think about it, but thanks for pointing out, I'll try to make it work!

Copy link
Contributor Author

@gbq6 gbq6 Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adjusted it to support numbers, but only non-negatives yet. Planning to extend it with those as well, but in the meantime if you have any test cases that you suggest I'd appreciate it.

@gbq6 gbq6 marked this pull request as draft November 10, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants