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

edu.umd.cs.findbugs.sarif.Level Maven / Gradle / Ivy

There is a newer version: 4.8.6
Show newest version
package edu.umd.cs.findbugs.sarif;

import com.google.gson.annotations.SerializedName;
import edu.umd.cs.findbugs.BugRankCategory;
import edu.umd.cs.findbugs.annotations.NonNull;

/**
 * An enum representing {@code level} property.
 *
 * @see 3.27.10 level property
 */
enum Level {
    /**
     * The rule specified by ruleId was evaluated and a problem was found.
     */
    @SerializedName("warning")
    WARNING,
    /**
     * The rule specified by ruleId was evaluated and a serious problem was found.
     */
    @SerializedName("error")
    ERROR,
    /**
     * The rule specified by ruleId was evaluated and a minor problem or an opportunity to improve the code was found.
     */
    @SerializedName("note")
    NOTE,
    /**
     * The concept of “severity” does not apply to this result because the kind property (§3.27.9) has a value other than "fail".
     */
    @SerializedName("none")
    NONE;

    public String toJsonString() {
        return name().toLowerCase();
    }

    @NonNull
    static Level fromBugRank(int bugRank) {
        BugRankCategory category = BugRankCategory.getRank(bugRank);
        switch (category) {
        case SCARIEST:
        case SCARY:
            return ERROR;
        case TROUBLING:
            return WARNING;
        case OF_CONCERN:
            return NOTE;
        default:
            throw new IllegalArgumentException("Illegal bugRank given: " + bugRank);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy