SonarJ Upgrades Architectural Dependency Tracking
Join the DZone community and get the full member experience.
Join For FreeA German company, Hello2morrow, recently launched a new version of its tool for bridging the gap between architects and developers. SonarJ allows developers to validate their code against large software architectures using static analysis. It exists as a standalone version, an Eclipse plugin, and as a Maven plugin or Ant task. SonarJ 5.1.1 and the Sonar plugin 1.2 for SonarJ were recently unveiled with new features including enhanced Excel exporting of dependencies for SonarJ and multi-module Maven project support for the plugin.
SonarJ is used to build project architectures (or use existing ones) and map a system model to the code. The architecture logic built in SonarJ defines a "blueprint" of layers, vertical slices and subsystems. SonarJ then takes guidelines and distributes them to the development teams as an XML file. Finally, it monitors the changes and notifies developers when a quality or architectural violation occurs. The program can then provide a simple workflow for assigning issue fixes. All of this is done within the IDE.
SonarJ Maps Cyclic Dependencies

SonarJ was used to detect dependency cycles in Spring's architecture
Developers can choose to use SonarJ as an Eclipse plugin or as a standalone version which can integrate with most other development environments. The software supports anything that ends in Java bytecode and most of the analysis is done on the bytecode level. SonarJ also corrects architectural problems by simulating and planning refactorings. Large monolithic systems can be partitioned and modularized with SonarJ's ability to visualize dependency structures and simulate refactorings. SonarJ's dependency visualization also detects cyclic dependency structures on multiple levels and improves QA. Overall, SonarJ is useful because it lets developers know if their code really reflects the architecture. Without a tool like SonarJ, an architecture only exists in the form of documents or UML diagrams; you never really know if your code reflects the architecture.
Hello2morrow founder Alexander on Zitzewitz further explains SonarJ's capabilities:
What's New?
Metrics Evaluation in SonarJ

For projects with a size of up to 50k bytecode instructions (approx. 20k lines of code) SonarJ can be used free of charge. A commercial license is available for commercial projects. The Sonar 1.2 plugin for SonarJ is under the Apache license v2. There are several video tutorials explaining how SonarJ is used.
SonarJ is used to build project architectures (or use existing ones) and map a system model to the code. The architecture logic built in SonarJ defines a "blueprint" of layers, vertical slices and subsystems. SonarJ then takes guidelines and distributes them to the development teams as an XML file. Finally, it monitors the changes and notifies developers when a quality or architectural violation occurs. The program can then provide a simple workflow for assigning issue fixes. All of this is done within the IDE.
SonarJ Maps Cyclic Dependencies

SonarJ was used to detect dependency cycles in Spring's architecture
Developers can choose to use SonarJ as an Eclipse plugin or as a standalone version which can integrate with most other development environments. The software supports anything that ends in Java bytecode and most of the analysis is done on the bytecode level. SonarJ also corrects architectural problems by simulating and planning refactorings. Large monolithic systems can be partitioned and modularized with SonarJ's ability to visualize dependency structures and simulate refactorings. SonarJ's dependency visualization also detects cyclic dependency structures on multiple levels and improves QA. Overall, SonarJ is useful because it lets developers know if their code really reflects the architecture. Without a tool like SonarJ, an architecture only exists in the form of documents or UML diagrams; you never really know if your code reflects the architecture.
Hello2morrow founder Alexander on Zitzewitz further explains SonarJ's capabilities:
"The mapping is done by assigning Java elements like packages or types to the artifacts of the logical architecture. As soon as this had been done we can automatically compare the logical architecture with the code base and find and display all violations (dependencies, that are not foreseen in the logical architecture). This feature is of course especially useful in the Eclipse plugin, where violations are marked with error markers as soon as the developer saves a code change. This check is done within milliseconds because SonarJ always keeps a very compact model of the code in memory so that only changed files need to be reparsed. Besides checking the structure, SonarJ can also check a couple of relevant software metrics and warn the developer, when a metric is out of range."
What's New?
- Code Block Duplication - SonarJ is now able to locate duplicate code blocks using a high-performance algorithm. This feature mitigates the problems caused by by copy & paste programming.
- New Package Level Refactorings - Version 5.1.1's virtual refactoring engine includes new package-level refactorings that make it easier to delegate virtual refactorings to Eclipse for execution.
- Partially Opened Project Support - The classes and sources analyzed by the Eclipse plugin have more flexible management options that allow SonarJ to work effectively even if your project is only partially opened.
- Enhanced Excel Export - When you need to know all dependencies between a set of .jar files you can use the exploration view to visualize dependencies (switch to “Physical” in the navigator before you do so) or click on “Excel Export” in the context menu of the dependency view. This option populates an Excel spreadsheet with a list of all your dependencies. It also marks the dependencies that violate any of your architecture rules.
Metrics Evaluation in SonarJ

For projects with a size of up to 50k bytecode instructions (approx. 20k lines of code) SonarJ can be used free of charge. A commercial license is available for commercial projects. The Sonar 1.2 plugin for SonarJ is under the Apache license v2. There are several video tutorials explaining how SonarJ is used.
Dependency
Architecture
Opinions expressed by DZone contributors are their own.
Comments