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

Consider making digest even more amenable to static analysis #14

Open
lread opened this issue Jan 24, 2022 · 0 comments
Open

Consider making digest even more amenable to static analysis #14

lread opened this issue Jan 24, 2022 · 0 comments

Comments

@lread
Copy link

lread commented Jan 24, 2022

Currently...

The digest library generates its API at load time.

Clj-kondo will discover digest API vars when comments are not being skipped via this little trick:

;;;; Hints for clj-kondo
(comment
(declare sha3-384 sha-256 sha3-256 sha-384 sha3-512 sha-1 sha-224 sha1 sha-512 md2 sha sha3-224 md5)
)

But...

This did not work for cljdoc linting with clj-kondo because it disables checking comments.

Perhaps...

We could make digest even more clj-kondo friendly.

Idea 1 - Move declare

Move declare outside of comment block.
But this could get out of synch with digest API, I suppose.

Idea 2 - Create a hook

Create a custom clj-kondo hook for digest.
But since the API depends on querying available security providers, we might have the same issue as with idea 1?

Idea 3 - Generate API source

Instead of creating digest's API at load time, statically generate digest API source code.

Idea 4 - Just hand-code it

Instead of generating digest API automatically, do it by hand.
I mean, do the available providers change with new versions of Java?
And if they do, should the digest API be automatically changing?
Probably not.

Proposal

Without a deep understanding, idea 3 seems like a reasonable choice to me.
The API would be generated under a specific JVM (if that's important).
It is similar to idea 4 but perhaps a bit less prone to human error.
Thoughts?

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

No branches or pull requests

1 participant