Package net.sourceforge.pmd.cache
Class NoopAnalysisCache
- java.lang.Object
-
- net.sourceforge.pmd.cache.NoopAnalysisCache
-
- All Implemented Interfaces:
AnalysisCache,ThreadSafeReportListener
public class NoopAnalysisCache extends java.lang.Object implements AnalysisCache
A NOOP analysis cache. Easier / safer than null-checking.
-
-
Constructor Summary
Constructors Constructor Description NoopAnalysisCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalysisFailed(java.io.File sourceFile)Notifies the cache that analysis of the given file has failed and should not be cached.voidcheckValidity(RuleSets ruleSets, java.lang.ClassLoader classLoader)Checks if the cache is valid for the configured rulesets and class loader.java.util.List<RuleViolation>getCachedViolations(java.io.File sourceFile)Retrieves cached violations for the given file.booleanisUpToDate(java.io.File sourceFile)Checks if a given file is up to date in the cache and can be skipped from analysis.voidmetricAdded(Metric metric)A new metric point has been reported.voidpersist()Persists the updated analysis results on whatever medium is used by the cache.voidruleViolationAdded(RuleViolation ruleViolation)A new violation has been found.
-
-
-
Method Detail
-
ruleViolationAdded
public void ruleViolationAdded(RuleViolation ruleViolation)
Description copied from interface:ThreadSafeReportListenerA new violation has been found.- Specified by:
ruleViolationAddedin interfaceThreadSafeReportListener- Parameters:
ruleViolation- the found violation.
-
metricAdded
public void metricAdded(Metric metric)
Description copied from interface:ThreadSafeReportListenerA new metric point has been reported.- Specified by:
metricAddedin interfaceThreadSafeReportListener- Parameters:
metric- the metric
-
persist
public void persist()
Description copied from interface:AnalysisCachePersists the updated analysis results on whatever medium is used by the cache.- Specified by:
persistin interfaceAnalysisCache
-
isUpToDate
public boolean isUpToDate(java.io.File sourceFile)
Description copied from interface:AnalysisCacheChecks if a given file is up to date in the cache and can be skipped from analysis. Regardless of the return value of this method, each call adds the parameter to the updated cache, which allowsThreadSafeReportListener.ruleViolationAdded(RuleViolation)to add a rule violation to the file. TODO is this really best behaviour? This side-effects seems counter-intuitive.- Specified by:
isUpToDatein interfaceAnalysisCache- Parameters:
sourceFile- The file to check in the cache- Returns:
- True if the cache is a hit, false otherwise
-
analysisFailed
public void analysisFailed(java.io.File sourceFile)
Description copied from interface:AnalysisCacheNotifies the cache that analysis of the given file has failed and should not be cached.- Specified by:
analysisFailedin interfaceAnalysisCache- Parameters:
sourceFile- The file whose analysis failed
-
checkValidity
public void checkValidity(RuleSets ruleSets, java.lang.ClassLoader classLoader)
Description copied from interface:AnalysisCacheChecks if the cache is valid for the configured rulesets and class loader. If the provided rulesets and classpath don't match those of the cache, the cache is invalidated. This needs to be called before analysis, as it conditions the good behaviour ofAnalysisCache.isUpToDate(File).- Specified by:
checkValidityin interfaceAnalysisCache- Parameters:
ruleSets- The rulesets configured for this analysis.classLoader- The class loader for auxclasspath configured for this analysis.
-
getCachedViolations
public java.util.List<RuleViolation> getCachedViolations(java.io.File sourceFile)
Description copied from interface:AnalysisCacheRetrieves cached violations for the given file. Make sure to callAnalysisCache.isUpToDate(File)first.- Specified by:
getCachedViolationsin interfaceAnalysisCache- Parameters:
sourceFile- The file to check in the cache- Returns:
- The list of cached violations.
-
-