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

Refactor code to never do casts #72

Merged
merged 4 commits into from
Jun 3, 2024
Merged

Refactor code to never do casts #72

merged 4 commits into from
Jun 3, 2024

Conversation

SilasKenneth
Copy link
Member

@SilasKenneth SilasKenneth commented May 28, 2024

Given the code

if ($parseNode->getBooleanValue() !== null) {
    $result->setBoolean($parseNode->getBooleanValue());
} else if ($parseNode->getFloatValue() !== null) {
    $result->setDouble($parseNode->getFloatValue());
} else if ($parseNode->getIntegerValue() !== null) {
    $result->setInteger($parseNode->getIntegerValue());
} else if ($parseNode->getStringValue() !== null) {
    $result->setString($parseNode->getStringValue());
}

With the current ParseNode implementation, the code will always never go to other branches of the if (unless getBooleanValue() returns null) since anything can be cast to boolean making the first branch of the if always true.

This work is part of
microsoft/kiota#2827
#73

@SilasKenneth SilasKenneth requested a review from a team as a code owner May 28, 2024 11:52
@SilasKenneth SilasKenneth self-assigned this May 28, 2024
Copy link
Member

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

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

Do we also need a changelog entry and version bump here?

@SilasKenneth
Copy link
Member Author

Do we also need a changelog entry and version bump here?

Hi @andrueastman , this is done.

Copy link

sonarqubecloud bot commented Jun 3, 2024

@SilasKenneth SilasKenneth merged commit 62a5097 into dev Jun 3, 2024
7 checks passed
@SilasKenneth SilasKenneth deleted the fix/casting-remove branch June 3, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants