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

[MCHECKSTYLE-449] Add support for SARIF output format #136

Merged
merged 1 commit into from
Jun 1, 2024

Conversation

exiahuang
Copy link
Contributor

@exiahuang exiahuang commented May 29, 2024

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCHECKSTYLE-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCHECKSTYLE-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@exiahuang
Copy link
Contributor Author

Add outputFileFormat support sarif.

@exiahuang exiahuang changed the title Support sarif type Support sarif outputFileFormat May 29, 2024
@michael-o michael-o force-pushed the feature/support-sarif-type branch from 7143e0e to 1ad6033 Compare June 1, 2024 11:24
@michael-o michael-o changed the title Support sarif outputFileFormat [MCHECKSTYLE-449] Add support for SARIF output format Jun 1, 2024
@asfgit asfgit closed this in 1ad6033 Jun 1, 2024
@asfgit asfgit merged commit 1ad6033 into apache:master Jun 1, 2024
19 checks passed
@motlin
Copy link

motlin commented Jun 6, 2024

I'm trying to use this and running into:

Caused by: java.lang.NoSuchMethodError: 'void com.puppycrawl.tools.checkstyle.SarifLogger.<init>(java.io.OutputStream, com.puppycrawl.tools.checkstyle.api.AutomaticBean$OutputStreamOptions)'
    at org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.getListener (CheckstyleViolationCheckMojo.java:816)
    at org.apache.maven.plugins.checkstyle.CheckstyleViolationCheckMojo.execute (CheckstyleViolationCheckMojo.java:539)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:193)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:180)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
    at java.util.concurrent.FutureTask.run (FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
    at java.lang.Thread.run (Thread.java:842)

My command is:

mvn checkstyle:check --activate-profiles 'checkstyle-semantics' -Dcheckstyle.output.format=sarif

My versions are:

        <profile>
            <id>checkstyle-semantics</id>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>3.4.0</version>
                        <dependencies>
                            <dependency>
                                <groupId>com.puppycrawl.tools</groupId>
                                <artifactId>checkstyle</artifactId>
                                <version>10.17.0</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <configLocation>checkstyle-configuration-semantics.xml</configLocation>
                            <outputFileFormat>sarif</outputFileFormat>
                        </configuration>
                        <executions>
                            <execution>
                                <id>checkstyle:check semantics</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <phase>prepare-package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

@michael-o
Copy link
Member

@motlin, can you provide mvn -X of the plugin execution. I'd like to see the dep tree. This output confuses me.

@michael-o
Copy link
Member

Hold on, 10.17.0 is a major version. Signatures might have changed from 9. You should check that first. If it runs with the stock one, then the issue is clear.

@motlin
Copy link

motlin commented Jun 6, 2024

Downgrading to Checkstyle 9.3 seemed to work. It's not ideal since I use some newer checks.

@michael-o
Copy link
Member

Downgrading to Checkstyle 9.3 seemed to work. It's not ideal since I use some newer checks.

This is something we cannot fix because Checkstyle raised to Java 11 some time ago.

@motlin
Copy link

motlin commented Jun 6, 2024

Would it make sense to release versions of maven-checkstyle-plugin that are separately compatible with 9.x and 10.x?

@michael-o
Copy link
Member

Would it make sense to release versions of maven-checkstyle-plugin that are separately compatible with 9.x and 10.x?

Technically yes, but not before the Doxia 2.0.0 stack has been integrated. That would force me to maintain four versions which I am not going to do.

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

Successfully merging this pull request may close these issues.

4 participants