minimal-json icon indicating copy to clipboard operation
minimal-json copied to clipboard

Fixed some Sonar issues

Open nbartels opened this issue 6 years ago • 6 comments

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

  • Duplicate strings used in several Exceptions moved to constant values
  • IntelliJ IDE project files added to gitignore

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

nbartels avatar Dec 08 '18 21:12 nbartels

Location was made Serializable. Why is it so?

bernardosulzbach avatar Dec 08 '18 22:12 bernardosulzbach

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.

nbartels avatar Dec 08 '18 23:12 nbartels

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.

bernardosulzbach avatar Dec 08 '18 23:12 bernardosulzbach

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.

nbartels avatar Dec 09 '18 14:12 nbartels

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.

bernardosulzbach avatar Dec 09 '18 14:12 bernardosulzbach

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.

ralfstx avatar Dec 16 '18 16:12 ralfstx