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

Linter: ! suffix consistency #101

Open
vemv opened this issue Dec 17, 2019 · 1 comment
Open

Linter: ! suffix consistency #101

vemv opened this issue Dec 17, 2019 · 1 comment

Comments

@vemv
Copy link
Contributor

vemv commented Dec 17, 2019

Context

A defn that is not suffixed in ! but which body contains a defn/macro call which is suffixed with ! is "inconsistent":

(defn foo [] ;; inconsistent: should be named `foo!`
  (swap! bar inc))

This gives the impression that foo is pure, while it is not.

The overall result is that the whole ! convention becomes weaker and less useful.

Task

Create a linter which analyzes all top-level defns/etc, detecting these inconsistencies.

Considerations

  • Renaming defns to satisfy the linter could constitute breaking changes; consumers should act carefully
  • A naive codebase that complied with this linter could have !s everywhere
    • That'd be a good thing: it would be evident that the codebase could benefit from a more functional architecture.

Additional resources

Use the bang! only for things not safe in an STM transaction.

@vemv
Copy link
Contributor Author

vemv commented Feb 20, 2020

Tried here clj-kondo/clj-kondo#751 proved tricky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant