sonar-devon4j-plugin

SonarQube Plugin with rules for static code analysis to validate architecture.

License

License

GroupId

GroupId

com.devonfw.tools
ArtifactId

ArtifactId

sonar-devon4j-plugin
Last Version

Last Version

2020.12.002
Release Date

Release Date

Type

Type

sonar-plugin
Description

Description

sonar-devon4j-plugin
SonarQube Plugin with rules for static code analysis to validate architecture.
Project URL

Project URL

https://github.com/devonfw/sonar-devon4j-plugin#sonar-devon4j-plugin
Project Organization

Project Organization

devonfw

Download sonar-devon4j-plugin

Dependencies

compile (5)

Group / Artifact Type Version
org.sonarsource.java : java-frontend jar 5.14.0.18788
org.slf4j : slf4j-api jar 1.7.16
com.fasterxml.jackson.jaxrs : jackson-jaxrs-json-provider jar 2.8.8
commons-codec : commons-codec jar 1.10
com.google.code.gson : gson jar 2.6.2

provided (2)

Group / Artifact Type Version
org.sonarsource.sonarqube : sonar-plugin-api jar 7.9.1
org.sonarsource.java : sonar-java-plugin jar 5.14.0.18788

Project Modules

There are no modules declared in this project.

sonar-devon4j-plugin

Apache License, Version 2.0 Maven Central Build Status

Plugin for SonarQube to validate devon4j architecture.

Motivation

With devon4j you can build business applications very efficiently following elaborated guidelines and best practices. This includes a profound architecture blueprint that is mapped to the code via clear packaging conventions.

This sonar-devon4j-plugin provides a plugin extending SonarQube with the ability to validate your Java code according to the devon4j architecture.

Installation

If you have SonarQube installed, you only need to go to its marketplace and install the latest version of this sonar-devon4j-plugin. Further you need to import the devonfw quality profiles (or activate all the rules of this plugin in your quality profile). For further details read the SonarQube setup guide.

Configuration

In your project add a file called architecture.json to the toplevel directory of your project and configure your components and their dependencies. You should commit this file to your version control system (e.g. git). The following example shows an architecture definition for the my-thai-star sample application:

{
  "architecture": {
    "components": [
        {"name":"bookingmanagement","dependencies":["ordermanagement","usermanagement","mailservice"]},
        {"name":"dishmanagement","dependencies":["imagemanagement"]},
        {"name":"imagemanagement","dependencies":[]},
        {"name":"ordermanagement","dependencies":["dishmanagement"]},
        {"name":"usermanagement","dependencies":[]},
        {"name":"mailservice","dependencies":[]}
      ]
  }
}

As you can see all you need to do is declare the components of your application with their allowed dependencies. In case you need dependencies to other devonfw apps (microservices) you can also add them as dependencies with qualified packages (e.g. com.devonfw.sampleapp.samplecomponent). As the technical architecture is standardized by a blueprint in devonfw, you do not need any further configuration and everything can already be validated out of the box.

Architecture Rules

The following image illustrates the devonfw architecture rules. The arrows show the allowed dependencies in green, discouraged dependencies in orange and forbidden dependencies in red. Devon Architecture Rules

Within the same component you are always allowed to call code from the same layer and scope as well as the API from the next layer below. Discouraged and forbidden dependencies are always implemented by its own SonarQube rule. This gives you absolute flexibility to customize the severity of such architecture violation. These dependencies have a white circle with a unique label. For each label we link the according rule to give you transparency and help you customizing.

Package Rules

Additionally, there is a generic rule that checks the devonfw packaging conventions:

Security Rules

As of version 3.2.1, we have started adding security-related rules to our plugin:

devonfw Java Quality Profile

This plugin comes with a quality profile containing not only the previously described rules, but also rules from other plugins that are vital to ensure optimal code quality. You can download these plugins directly onto your SonarQube instance via its marketplace or install them manually. For more information on the installation of plugins, see here. If you have this devon4j plugin installed, you should make sure to install the following plugins, so that the quality profile can be properly initialized at startup:

You can either associate this profile with certain projects or set it as default to make it active for every project. If you want to make changes to the profile, just create a copy of it. You will then be able to make your adjustments, like including or excluding rules, to that copy.

For further information on quality profiles and their setup, please follow the SonarQube documentation on Quality Profiles.

com.devonfw.tools

devonfw

The Open Source Standard Software Development Platform for state of the art Cloud Native Micro Service and Multi Platform Rich Web Apps

Versions

Version
2020.12.002
2020.12.001
2020.08.001
2020.04.002
2020.04.001
3.2.1
3.2.0