Skip to content

avioconsulting/mule-linter

Repository files navigation

#Mule Linter Tool A linter is a tool that analyzes source code looking for patterns that don’t follow convention. Linting helps prevent errors and improve the overall quality of the code by following best practices. Lint tools are a form of static code analyzers. Some common code analyzers for Java are Checkstyle, FindBugs, and PMD.

The Mule Linter will enforce that all Mule projects are developed with a baseline set of rules. Some basic examples of rules that will be enforced, are the proper usage of property and pom files, useful logging messages, and standard project structure.

Usage

Maven Plugin

See Readme in mule-linter-maven-plugin module.

CLI

Project uses Gradle build system. Run following command to build all components in local -

./gradlew build

The CLI distributions are generated in ./mule-linter-cli/build/distributions/. Unzip/Untar the distribution. You can run the CLI from expanded files -

./bin/mule-linter-cli

You may move expanded distribution folder to other persistent location and add it on OS PATH, and then run cli from anywhere on the system.

Build

To build the project run -

./gradlew build

Generated Distribution and install in local -

./gradlew installDist

Rule Configuration

Create a Groovy class that implements a static method called getRules and returns a RuleSet object.

static RuleSet getRules() { }

Initialize the Rules you would like to use, and add them to the RuleSet with the .addRule(Rule) method. Make sure to import the rules and helper classes you intend to use.

See AVIOGDSLRuleConfiguration.groovy for sample configuration.

For a full breakdown on the available rules, check here.

Using IntelliJ Auto Completion

Mule Linter's core library contains the GDSL file to support autocompletion in IntelliJ. To use that feature, com.avioconsulting.mule:mule-linter-core dependency must be added with provided scope in the project. provided scope will avoid maven packaging core into project artifact but still allow IntelliJ to detect the GDSL script from classpath.

Code Checkout

When cloning add the 'recurse-submodules' flag

git clone --recurse-submodules

After cloning, update the submodules

git submodule update --remote

Mule Application Design

Mermaid Design

Updating Mermaid Diagram

Mermaid Live Editor

Code Coverage

CodeNarc is used to ensure quality in groovy code. The configuration file is located here. To execute run gradle check, and an output report will be generated.