ralfstx / minimal-json

A fast and small JSON parser and writer for Java
MIT License
732 stars 186 forks source link

Fixed some Sonar issues #105

Open nbartels opened 5 years ago

nbartels commented 5 years ago

This is basically a port from RestFB and improved even further.

This fixes improve the code quality according to the default sonarqube java quality profile.

bernardosulzbach commented 5 years ago

Location was made Serializable. Why is it so?

nbartels commented 5 years ago

Ah sorry, I forgot to mention this one.

Location is used as field in the ParseException and the exception class is serializable because every exception extends Throwable.

So all fields of the ParseException should be serializable, too. Or the field needs to be transient. But because there are methods that work directly on the Location field, serializable look like the better way.

bernardosulzbach commented 5 years ago

Location is used as field in the ParseException and the exception class is serializable because every exception extends Throwable.

I see.

Well, it looks like a good pull request to me, but I don't think it will be merged any time soon, as the maintainer seems to have distanced himself from the project.

nbartels commented 5 years ago

Hm okay, I see. That's a pity, since I really like minimal-json and with its zero dependency approach it is a good "partner" for the RestFB library. I try to contact Ralf and check the state of minimal-json.

bernardosulzbach commented 5 years ago

Good luck. What I really liked about this library is that it's just a clean Java JSON library.

No reflection, no nonsensical casts, and a quite lean API.

ralfstx commented 5 years ago

Thanks for the PR and sorry for letting you wait.

I understand that Sonar recommends extracting constants, however, in this case, I don't see much value in this change. It creates a dependency between the parameter names and the constants. It's really not a big issue, but I have a slight preference to keep the messages close to the parameter names they refer to. The change also does not help to reduce the size of the compiled jar. In fact, it even adds ~ 290 bytes.

For these reasons, I'd feel better not to include this change.

Making Location serializable looks reasonable to me.