Skip to content

Talend Validation Toolkit is a static code analysis tool to motivate Talend developers to design Talend Projects that adheres to a coding standard.

License

Notifications You must be signed in to change notification settings

hjchanna/talend-validation-toolkit

Repository files navigation

talend-validation-toolkit

CircleCI Codacy Badge codecov Releases

Talend Validation Toolkit is a static code analysis tool to motivate Talend developers to design Talend Projects that adheres to a coding standard. It automates the process of checking Talend components for validation rules and spare humans from this boring (but important) task. Talend Validation Toolkit ideal for Talend projects that want to enforce coding standards.

Installing

Talend Validation Toolkit can be used for multiple purposes and methods such as;

  • As a Java Library (module: talend-validation-util)
  • As a Desktop application (module: talend-validation-tool)
  • As a Maven Plugin for Talend Project (module: talend-validation-maven-plugin)
  • TODO: As a Plugin for a Build Tool which configured for remote SVN Talend Project

As a Java Library

import com.hjchanna.talend.TalendValidationUtil;
import com.hjchanna.talend.ValidationResponse;
...
File talendProjectRoot = new File("path/to/your/talend/project/");
TalendValidationUtil validationUtil = TalendValidationUtil.getInstance();

//validate the talend project
List<ValidationResponse> validationResponses = validationUtil.validateTalendProject(talendProjectRoot);

As a Desktop Application

Please download an run the talend-validation-tool.jar in the release section of this repository. The desktop application allows developers to locate Talend project clonned locally and validate them.

Cat

As a Maven Plugin

Add following plugin configuration to pom.xml of the Talend Project.

<plugin>
    <groupId>com.hjchanna.talend</groupId>
    <artifactId>talend-validation-maven-plugin</artifactId>
    <version>1.0</version>

    <executions>
        <execution>
            <id>validate-talend</id>
            <phase>validate</phase>
            <goals>
                <goal>validate-talend</goal>
            </goals>
        </execution>
    </executions>
</plugin>

As a Build Tool Plugin

This feature is still in development stage.

Development Guide

Prerequisites

  • Java (JDK 1.7)
  • Maven

Project Structure and Sub Modules

Talend Validation Toolkit has serveral maven modules for the parent project. The project hierarchy as follows.

| talend-validation-toolkit
|----| talend-validation-util
|----| talend-validation-tool
|----| talend-validation-maven-plugin

Module: talend-validation-util

talend-validation-util is the main artifact of the talend-validation-toolkit which consists of validation logics and validation configurations. Validation configurations are defined in json format in resource directory. Validation rules json template as follows;

JSON Template:
{
  "name": "Validation Rule Name",
  "description":"Validation Rule Description",
  "level": "WARN",
  "fileLocations": [
    "context" (folders to match files)
  ],
  "includeSubDirectories": true,
  "filePattern": "file pattern in regex format",
  "validationType": "content/xml", (or filename)
  "sourceXpath": "//contextParameter/@name", (if validationType is content/xml)
  "assertionRegex": "value match pattern in regex"
}
Example:
{
  "name": "Context Parameter Validation",
  "description":"A context variable should be in Camel Case",
  "level": "WARN",
  "fileLocations": [
    "context"
  ],
  "includeSubDirectories": true,
  "filePattern": ".*(.item)",
  "validationType": "content/xml",
  "sourceXpath": "//contextParameter/@name",
  "assertionRegex": "[a-z][A-Za-z0-9]*"
}

Note: Once a validattion rule is defined as a JSON, it shoul add to the validators.json file which is available in the resource directory.

Available Validators

There are only two validation rules are defined in this stage of the project which are;

  • Context Parameter Validation (Rule: A context variable should be in Camel Case)
  • Joblet Name Validation (Rule: A joblet name should be in Camel Case)

Module: talend-validation-maven-plugin

talend-validation-maven-plugin is a dependent project of talend-validation-util and it has packaged as a maven-plugin which enables to control the maven build. The plugin would be applied in verify phase of a maven project in default.

Build Command

Use following maven commands to build the project from the project root.

mvn clean install

Authors

About

Talend Validation Toolkit is a static code analysis tool to motivate Talend developers to design Talend Projects that adheres to a coding standard.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages