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

Add testDocumentationExample #244

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Add testDocumentationExample #244

merged 2 commits into from
Jan 22, 2024

Conversation

ZacSweers
Copy link
Collaborator

So a neat feature @tnorbye told me about recently is that adding a test with the name testDocumentationExample will automatically index as a sample error on the lint docs site (which index our lints!)

This is a little test of that to see if it shows up here:

@ZacSweers ZacSweers requested a review from chrisbanes January 22, 2024 06:41
@tnorbye
Copy link

tnorbye commented Jan 22, 2024

(FYI, that site doesn't get updated automatically, I do manual pushes every now and then. Yeah I probably should automate it. Here's the issue documentation generator by the way: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/cli/src/main/java/com/android/tools/lint/LintIssueDocGenerator.kt )

@tnorbye
Copy link

tnorbye commented Jan 22, 2024

...basically, I try to have every lint check have a test which is just a "good example" of an error -- instead of (as I initially did) mixing a bunch of corner cases all into the same test.

@ZacSweers ZacSweers added this pull request to the merge queue Jan 22, 2024
Merged via the queue into main with commit 0aabefe Jan 22, 2024
2 checks passed
@ZacSweers ZacSweers deleted the z/examples branch January 22, 2024 17:22
@ZacSweers
Copy link
Collaborator Author

Nice

image

@tnorbye
Copy link

tnorbye commented Jan 26, 2024

The bottom of your screenshot shows that it actually just picked the first unit test it could find. That's probably because it was from the last time I had run the docs generation -- before your change.

I just updated the doc snapshot yesterday -- it now has the latest released version of the slack lint checks (91 issues included). And now it's picking up the default too -- it's no longer talking about having picked the first test etc:[
Screenshot 2024-01-26 at 13 32 45

P.S. As I was looking I noticed that in some places there is no space between a previous sentence and the next one. I thought maybe there was an error in the formatting somewhere -- but I actually see it in the text messages in your unit tests too: https://github.com/slackhq/compose-lints/blob/main/compose-lint-checks/src/test/java/slack/lint/compose/ComposableFunctionNamingDetectorTest.kt -- look for "letter.They". I think what's going on is that you're passing in the explanation text as the error message (that's not usually recommended for reasons explained here: https://googlesamples.github.io/android-custom-lint-rules/api-guide.md.html#errormessageconventions/includedetails -- and your issue explanation seems to not put a space before the line continuation () characters. Maybe lint is using a different convention than other tools? But lint treats this kind of like string concatenations, e.g.

foo \
bar

is the same as

"foo " +
"bar".

So

foo\
bar

is treated as "foobar". If what we're doing is different from a standard convention maybe we should change it. I suspect nobody actually wants the behavior where there's no space between the previous line and the next one, so we could just insert it...

@tnorbye
Copy link

tnorbye commented Jan 26, 2024

Hmmm a quick test makes it seem like at least shells behave the same way. So for the source code in https://github.com/slackhq/compose-lints/blob/main/compose-lint-checks/src/main/java/slack/lint/compose/ComposableFunctionNamingDetector.kt for example, I think the issue explanation should have an extra space before the \ on most lines.

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.

3 participants