-
Notifications
You must be signed in to change notification settings - Fork 467
spotlessCheck
could add comments and suggested fix to GitHub PR
#655
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
Comments
Violation-comments to github uses https://github.com/tomasbjerre/violations-lib I may also be able to have a look in a few days/weeks |
Or you can add an option in Spotless to create a report on one of the formats supported by violations-lib. |
Integration with https://github.com/reviewdog/reviewdog would also be nice |
The reviewdog diagnostic format is designed to associate diagnostic messages with a code and a severity against sections of files. Correct me if I've misunderstood but I don't think Spotless has a variety of messages / codes / severities to offer. We'd be left to identify the suggested changes and produce uniform generic message / code / severity for each of them. It appears that reviewdog also supports a diff input and given that Spotless is built around a simple |
The reviewdog data format includes a I agree that the messages/codes/severities will all be the same, except for failures. Spotless is designed around In particular, ktlint throws errors for lots of things which don't fit the If you make a PR which adds a |
A PR against #1097 which pipes
|
I'm interested in this feature, so I'm planning to implement it myself. 🚀 To elaborate a bit more: this feature has been discussed across several
One of the related issues mentioned that the feature was blocked due to internal changes, but looking at the PR, it seems that it has since been merged. I also noticed another PR that introduces the concept of lint, which seems related to solving this issue. So, to ensure a smooth design process, I'd like to confirm the latest state of the issue. |
Wonderful!!!
Correct, the blockers to this have been solved. Our core abstractions are now very stable, I anticipate no changes to our core abstractions in the foreseeable future. Big picture, the goal of Spotless is to be a formatter, not a linter. But inevitably, there are some "formatting issues" which can't be automatically fixed. Syntax errors, for example. And there are linters which can sometimes automatically provide fixes, which makes them more like a formatter. So the line is blurrier than it first appears. Spotless handles this like so: class DirtyState {
boolean isClean()
byte[] canonicalBytes() // only legal to call if !isClean()
}
class Lint {
int lineStart, lineEnd; //1-indexed, inclusive
String shortCode, detail;
}
class LintState {
DirtyState dirtyState;
List<List<Lint>> lintsPerStep;
}
// key entrypoint
public static LintState of(Formatter formatter, File file) { ... } So inside a
It seems more complicated than it needs to be. But until we separated out this lint concept, it was common for silly little quibbles to prevent a file from being formatted. Now the file can get formatted first, and then we fail the build based on the quibble. If you run
I have no strong opinion that it needs to use or avoid ReviewDog vs some other middleware vs go straight through hub4j/github-api. Implementor's choice. If one gets built I think it will be relatively easy for people to integrate with it in other ways later. This isn't required, but I think snapshot testing will be quite helpful. We are already using Selfie for inline snapshots like so: spotless/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java Lines 69 to 70 in d97b95d
|
Thank you for your detailed explanation :) I’ll try designing the solution myself first, and then share a draft PR (or something similar) to get your feedback. |
Per @rompic's great idea on gitter.
https://github.com/jenkinsci/violation-comments-to-github-plugin
The text was updated successfully, but these errors were encountered: