Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed redundant variable assignment in remote debugger #50870

Closed

Conversation

TheRealChestnut
Copy link

@TheRealChestnut TheRealChestnut commented Jul 25, 2021

Bugsquad edit: Fixes #50848.

@TheRealChestnut TheRealChestnut requested a review from a team as a code owner July 25, 2021 22:07
@TheRealChestnut
Copy link
Author

I'm very new to GitHub and contributing to open source projects so if I've done something stupid please let me know :)

@YuriSizov YuriSizov added this to the 4.0 milestone Jul 25, 2021
@YuriSizov
Copy link
Contributor

The message needs to be amended to reflect the nature of change, not the line that you've touched. Something like "Remove a redundant assignment in the remote debugger" should suffice.

@@ -408,7 +408,6 @@ struct RemoteDebugger::PerformanceProfiler {
Variant monitor_value = performance->call("get_custom_monitor", custom_monitor_names[i]);
if (!monitor_value.is_num()) {
ERR_PRINT("Value of custom monitor '" + String(custom_monitor_names[i]) + "' is not a number");
arr[i + max] = Variant();
Copy link
Member

Choose a reason for hiding this comment

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

This change preserves what was the current behavior, but I'm not sure that it's correct.

The intent of this code's author was that in the error case, arr[i + max] should be Variant(), not a non-numeral value. So this is probably what needs to be changed (with an else instead of removing the assignment).

CC @simpuid who wrote that code, and @Faless who reviewed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that seems to be the case. It slipped my review. Could also be arr[i + max] = 0 instead of Variant().

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the part where we are getting the float back from Variant
@Faless Should we add an extra check there too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I missed this comment, yes, the cast should be automatic and not fail, but better be safe, so I would add the check (setting the value to 0 is not is_num).

@akien-mga
Copy link
Member

akien-mga commented Jul 26, 2021

Congrats for your first contribution :) I left a comment on whether this fix is the correct one, we might need input from contributors who know about it to confirm.

Aside from this, on the workflow side, we usually want PRs with a self-contained change like this to only contain one commit, so that our Git history stays readable and useful (that's also why we require explicit commit messages so that we can see what a commit does at a glance - you already improved it, see CONTRIBUTING.md for more details for future contributions). For this PR, that means that you should squash the current 3 commits into one using the procedure described in PR workflow.

@akien-mga akien-mga changed the title Fixed issue on line 411 - issue #50848 Removed redundant variable assignment in remote debugger Jul 26, 2021
@akien-mga akien-mga added cherrypick:3.x Considered for cherry-picking into a future 3.x release and removed cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jul 26, 2021
@TheRealChestnut
Copy link
Author

Thanks for all of the help! I'll squash the commits and leave the rest of the request as it is (as I am assuming it is bad practice to push further changes mid review)

@akien-mga
Copy link
Member

I'll squash the commits and leave the rest of the request as it is (as I am assuming it is bad practice to push further changes mid review)

Based on the current feedback you can already change the code. The correct fix would be something like:

if (!monitor_value.is_num()) {
	ERR_PRINT("Value of custom monitor '" + String(custom_monitor_names[i]) + "' is not a number");
	arr[i + max] = 0;
} else {
	arr[i + max] = monitor_value;
}

@TheRealChestnut
Copy link
Author

Thanks for letting me know. I'll go ahead and change that now

@akien-mga
Copy link
Member

Your latest push added a merge commit which is not relevant for the merged history, you can remove it by rebasing on the master branch.

@TheRealChestnut
Copy link
Author

Really sorry about that - something went very wrong when I tried to remove the previous commit.

@YuriSizov
Copy link
Contributor

Sorry for the long pause. You've made the correct change, but we failed to approve it in a timely manner. In the meantime, this was fixed by #59911 alongside other potential code issues. Thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduntant assignement of arr[i + max]
5 participants