Skip to content

Conversation

@aSTRonuun
Copy link
Contributor

Hello everyone, I'm submitting this refactor to learn how to contribute to open source projects at the same time as I study "code smells" and I analyzed this at first and found this improvement

This rule recommends avoiding code that contains deeply nested if-then statements to improve code readability.

}
}
return item;
return PlaylistItemFactory.createPlaylistItem(trackObj);
Copy link
Member

Choose a reason for hiding this comment

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

The indentation looks a bit off to me. The return statement should only be indented using two spaces instead of four as defined in the .editorconfig file in the repository's root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right! Thanks

public class PlaylistItemFactory {
public static IPlaylistItem createPlaylistItem(JsonObject trackObj) {
IPlaylistItem item = null;
if (trackObj.has("type") && !trackObj.get("type").isJsonNull()) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the hasAndNotNull if we're at it trying to reduce duplicated code, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the delay

Yes, you're right. I fixed this to reuse this function

@aSTRonuun aSTRonuun force-pushed the refact/use-factory-class-to-remove-duplate-code branch from 1bd3b3d to 56c286d Compare December 13, 2023 15:25
Copy link
Member

@dargmuesli dargmuesli left a comment

Choose a reason for hiding this comment

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

Thank you! 🌈

@dargmuesli dargmuesli merged commit 1f95a39 into spotify-web-api-java:master Dec 14, 2023
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