Skip to content

Conversation

GingerYouth
Copy link
Contributor

@GingerYouth GingerYouth commented Jun 27, 2025

  • Implemented PmdModule analogical to CheckstyleModule
  • Added test with some PMD violations and simple ruleset

Resolves #5379

@GingerYouth GingerYouth marked this pull request as ready for review June 27, 2025 16:09
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first contribution!

Can you also add an example project which serves as documentation as well as an integration test? Something like the example test for the checkstyle module (example/javalib/linting/2-checkstyle).

@GingerYouth
Copy link
Contributor Author

Updated.

@@ -42,7 +42,7 @@ PMD found 1 violation(s)
// Here's an example of producing HTML report:
/** Usage
> ./mill pmd -f "html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the command to write that to a file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the more likely use-case, as it can then easily be opened with a browser.

Copy link
Contributor Author

@GingerYouth GingerYouth Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the logic is: if user hasn't specified 'stdout' -> report will be saved to a file (see PmdModule, line 37).
If the user specified 'stdout' -> report won't be saved to a file.
I agree that case with reporting to a file is more likely, so it's default.

What would be the command to write that to a file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved docs to make it more clear #7d89e00

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I don't get why we see the HTML output here, since we didn't specify -s.

I also think it would be good to just print a line: "Writing output to path/to/file.html", so users do recognize and can click (most terminals support this, if it's an URL) on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Added log message for output file location.
  2. Changed options to make it more clear and in line with official PMD command-line options (now -s option is responsible only for enabling stdout, as it should be).

@GingerYouth
Copy link
Contributor Author

CI failing as I pulled from main and scalalib is no longer present there. Refactoring in progress.

*
* @note [[sources]] are processed when no [[PmdArgs.sources]] are specified.
*/
def pmd(@mainargs.arg pmdArgs: PmdArgs): Command[Int] = Task.Command {
Copy link
Member

@lefou lefou Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just returning a Int isn't that useful. It's unclear, if these are warning or errors. If there are errors, I would fail the task anyways. Also, I'd like to return the actual report file as PathRef.

Maybe, we should return a named tuple instead, so each value can have a proper name and we can extend it over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Added exit codes handling to pmdHandleExitCode, in line with PMD documentation.
  2. Changed return type to tuple with exit code and PathRef.
  3. Cleaned up some code in PmdModule.

@GingerYouth
Copy link
Contributor Author

This is ready for review/merge.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution!

@lefou lefou merged commit 00ddc31 into com-lihaoyi:main Jul 2, 2025
39 checks passed
@lefou lefou added this to the 1.0.0 milestone Jul 2, 2025
ajaychandran added a commit to ajaychandran/mill that referenced this pull request Jul 7, 2025
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.

PMD support (300USD Bounty)
3 participants