New plugin to analyze JSON files

212 views
Skip to first unread message

David Racodon

unread,
Aug 19, 2015, 5:05:13 AM8/19/15
to SonarQube
Hi guys,

I developed a plugin to analyze JSON files. It comes with:
  • Generic rules:
    • File naming convention
    • Tab characters should not be used
    • ...
  • Puppet specific rules:
    • Deprecated keys should be removed from Puppet "metadata.json" files
    • "version" should be a semantic version in Puppet "metadata.json" files
    • ...

The plugin can be downloaded at https://github.com/racodond/sonar-json-plugin/releases/download/1.0/sonar-json-plugin-1.0.jar. It is compatible with SonarQube 4.5.2+. The source code is available at https://github.com/racodond/sonar-json-plugin.

Feel free to give it a try. Any feedback is more than welcome! Contributions/ideas to add checks for other frameworks are also welcome.

@SonarSource: It would be great if you would be able to give it a try and provide some feedback. If you find it valuable, I would be eager to have it hosted at https://github.com/SonarCommunity 

Thanks!

Cheers,

David RACODON
Freelance QA Consultant

G. Ann Campbell

unread,
Aug 24, 2015, 4:00:45 PM8/24/15
to SonarQube
I've added this to the Community Plugins page.


Ann

David Racodon

unread,
Aug 24, 2015, 4:01:49 PM8/24/15
to G. Ann Campbell, SonarQube
Thanks!

David RACODON
Freelance QA Consultant

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/ae2f9a89-2129-4d2a-b449-e6eace3adf54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Racodon

unread,
Sep 4, 2015, 10:08:51 AM9/4/15
to SonarQube
Hi,

Would it be possible to add the JSON plugin to Nemo and to the Update Center?

Thank you

Regards,

David

G. Ann Campbell

unread,
Sep 4, 2015, 12:30:23 PM9/4/15
to David Racodon, SonarQube



---
G. Ann CAMPBELL | SonarSource
Product Owner

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/S4YSE9W-qq0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/5bb7154f-37d8-46aa-ba18-81b2e1fff44e%40googlegroups.com.

G. Ann Campbell

unread,
Sep 4, 2015, 12:32:06 PM9/4/15
to David Racodon, SonarQube
Sorry, I should have included this in the previous response: since the project doesn't currently pass the quality gate, it's not a candidate for the update center. Feel free to come back to me at your next release.



---
G. Ann CAMPBELL | SonarSource
Product Owner

David Racodon

unread,
Sep 4, 2015, 12:41:16 PM9/4/15
to G. Ann Campbell, SonarQube
Thanks Ann!

How should I deal with issues such as http://nemo.sonarqube.org/issues/search#issues=28a692cf-e2d5-4dc0-aaa9-43b8b68f39cb that I don't want to fix?




David RACODON
Freelance QA Consultant

G. Ann Campbell

unread,
Sep 4, 2015, 1:50:49 PM9/4/15
to David Racodon, SonarQube
NOSONAR followed by an explanation?



---
G. Ann CAMPBELL | SonarSource
Product Owner

David Racodon

unread,
Sep 4, 2015, 2:08:34 PM9/4/15
to G. Ann Campbell, SonarQube

I don't like to pollute my code with tool annotations... Any chance to be able to log in on Nemo so that I can manage issues on my projects?

David Racodon

unread,
Sep 7, 2015, 3:56:39 AM9/7/15
to G. Ann Campbell, SonarQube
Hi Ann,

I just released version 1.1 of the SonarQube JSON plugin: https://github.com/racodond/sonar-json-plugin/releases/tag/1.1
Could you please add it to the Update Center?

Thank you

Regards,

David RACODON
Freelance QA Consultant

G. Ann Campbell

unread,
Sep 17, 2015, 10:54:19 AM9/17/15
to David Racodon, SonarQube
Done.



---
G. Ann CAMPBELL | SonarSource
Product Owner

Dinesh Bolkensteyn

unread,
Nov 9, 2015, 8:09:26 AM11/9/15
to SonarQube
Hi David,

Late feedback, but it seems that the JSON plugin isn't able to parse files that do have a UTF-8 BOM files, such as the ones produced by Visual Studio:

13:06:04.114 ERROR - Unable to parse file: C:\projects\test\roslyn\src\Test\PdbUtilities\project.json
13:06:04.114 ERROR - Parse error at line 1 column 1:
 
 1: ?{
    ^
 2:   "supports": {},


On Wednesday, August 19, 2015 at 11:05:13 AM UTC+2, David Racodon wrote:

David Racodon

unread,
Nov 9, 2015, 1:00:21 PM11/9/15
to Dinesh Bolkensteyn, SonarQube
Hi Dinesh,

Late feedback, but it seems that the JSON plugin isn't able to parse files that do have a UTF-8 BOM files, such as the ones produced by Visual Studio

Indeed BOM is not supported.

I had a look at how BOM is handled in other language plugins. It looks like they only support "FF FE   UTF-16, little-endian". It looks like it is the most widely used BOM. But do you know why other BOM are not supported by those plugins?

Do you confirm that your file starts with a UTF-8 BOM and not a UTF-16 BOM? Would it be possible to send it to me?

Thank you

Regards,

David RACODON
Freelance QA Consultant

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/6ffb517c-73e0-402c-944b-5037b1e7f948%40googlegroups.com.

Dinesh Bolkensteyn

unread,
Nov 9, 2015, 4:44:47 PM11/9/15
to David Racodon, SonarQube
Hi David,

Thank you for the quick reply.

I'm analyzing the Roslyn project on Nemo (where the JSON plugin is deployed) - it's failing to parse all its "project.json" files, see https://github.com/dotnet/roslyn/blob/master/src/Interactive/csi/project.json


Plugins usually have some special logic to deal with UTF-8, as Java itself already properly handles UTF-16 or 32 BOM characters (if sonar.sourceEncoding is set to the right value): Indeed, the BOM is not strictly required for UTF-8, and it's mainly Microsoft text editors that systematically add them.

++

David Racodon

unread,
Nov 10, 2015, 5:36:00 AM11/10/15
to Dinesh Bolkensteyn, SonarQube
Hi Dinesh,

I did a bit of reading to better understand this topic.

For your information, I also added a rule to spot UTF-8 files containing a BOM.

Feel free to test and provide some feedback.

Thank you

Regards,


David RACODON
Freelance QA Consultant

Reply all
Reply to author
Forward
0 new messages