Project Ideas [Inception] - pmd/pmd GitHub Wiki

This document provides brief descriptions of candidate projects that are still in their inception stage. As such, the exact scope, expected output and required knowledge to tackle such projects may still be unknown.

Once mature, these ideas are promoted to this document

Table of Contents

Add Support for TypeScript

See https://sourceforge.net/p/pmd/bugs/1137/

Expected outcome: CPD supports TypeScript and PMD supports TypeScript. A few basic rules have been created.

Skills required/preferred:

Dead Code Detection

PMD used to have a non-working embryo for a dead code detector (DCD). This has been removed for 7.0.0, as nobody had worked on it for over a decade. The related feature request, containing some ideas about a possible reimplementation, is available at #439.

Expected outcome:

Skills required/preferred:

Clean Code Ruleset

Provide a preconfigured ruleset which has rules activated, that encourage clean code style. Identify missing rules. TODO needs more detail...

Expected outcome:

Skills required/preferred:

Multiple languages mixed

Some languages, like JSP, allow embedding a different language, e.g. JavaScript. PMD should not only be able to check the "outer" language, but it should check the "inner" language, too. So, there is some kind of context switching needed in PMD.

Other examples: PHP, VisualForce, Lightning.

See discussion at: [core] RFC: Analyzing embedded snippets from other languages (#237).

Multifile Analysis

Currently PMD analyzes source file by source file. If it would have an overview of the whole project (all files that are being currently analyzed), we could improve

  • Metrics - some metrics depend on the whole project, e.g. they relate the class size to the project size like number of classes.

  • Better symbol analysis:

    Currently PMD only looks at one source file at a time. Instead, it should resolve symbols across classes. This will eliminate some open bugs and enable a lot more rules to be written. However, it'll taken some doing, because it'll require parsing of class files. Lots of work here.

Complete type resolution for Java

Rationale

For some time PMD has supported Type Resolution, being able to detect the type associated with different nodes in the AST, however, such support for Java is only partial.

The goal of this project is to fully implement Type Resolution for all nodes with associated types, and write rules demonstrating such support (for instance, implementing rules equivalent to FindBugs' GC_UNRELATED_TYPES).

The rule UnusedPrivateMethod currently suffers from one limitation in type resolution: The return type of method calls is not determined leading to false positives as described in issue #1531.

As type resolution depends on a correctly set auxclasspath option, PMD should verify this, failing fast if not set at all, and providing proper warnings on missing classes.

Additionally, it would be interesting to explore changes to how type resolution is performed. Currently a full AST analysis is performed if any rule declares use of type resolution. However, such rules usually care for a small portion of the AST. Changing this full tree analysis to a subtree analysis on demand (with dynamic programming) could speed up execution time by reducing analysis scope.

Ideally, all the features of type resolution are exposed to XPath based rules as well.

Impact

Full Type Resolution greatly empowers PMD to perform far more complex and accurate analysis, while keeping the blazing speed it currently offers. This would allow to import rules from other tools allowing users to reduce their toolsets while maximizing customization and performance.

Expected outcome

All appropriate nodes of the AST can know their produced types. At least one new rule is produced to show this working. A proper performance analysis has been performed to consider on-demand type resolution. The code is documented.

Desirable skills

Intermediate Java, Understanding compiler construction

What the student will learn

Detailed knowledge of Java's type system and resolution rules. Dealing with the Java Language Specification. Profiling and performance tuning in Java.

Proposed mentors

Language Server Protocol

https://microsoft.github.io/language-server-protocol/

Vision: PMD as a Service.

Probably not usable by pmd, since the protocol's abstraction level is text positions & files (very IDE-oriented, goal is to hide everything about AST and semantics inside the server, away from IDE).

However, PMD could be embedded into a language server to provide linting results.

This is described eg. in https://www.eclipse.org/community/eclipse_newsletter/2017/may/article1.php:

We started dogfooding the protocol with what we called linter language servers. A linter language server responds to requests to lint a file and returns a set of detected warnings and errors. We wanted to lint a file as the user edits in a document which means that VS Code will emit many linting requests during an editor session. We therefore wanted to keep a server up and running so that we did not need to start a new linting process for each user edit.

That would make it easier to provide PMD for multiple different IDEs (maybe).

Template

[Optional] sub title

Rationale

Impact

Expected Outcome

Desirable Skills

What the student will learn

Proposed Mentors

[Optional] Explicit non-goal(s)

[Optional] Stretch goal(s)

[Optional] References