Class PMDConfiguration

    • Field Detail

      • DEFAULT_SUPPRESS_MARKER

        public static final String DEFAULT_SUPPRESS_MARKER
        The default suppress marker string.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PMDConfiguration

        public PMDConfiguration()
      • PMDConfiguration

        public PMDConfiguration​(@NonNull LanguageRegistry languageRegistry)
    • Method Detail

      • getSuppressMarker

        public String getSuppressMarker()
        Get the suppress marker. This is the source level marker used to indicate a RuleViolation should be suppressed.
        Returns:
        The suppress marker.
      • setSuppressMarker

        public void setSuppressMarker​(String suppressMarker)
        Set the suppress marker.
        Parameters:
        suppressMarker - The suppress marker to use.
      • getThreads

        public int getThreads()
        Get the number of threads to use when processing Rules.
        Returns:
        The number of threads.
      • setThreads

        public void setThreads​(int threads)
        Set the number of threads to use when processing Rules.
        Parameters:
        threads - The number of threads.
      • getClassLoader

        public ClassLoader getClassLoader()
        Get the ClassLoader being used by PMD when processing Rules.
        Returns:
        The ClassLoader being used
      • setClassLoader

        public void setClassLoader​(ClassLoader classLoader)
        Set the ClassLoader being used by PMD when processing Rules. Setting a value of null will cause the default ClassLoader to be used.
        Parameters:
        classLoader - The ClassLoader to use
      • prependAuxClasspath

        public void prependAuxClasspath​(String classpath)
        Prepend the specified classpath like string to the current ClassLoader of the configuration. If no ClassLoader is currently configured, the ClassLoader used to load the PMDConfiguration class will be used as the parent ClassLoader of the created ClassLoader.

        If the classpath String looks like a URL to a file (i.e. starts with file://) the file will be read with each line representing an entry on the classpath.

        You can specify multiple class paths separated by `:` on Unix-systems or `;` under Windows. See File.pathSeparator.

        Parameters:
        classpath - The prepended classpath.
        Throws:
        IllegalArgumentException - if the given classpath is invalid (e.g. does not exist)
        See Also:
        setClassLoader(ClassLoader)
      • getMinimumPriority

        public RulePriority getMinimumPriority()
        Get the minimum priority threshold when loading Rules from RuleSets.
        Returns:
        The minimum priority threshold.
      • setMinimumPriority

        public void setMinimumPriority​(RulePriority minimumPriority)
        Set the minimum priority threshold when loading Rules from RuleSets.
        Parameters:
        minimumPriority - The minimum priority.
      • createRenderer

        public Renderer createRenderer()
        Create a Renderer instance based upon the configured reporting options. No writer is created.
        Returns:
        renderer
      • createRenderer

        public Renderer createRenderer​(boolean withReportWriter)
        Create a Renderer instance based upon the configured reporting options. If withReportWriter then we'll configure it with a writer for the reportFile specified.
        Parameters:
        withReportWriter - whether to configure a writer or not
        Returns:
        A Renderer instance.
      • getReportFormat

        public String getReportFormat()
        Get the report format.
        Returns:
        The report format.
      • setReportFormat

        public void setReportFormat​(String reportFormat)
        Set the report format. This should be a name of a Renderer.
        Parameters:
        reportFormat - The report format.
        See Also:
        Renderer
      • isShowSuppressedViolations

        public boolean isShowSuppressedViolations()
        Get whether the report should show suppressed violations.
        Returns:
        true if showing suppressed violations, false otherwise.
      • setShowSuppressedViolations

        public void setShowSuppressedViolations​(boolean showSuppressedViolations)
        Set whether the report should show suppressed violations.
        Parameters:
        showSuppressedViolations - true if showing suppressed violations, false otherwise.
      • getReportProperties

        public Properties getReportProperties()
        Get the Report properties. These are used to create the Renderer.
        Returns:
        The report properties.
      • setReportProperties

        public void setReportProperties​(Properties reportProperties)
        Set the Report properties. These are used to create the Renderer.
        Parameters:
        reportProperties - The Report properties to set.
      • isFailOnViolation

        public boolean isFailOnViolation()
        Whether PMD should exit with status 4 (the default behavior, true) if violations are found or just with 0 (to not break the build, e.g.).
        Returns:
        failOnViolation
      • setFailOnViolation

        public void setFailOnViolation​(boolean failOnViolation)
        Sets whether PMD should exit with status 4 (the default behavior, true) if violations are found or just with 0 (to not break the build, e.g.).
        Parameters:
        failOnViolation - failOnViolation
      • setAnalysisCacheLocation

        public void setAnalysisCacheLocation​(String cacheLocation)
        Sets the location of the analysis cache to be used. This will automatically configure and appropriate AnalysisCache implementation. Setting a value of null will cause a Noop AnalysisCache to be used. If incremental analysis was explicitly disabled (isIgnoreIncrementalAnalysis()), then this method is a noop.
        Parameters:
        cacheLocation - The location of the analysis cache to be used. Use null to disable the cache.
      • setIgnoreIncrementalAnalysis

        public void setIgnoreIncrementalAnalysis​(boolean noCache)
        Sets whether the user has explicitly disabled incremental analysis or not. If so, incremental analysis is not used, and all suggestions to use it are disabled. The analysis cached location is ignored, even if it's specified.
        Parameters:
        noCache - Whether to ignore incremental analysis or not
      • isIgnoreIncrementalAnalysis

        public boolean isIgnoreIncrementalAnalysis()
        Returns whether incremental analysis was explicitly disabled by the user or not.
        Returns:
        true if incremental analysis is explicitly disabled
      • getReportFilePath

        public Path getReportFilePath()
        Get the file to which the report should render.
        Returns:
        The file to which to render.
      • setReportFile

        public void setReportFile​(Path reportFile)
        Set the file to which the report should render.
        Parameters:
        reportFile - the file to set