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

edu.hm.hafner.analysis.AbstractModuleDetector Maven / Gradle / Ivy

Go to download

This library provides a Java object model to read, aggregate, filter, and query static analysis reports. It is used by Jenkins' warnings next generation plug-in to visualize the warnings of individual builds. Additionally, this library is used by a GitHub action to autograde student software projects based on a given set of metrics (unit tests, code and mutation coverage, static analysis warnings).

There is a newer version: 12.9.1
Show newest version
package edu.hm.hafner.analysis;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import edu.hm.hafner.analysis.ModuleDetector.FileSystem;

/**
 * Abstract class for all Module Detectors.
 */
abstract class AbstractModuleDetector {
    static final String SLASH = "/";
    static final String ALL_DIRECTORIES = "**/";
    static final String PLUS = ", ";

    private final FileSystem factory;

    /**
     * Collects all projects of a specific type.
     *  @param mapping the mapping of path prefixes to module names
     * @param projects the projects of a specific type
     */
    abstract void collectProjects(Map mapping, List projects);

    /**
     * Returns the names of all project files in the following structure:
     * {@code **\/build.xml}.
     *
     * @return pattern
     */
    abstract String getPattern();

    AbstractModuleDetector(final FileSystem fileSystem) {
        factory = fileSystem;
    }

    void addMapping(final Map mapping, final String fileName, final String suffix,
            final String moduleName) {
        if (StringUtils.isNotBlank(moduleName)) {
            mapping.put(StringUtils.substringBeforeLast(fileName, suffix), moduleName);
        }
    }

    public FileSystem getFactory() {
        return factory;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy