// Path: src/main/java/org/jenkinsci/plugins/DependencyCheck/model/SeverityDistribution.java
// public class SeverityDistribution implements Serializable {
// 
//     private static final long serialVersionUID = -8061827374550831502L;
// 
//     private int buildNumber;
//     private int critical;
//     private int high;
//     private int medium;
//     private int low;
//     private int info;
//     private int unassigned;
// 
//     public SeverityDistribution(int buildNumber) {
//         this.buildNumber = buildNumber;
//     }
// 
//     public int getBuildNumber() {
//         return buildNumber;
//     }
// 
//     public int getCritical() {
//         return critical;
//     }
// 
//     public int getHigh() {
//         return high;
//     }
// 
//     public int getMedium() {
//         return medium;
//     }
// 
//     public int getLow() {
//         return low;
//     }
// 
//     public int getInfo() {
//         return info;
//     }
// 
//     public int getUnassigned() {
//         return unassigned;
//     }
// 
//     public void add(Severity severity) {
//         if (Severity.CRITICAL == severity) {
//             critical++;
//         } else if (Severity.HIGH == severity) {
//             high++;
//         } else if (Severity.MEDIUM == severity) {
//             medium++;
//         } else if (Severity.LOW == severity) {
//             low++;
//         } else if (Severity.INFO == severity) {
//             info++;
//         } else if (Severity.UNASSIGNED == severity) {
//             unassigned++;
//         }
//     }
// }


import hudson.model.Action;
import hudson.model.Job;
import hudson.model.Run;
import net.sf.json.JSONArray;
import org.jenkinsci.plugins.DependencyCheck.model.SeverityDistribution;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import java.util.ArrayList;
import java.util.List;
    public boolean isTrendVisible() {
        final List<? extends Run<?, ?>> builds = project.getBuilds();
        int count = 0;
        for (Run<?, ?> currentBuild : builds) {
            final ResultAction action = currentBuild.getAction(ResultAction.class);
            if (action != null) {
                return true;
            }
            count++;
            if (count == 10) { // Only chart the last 10 builds (max)
                break;
            }
        }
        return false;
    }

    /**
     * Returns the UI model for an ECharts line chart that shows the issues stacked by severity.
     *
     * @return the UI model as JSON
     */
    @JavaScriptMethod
    @SuppressWarnings("unused") // Called by jelly view
    public JSONArray getSeverityDistributionTrend() {
        final List<SeverityDistribution> severityDistributions = new ArrayList<>();
        final List<? extends Run<?, ?>> builds = project.getBuilds();
        int count = 0;
        for (Run<?, ?> currentBuild : builds) {
            final ResultAction action = currentBuild.getAction(ResultAction.class);
            if (action != null) {
// Path: src/main/java/org/jenkinsci/plugins/DependencyCheck/model/SeverityDistribution.java
// public class SeverityDistribution implements Serializable {
// 
//     private static final long serialVersionUID = -8061827374550831502L;
// 
//     private int buildNumber;
//     private int critical;
//     private int high;
//     private int medium;
//     private int low;
//     private int info;
//     private int unassigned;
// 
//     public SeverityDistribution(int buildNumber) {
//         this.buildNumber = buildNumber;
//     }
// 
//     public int getBuildNumber() {
//         return buildNumber;
//     }
// 
//     public int getCritical() {
//         return critical;
//     }
// 
//     public int getHigh() {
//         return high;
//     }
// 
//     public int getMedium() {
//         return medium;
//     }
// 
//     public int getLow() {
//         return low;
//     }
// 
//     public int getInfo() {
//         return info;
//     }
// 
//     public int getUnassigned() {
//         return unassigned;
//     }
// 
//     public void add(Severity severity) {
//         if (Severity.CRITICAL == severity) {
//             critical++;
//         } else if (Severity.HIGH == severity) {
//             high++;
//         } else if (Severity.MEDIUM == severity) {
//             medium++;
//         } else if (Severity.LOW == severity) {
//             low++;
//         } else if (Severity.INFO == severity) {
//             info++;
//         } else if (Severity.UNASSIGNED == severity) {
//             unassigned++;
//         }
//     }
// }


// Path: src/main/java/org/jenkinsci/plugins/DependencyCheck/JobAction.java
import hudson.model.Action;
import hudson.model.Job;
import hudson.model.Run;
import net.sf.json.JSONArray;
import org.jenkinsci.plugins.DependencyCheck.model.SeverityDistribution;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import java.util.ArrayList;
import java.util.List;

    public boolean isTrendVisible() {
        final List<? extends Run<?, ?>> builds = project.getBuilds();
        int count = 0;
        for (Run<?, ?> currentBuild : builds) {
            final ResultAction action = currentBuild.getAction(ResultAction.class);
            if (action != null) {
                return true;
            }
            count++;
            if (count == 10) { // Only chart the last 10 builds (max)
                break;
            }
        }
        return false;
    }

    /**
     * Returns the UI model for an ECharts line chart that shows the issues stacked by severity.
     *
     * @return the UI model as JSON
     */
    @JavaScriptMethod
    @SuppressWarnings("unused") // Called by jelly view
    public JSONArray getSeverityDistributionTrend() {
        final List<SeverityDistribution> severityDistributions = new ArrayList<>();
        final List<? extends Run<?, ?>> builds = project.getBuilds();
        int count = 0;
        for (Run<?, ?> currentBuild : builds) {
            final ResultAction action = currentBuild.getAction(ResultAction.class);
            if (action != null) {
                if (action.getSeverityDistribution() != null) {