All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sanity4j.util.Tool Maven / Gradle / Ivy

Go to download

Sanity4J was created to simplify running multiple static code analysis tools on the Java projects. It provides a single entry point to run all the selected tools and produce a consolidated report, which presents all findings in an easily accessible manner.

The newest version!
package com.github.sanity4j.util;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * An enumeration of available tools.
 *
 * @author Yiannis Paschalidis
 * @since Sanity4J 1.0
 */
public enum Tool
{
    /** Checkstyle static source code analyser. */
    CHECKSTYLE("checkstyle", "Checkstyle"),

    /** SpotBugs static byte-code analyser. */
    SPOTBUGS("spotbugs", "SpotBugs"),
    
    /** JaCoco datafile merge tool. */
    JACOCO_MERGE("jacoco-merge", "JaCoCo merge"),
    
    /** JaCoco unit test coverage analysis. */
    JACOCO("jacoco", "JaCoCo"),
    
    /** PMD static source code analyser. */
    PMD("pmd", "PMD"),
    
    /** PMD CPD copy & pasted source code detector. */
    PMD_CPD("pmd-cpd", "PMD CPD");

    //JUNIT("junit", "JUnit");

    /** A Read-only list of all the tools which are supported by Sanity4J. */
    public static final List TOOLS = Collections.unmodifiableList(Arrays.asList(new Tool[]
    {
       CHECKSTYLE,
       SPOTBUGS,
       JACOCO,
       JACOCO_MERGE,
       //JUNIT,
       PMD,
       PMD_CPD
    }));

    /** The tool id, which is used to e.g. look up values in tools.properties. */
    private final String toolId;

    /** The human-readable tool name. */
    private final String name;

    /**
     * Creates a tool with the given id and name.
     * @param toolId the tool id
     * @param name the tool name
     */
    private Tool(final String toolId, final String name)
    {
       this.toolId = toolId;
       this.name = name;
    }

    /** @return the id */
    public String getId()
    {
        return toolId;
    }

    /** @return the name */
    public String getName()
    {
        return name;
    }

    /** @return the id */
    @Override
    public String toString()
    {
        return toolId;
    }

    /**
     * Retrieves the tool with the given id.
     * @param toolId the tool id.
     * @return the tool with the given id, or null if the tool does not exist.
     */
    public static Tool get(final String toolId)
    {
        for (Tool tool : TOOLS)
        {
            if (tool.getId().equals(toolId))
            {
                return tool;
            }
        }

        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy