Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement request] couple of requests for new features #3996

Open
patpatpat123 opened this issue Jun 28, 2023 · 3 comments
Open

[Enhancement request] couple of requests for new features #3996

patpatpat123 opened this issue Jun 28, 2023 · 3 comments

Comments

@patpatpat123
Copy link

patpatpat123 commented Jun 28, 2023

Hello error-prone team,

This is my first post in this repo. I have been using error-prone for half a year now, if not anything else, please allow me to just say thank you for this project.

It is easy to use, and very helpful in finding some corner case bugs.

After half a year of usage, there are some features that we believe might be helpful to the community. Could you please kindly review and consider them?

- standalone maven plugin

As of today, in order to use error prone in a maven project (this is not a maven versus other argument), one needs to do something like this:

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <compilerArgs>
                        <arg>-XDcompilePolicy=simple</arg>
                        <arg>-Xplugin:ErrorProne</arg>
                    </compilerArgs>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.google.errorprone</groupId>
                            <artifactId>error_prone_core</artifactId>
                            <version>2.20.0</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

This makes it bound to the maven compiler plugin. Would it be possible, like checkstyle, which google invested in, to have a standalone maven plugin, something like:

  <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
            </plugin>
            <plugin>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_core</artifactId>
                <version>2.20.0</version>
                <configuration>
                    [...]
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <configLocation>google_checks.xml</configLocation>
                    <outputDirectory>target/reports/checkstyle</outputDirectory>
                    <outputFileFormat>xml</outputFileFormat>
                </configuration>
            </plugin>

And with that, a standalone maven goal, similar to checkstyle:checkstyle maybe errorprone:errorprone (as per your design of course)

(and also, hopefully, to see the needs of .mvn/jvm.config gone. We need to checkin a rather useless file just to benefits from the scan)

- disable analysis on test files, or source code files based on a flag or inclusion-exclusion patterns

As of today, out of the box, the plugin scan the source code, which is great, but also the test files.

It will be great if we can disable the scan on test files, with maybe a flag.

Moreover, it will be great if one can specify exclusion patterns for some specific files not interested in the scan

Report integration with external tools, such as SonarQube, maven site, maven-project-info-reports-plugin, maven reporting

As of today, the output of the scan, and the precious information it contains, are left as it is, within the output of the run. It would be great if it can generate some reports, for historical knowledge, and also, integrate some visualization tools, such as SonarQube, or the maven ecosystem.

I hope not to trouble you guys with my writing, just want to make this error-prone even more interesting.

Wishing you a good day!

Thank you

@Stephan202
Copy link
Contributor

Hey @patpatpat123! I'm not an Error Prone maintainer, so the following is not an official answer, but it may help:

  1. Having a separate plugin would be nice, but Error Prone is very tightly integrated with the compiler; the extra plugin would likely have to compile the code a second time around. In all, such a separate plugin would likely not provide sufficient benefit, relative to the new surprises and inefficiencies it introduces.
  2. File name-based exclusion of files is possible using the -XepExcludedPaths flag. Since this flag accepts an arbitrary Java regex, with a bit (or a lot 😄) of fiddling it's also possible to craft a pattern to express "exclude all files but the following", which would effectively amount to an inclusion pattern.
  3. On the topic of external integrations it seems best to keep an eye on [Discussion] Serialization of Error Prone diagnostics #3766.

@tbroyer
Copy link
Contributor

tbroyer commented Jun 28, 2023

I'd also add that to only process non-test code, then configure the maven-compiler-plugin accordingly, e.g. by moving the <compilerArgs> and <annotationProcessorPaths> into an <execution> matching only the compile goal.

https://maven.apache.org/guides/mini/guide-default-execution-ids.html#example-configuring-compile-and-testcompile-mojos-separately

@breun
Copy link

breun commented Jun 11, 2024

A Maven plugin may indeed not provide enough integration, but maybe a Maven extension would allow for enough access to hook into the compilation? Just an idea, I haven't checked the feasibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants