-
Notifications
You must be signed in to change notification settings - Fork 13
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
Load external denylist entries via ServiceLoader #261
Conversation
when running
Same issue happened with the |
For the spotless issue, just re-run it again without configuration cache. It's a weird issue with spotless that I don't really understand :/ |
val loader = ServiceLoader.load(DenyListedEntryLoader::class.java) | ||
|
||
return mutableSetOf<DenyListedEntry>().apply { | ||
loader.iterator().forEachRemaining { addAll(it.entries) } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to do something like ServiceLoader.load(...).iterator().toSet()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, the more concise the better. I'm not seeing an applicable toSet()
call to use here, but I might be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe .iterator().asSequence().toSet()
@@ -0,0 +1,5 @@ | |||
package slack.lint.denylistedapis | |||
|
|||
interface DenyListedEntryLoader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding an experimental annotation for this? None of this is a stable API anyway, but want to make it doubly-clear here :). Can call it ExperimentalSlackLintApi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also name this DenyListedEntryProvider
and make it have a function instead (i.e. getEntries()
) that takes a JavaContext
. Then let's lazily load these in the element handler and provide the available context to it, so we can minimize loading (especially if there are entries provided that don't apply in certain contexts).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah sure, good call.
@erawhctim are you still planning to finish this? |
Summary
Allow consumers to supply their own
DenyListedEntry
s via aServiceLoader
interface. Fixes #241.Open to suggestions on any of the names, or if there's a preferred use of
ServiceLoader
(it's new to me!)Requirements (place an
x
in each[ ]
)