Skip to content

Remove usage Format Json from BaseFaker #663

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

Merged
merged 4 commits into from
Feb 3, 2023

Conversation

RVRhub
Copy link
Contributor

@RVRhub RVRhub commented Feb 1, 2023

No description provided.

@what-the-diff
Copy link

what-the-diff bot commented Feb 1, 2023

  • Changed the return type of json and jsona methods from Json to String
  • Removed import net.datafaker.formats.*; in BaseFaker class
  • Added new classes:

Comment on lines 469 to 470
JsonTransformer.JsonTransformerBuilder<Object> jsonTransformerBuilder = new JsonTransformer.JsonTransformerBuilder<>();
JsonTransformer<Object> transformer = jsonTransformerBuilder.build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it could be moved to static final

Comment on lines 489 to 490
JsonTransformer.JsonTransformerBuilder<Object> jsonTransformerBuilder = new JsonTransformer.JsonTransformerBuilder<>();
JsonTransformer<Object> transformer = jsonTransformerBuilder.build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it could be moved to static final

@snuyanzin
Copy link
Collaborator

Hi @RVRhub
thanks for your contribution
i would suggest to remove deprecated class in this PR as well
WDYT?

data.add(apply(in, schema));
Iterator<IN> iterator = input.iterator();
while (iterator.hasNext()){
data.add(apply(iterator.next(), schema) + (commaBetweenObjects & iterator.hasNext() ? "," : ""));
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not &&?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

field("unit", Data::unit)
));

System.out.println(json);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could remove this output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return fakeValuesService().json(fieldExpressions);
}

public Json jsona(String... fieldExpressions) {
public String jsona(String... fieldExpressions) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these considered breaking changes? Since they’re public methods shouldn’t they be deprecated and alternatives added/encouraged?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this question applies for FakerValueService too

Copy link
Contributor

Choose a reason for hiding this comment

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

Normally I'd say yes, but I think the usage is so limited that the impact would be minimal. I would prefer depreciating a method, but it might be tricky in this case since only the return type changed. But I thought Json was already deprecated?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn’t check in an IDE. This is just me reading things and trying to get used to how the project does things 😉

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, Json and all other classes from formats package were deprecated with corresponding comments.
However it is a fair point that probably in future we should deprecate methods and probably some other usages as well ....

Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea was to make it failing for deprecated code which was deprecated in previous releases. However it should not fail for the code which was deprecated only in current development cycle.
Only pick each warning/failure and compare against git logs manually

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay if that's what you're after then yes it isn't something we can do.

We can limit to deprecation concerns -Xlint:deprecation, but the catch is that whenever we deprecate something we'd also have to stop using it internally. Which really should be true anyway IMHO but isn't necessarily quick or straight forward.

On that limited front here's what we'd have to address:

[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[447,20] net.datafaker.formats.Csv in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[447,43] net.datafaker.formats.Csv in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[457,9] net.datafaker.formats.Csv in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[457,36] net.datafaker.formats.Csv in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[460,30] net.datafaker.formats.Csv in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/service/FakeValuesService.java:[462,16] net.datafaker.formats.Format in net.datafaker.formats has been deprecated
[WARNING] /C:/datafaker/src/main/java/net/datafaker/transformations/JavaObjectTransformer.java:[20,31] newInstance() in java.lang.Class has been deprecated

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, probably we can go that way, agree.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay. I’ll open an issue. I started to look at some of these. But my lack of familiarity with the code base quickly became a challenge 😉

Copy link
Collaborator

Choose a reason for hiding this comment

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

From one side this would be great.
From another side just keep in mind that @RVRhub is working on removal of Format.Json

Copy link
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me

@snuyanzin
Copy link
Collaborator

@RVRhub thanks for addressing comments
lgtm

@snuyanzin snuyanzin merged commit f9d0142 into datafaker-net:main Feb 3, 2023
@kingthorin kingthorin mentioned this pull request Feb 5, 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.

4 participants