Class PMD

    • Field Detail

      • EOL

        public static final String EOL
        The line delimiter used by PMD in outputs. Usually the platform specific line separator.
      • configuration

        @Deprecated
        protected final PMDConfiguration configuration
        Deprecated.
        this configuration field is unused and will be removed. The class PMD should not be instantiated or subclassed.
        Contains the configuration with which this PMD instance has been created.
    • Constructor Detail

      • PMD

        @Deprecated
        public PMD()
        Deprecated.
        Just use the static methods, and maintain your PMDConfiguration separately.
        Create a PMD instance using a default Configuration. Changes to the configuration may be required.
      • PMD

        @Deprecated
        public PMD​(PMDConfiguration configuration)
        Deprecated.
        Just use the static methods, and maintain your PMDConfiguration separately.
        Create a PMD instance using the specified Configuration.
        Parameters:
        configuration - The runtime Configuration of PMD to use.
    • Method Detail

      • parserFor

        @Deprecated
        @InternalApi
        public static Parser parserFor​(LanguageVersion languageVersion,
                                       PMDConfiguration configuration)
        Deprecated.
        This is internal
        Helper method to get a configured parser for the requested language. The parser is configured based on the given PMDConfiguration.
        Parameters:
        languageVersion - the requested language
        configuration - the given configuration
        Returns:
        the pre-configured parser
      • getConfiguration

        @Deprecated
        public PMDConfiguration getConfiguration()
        Deprecated.
        Don't create a PMD instance just to create a PMDConfiguration
        Get the runtime configuration. The configuration can be modified to affect how PMD behaves.
        Returns:
        The configuration.
        See Also:
        PMDConfiguration
      • getSourceCodeProcessor

        @Deprecated
        public SourceCodeProcessor getSourceCodeProcessor()
        Deprecated.
        Source code processor is internal
        Gets the source code processor.
        Returns:
        SourceCodeProcessor
      • doPMD

        @Deprecated
        public static int doPMD​(PMDConfiguration configuration)
        Deprecated.
        This method is the main entry point for command line usage.
        Parameters:
        configuration - the configuration to use
        Returns:
        number of violations found.
      • newRuleContext

        @Deprecated
        public static RuleContext newRuleContext​(String sourceCodeFilename,
                                                 File sourceCodeFile)
        Deprecated.
        Not useful
        Creates a new rule context, initialized with a new, empty report.
        Parameters:
        sourceCodeFilename - the source code filename
        sourceCodeFile - the source code file
        Returns:
        the rule context
      • processFiles

        public static Report processFiles​(PMDConfiguration configuration,
                                          List<RuleSet> rulesets,
                                          Collection<? extends DataSource> files,
                                          List<Renderer> renderers)
        Run PMD using the given configuration. This replaces the other overload.
        Parameters:
        configuration - Configuration for the run. Note that the files, and rulesets, are ignored, as they are supplied as parameters
        rulesets - Parsed rulesets
        files - Files to process, will be closed by this method.
        renderers - Renderers that render the report
        Returns:
        Report in which violations are accumulated
        Throws:
        RuntimeException - If processing fails
      • getApplicableFiles

        public static List<DataSource> getApplicableFiles​(PMDConfiguration configuration,
                                                          Set<Language> languages)
        Determines all the files, that should be analyzed by PMD.
        Parameters:
        configuration - contains either the file path or the DB URI, from where to load the files
        languages - used to filter by file extension
        Returns:
        List of DataSource of files
      • main

        public static void main​(String[] args)
        Entry to invoke PMD as command line tool. Note that this will invoke System.exit(int).
        Parameters:
        args - command line arguments
      • run

        @Deprecated
        public static int run​(String[] args)
        Deprecated.
        Parses the command line arguments and executes PMD. Returns the exit code without exiting the VM.
        Parameters:
        args - command line arguments
        Returns:
        the exit code, where 0 means successful execution, 1 means error, 4 means there have been violations found.