clj-commons / clj-commons/digest

Consider making digest even more amenable to static analysis

Open
#14 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
Clojure
Stars
165
Forks
17
PR merge metrics
No merged PRs in 30d

Description

## Currently...
The digest library generates its API at load time.

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

https://github.com/clj-commons/digest/blob/bec1e0e6b887bdb408674f0025357cc49b02b434/src/clj_commons/digest.clj#L104-L108

## But...
This did not work for cljdoc linting with clj-kondo because it disables checking `comment`s.

## 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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/clj_commons/digest.clj, especially the API-generation code around lines 104-108, and review how clj-kondo and cljdoc linting treat the comment block. Choose and document an approach among the four proposals, then verify that the digest API is discoverable by static analysis without falling out of sync with available providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.