hudson.plugins.violations
Class ViolationsReport

java.lang.Object
  extended by hudson.plugins.violations.ViolationsReport
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ViolationsAggregatedReport

public class ViolationsReport
extends java.lang.Object
implements java.io.Serializable

This contains the report for the violations of a particular build.

See Also:
Serialized Form

Nested Class Summary
 class ViolationsReport.TypeReport
          Report class for a particular type.
static class ViolationsReport.ViolationsReportIterator
           
 
Constructor Summary
ViolationsReport()
           
 
Method Summary
 void addSuppression(Suppression suppression)
          Add a suppression to the set of suppressions.
 void doGraph(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Graph this report.
 int fileCount(java.lang.String type)
          Get the number of files in violation for a particular type.
static ViolationsReport findViolationsReport(hudson.model.AbstractBuild<?,?> b)
           
 hudson.model.AbstractBuild<?,?> getBuild()
          Get the build.
 hudson.model.HealthReport getBuildHealth()
          Get the overall health for the build.
 java.util.List<hudson.model.HealthReport> getBuildHealths()
          Get a health report for each type.
 ViolationsConfig getConfig()
          Get the config.
 java.lang.Object getDynamic(java.lang.String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          This gets called to display a particular violation file report.
 FileModelProxy getFileModelProxy(java.lang.String name)
          Get the file model proxt for a file name.
 hudson.model.HealthReport getHealthReportFor(java.lang.String type)
          Get the health for a particulat type.
 java.lang.String getIcon(java.lang.String t)
          Get the icon for a type.
 ViolationsConfig getLiveConfig()
          get the configuration for this job.
 BuildModel getModel()
          Get the detailed model for the build.
 java.lang.String getNumberString(java.lang.String t)
          Get the string number for a particular type.
 java.util.Map<java.lang.String,ViolationsReport.TypeReport> getTypeReports()
          Get a map of type to type reports.
 java.util.Map<java.lang.String,TypeSummary> getTypeSummaries()
          Get a map of type to type summary report.
 TypeSummary getTypeSummary(java.lang.String type)
          Get a type summary for a particular type.
 java.util.Map<java.lang.String,java.lang.Integer> getViolations()
          Get the violation counts for the build.
static ViolationsReport.ViolationsReportIterator iteration(hudson.model.AbstractBuild<?,?> build)
           
 ViolationsReport previous()
          Get the previous ViolationsReport
 void removeSuppression(Suppression suppression)
          Remove a suppression to the set of suppressions.
 void setBuild(hudson.model.AbstractBuild<?,?> build)
          Set the build.
 void setBuildResult()
          Set the unstable/failed status of a build based on this violations report.
 void setConfig(ViolationsConfig config)
          Set the config.
 int typeCount(java.lang.String type)
          Get the number of violations for a particular type.
 int violationCount(java.lang.String type, java.lang.String filename)
          Get the number of violations of a type for a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViolationsReport

public ViolationsReport()
Method Detail

setBuild

public void setBuild(hudson.model.AbstractBuild<?,?> build)
Set the build.

Parameters:
build - the current build.

getBuild

public hudson.model.AbstractBuild<?,?> getBuild()
Get the build.

Returns:
the build.

setConfig

public void setConfig(ViolationsConfig config)
Set the config.

Parameters:
config - the config.

getConfig

public ViolationsConfig getConfig()
Get the config.

Returns:
the config.

getViolations

public java.util.Map<java.lang.String,java.lang.Integer> getViolations()
Get the violation counts for the build.

Returns:
a map of type to count.

getBuildHealth

public hudson.model.HealthReport getBuildHealth()
Get the overall health for the build.

Returns:
the health report, null if there are no counts.

getBuildHealths

public java.util.List<hudson.model.HealthReport> getBuildHealths()
Get a health report for each type.

Returns:
a list of health reports.

getHealthReportFor

public hudson.model.HealthReport getHealthReportFor(java.lang.String type)
Get the health for a particulat type.

Parameters:
type - the type to get the health for.
Returns:
the health report.

getModel

public BuildModel getModel()
Get the detailed model for the build. This is lazily build from an xml created during publisher action.

Returns:
the build model.

getFileModelProxy

public FileModelProxy getFileModelProxy(java.lang.String name)
Get the file model proxt for a file name.

Parameters:
name - the name to use.
Returns:
the file model proxy.

getDynamic

public java.lang.Object getDynamic(java.lang.String token,
                                   org.kohsuke.stapler.StaplerRequest req,
                                   org.kohsuke.stapler.StaplerResponse rsp)
This gets called to display a particular violation file report.

Parameters:
token - the current token in the path being parsed.
req - the http/stapler request.
rsp - the http/stapler response.
Returns:
an object to handle the token.

getLiveConfig

public ViolationsConfig getLiveConfig()
get the configuration for this job.

Returns:
the configuration of the job.

addSuppression

public void addSuppression(Suppression suppression)
                    throws java.io.IOException
Add a suppression to the set of suppressions.

Parameters:
suppression - the suppression to add.
Throws:
java.io.IOException

removeSuppression

public void removeSuppression(Suppression suppression)
                       throws java.io.IOException
Remove a suppression to the set of suppressions.

Parameters:
suppression - the suppression to remove.
Throws:
java.io.IOException

getTypeSummaries

public java.util.Map<java.lang.String,TypeSummary> getTypeSummaries()
Get a map of type to type summary report.

Returns:
a map.

getTypeSummary

public TypeSummary getTypeSummary(java.lang.String type)
Get a type summary for a particular type.

Parameters:
type - the violation type.
Returns:
the type summary.

getTypeReports

public java.util.Map<java.lang.String,ViolationsReport.TypeReport> getTypeReports()
Get a map of type to type reports.

Returns:
a map of type to type reports.

doGraph

public void doGraph(org.kohsuke.stapler.StaplerRequest req,
                    org.kohsuke.stapler.StaplerResponse rsp)
             throws java.io.IOException
Graph this report. Note that for some reason, yet unknown, hudson seems to pick an in memory ViolationsReport object and not the report for the build. (Reason may be related to the fact that serialized builds may not be the same as in-memory builds). Need to find the correct build from the URI.

Parameters:
req - the request paramters
rsp - the response.
Throws:
java.io.IOException - if there is an error writing the graph.

getNumberString

public java.lang.String getNumberString(java.lang.String t)
Get the string number for a particular type.

Parameters:
t - the type
Returns:
the string - a number for a value type, "" for not found and "No reports" for < 0.

getIcon

public java.lang.String getIcon(java.lang.String t)
Get the icon for a type.

Parameters:
t - the type
Returns:
the icon name.

previous

public ViolationsReport previous()
Get the previous ViolationsReport

Returns:
the previous report if present, null otherwise.

typeCount

public int typeCount(java.lang.String type)
Get the number of violations for a particular type.

Parameters:
type - the violation type.
Returns:
the number of violations.

fileCount

public int fileCount(java.lang.String type)
Get the number of files in violation for a particular type.

Parameters:
type - the violation type.
Returns:
the number of files.

violationCount

public int violationCount(java.lang.String type,
                          java.lang.String filename)
Get the number of violations of a type for a file.

Parameters:
type - the type in question.
filename - the name of the file.
Returns:
the number found (0 for none and for failures).

setBuildResult

public void setBuildResult()
Set the unstable/failed status of a build based on this violations report.


findViolationsReport

public static ViolationsReport findViolationsReport(hudson.model.AbstractBuild<?,?> b)

iteration

public static ViolationsReport.ViolationsReportIterator iteration(hudson.model.AbstractBuild<?,?> build)


Copyright © 2004-2012. All Rights Reserved.