Skip to content
SonarQube JSON Analyzer
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
its Fix ITs for version 7.0 Feb 15, 2018
json-checks-testkit Bump version to 2.4-SNAPSHOT Nov 20, 2017
json-checks
json-frontend
sonar-json-plugin
.gitignore Make the plugin compatible with SonarQube 6.7 Nov 17, 2017
.travis.yml Remove useless linux distribution settings Mar 7, 2018
CONTRIBUTING.md
LICENSE First version of the SonarQube JSON plugin Aug 16, 2015
README.md
appveyor.yml No longer build against SonarQube DEV version Feb 9, 2018
pom.xml Fix ITs for version 7.0 Feb 15, 2018
travis.sh Activate SonarQube branch analysis Feb 15, 2018

README.md

Release Build Status AppVeyor Build Status

Quality Gate status Lines of Code Coverage

SonarQube JSON Analyzer

Description

This SonarQube plugin analyzes JSON files and:

  • Computes metrics: lines of code, statements, etc.
  • Checks various guidelines to find out potential bugs and code smells through more than 12 checks
  • Provides the ability to write your own checks

Usage

  1. Download ad install SonarQube
  2. Install the JSON plugin by a direct download. The latest version is compatible with SonarQube 6.7+
  3. Install your favorite scanner (SonarQube Scanner, Maven, Ant, etc.)
  4. Analyze your code

Custom Checks

You're thinking of new valuable rules? Version 2.0 or greater provides an API to write your own custom checks. A sample plugin with detailed explanations is available here. If your custom rules may benefit the community, feel free to create a pull request in order to make the rule available in the JSON analyzer.

You're thinking of new rules that may benefit the community but don't have the time or the skills to write them? Feel free to create an issue for your rules to be taken under consideration.

Troubleshooting

If a JSON file is containing some heavily nested objects (more than a hundred nested levels), you may face a StackOverflowError looking like:

Exception in thread "main" java.lang.StackOverflowError
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.convertChildren(SyntaxTreeCreator.java:128)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.visitNonTerminal(SyntaxTreeCreator.java:119)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.visit(SyntaxTreeCreator.java:72)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.visitNonTerminal(SyntaxTreeCreator.java:89)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.visit(SyntaxTreeCreator.java:72)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.convertChildren(SyntaxTreeCreator.java:129)
	at com.sonar.sslr.impl.typed.SyntaxTreeCreator.visitNonTerminal(SyntaxTreeCreator.java:119)
	...

Increasing the JVM stack size should fix your issue.

If you are running your analysis with:

  • The SonarQube Scanner, set the SONAR_SCANNER_OPTS environment variable to -Xss10m for instance
  • Maven, set the MAVEN_OPTS environment variable to -Xss10m for instance

and rerun your analysis.

Available Rules

Generic

  • BOM should not be used for UTF-8 files
  • File names should comply with a naming convention
  • Files should contain an empty new line at the end
  • Regular expression on key
  • Tabulation characters should not be used

Puppet

  • "author" should match the required value in Puppet "metadata.json" files
  • "license" should be valid in Puppet "metadata.json" files
  • "license" should match the required value in Puppet "metadata.json" files
  • "version" should be a semantic version in Puppet "metadata.json" files
  • Deprecated keys should be removed from Puppet "metadata.json" files
  • Duplicated dependencies should be removed from Puppet "metadata.json" files
  • Puppet "metadata.json" files should define all the required keys
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.