Skip to content

Commit

Permalink
Bump version for release
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Feb 14, 2024
1 parent 6677356 commit b41a5af
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This changelog is loose. Versions are not semantic, they are incremental. Splint

## Unreleased

## v1.13 - 2024-02-14

### New Rules

- `lint/prefer-method-values`: Prefer `(^[] String/toUpperCase "noah")` to `(.toUpperCase "noah")`.
Expand Down
31 changes: 30 additions & 1 deletion docs/rules/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,35 @@ Empty loops with nested when can be `while`.

---

## lint/prefer-method-values

| Enabled by default | Version Added | Version Updated |
| ------------------ | ------------- | --------------- |
| true | 1.13 | 1.13 |

**NOTE**: Requires Clojure version 1.12.0.

Uniform qualified method values are a new syntax for calling into java code. They must resolve to a single static or instance method and to help with that, a new metadata syntax can be used: `^[]` aka `^{:param-tags []}`. Types are specified with classes, each corrosponding to an argument in the target method: `(^[long String] SomeClass/someMethod 1 "Hello world!")`. It compiles to a direct call without any reflection, guaranteeing optimal performance.

If it doesn't resolve to a single method, then the Clojure compiler throws a syntax error (IllegalArgumentException). Such ahead-of-time compilation checking is a powerful and helpful tool in writing correct and performant code. Given that, it is preferable to exclusively use method values.

### Examples

```clojure
; bad
(.toUpperCase "noah")
(. "noah" toUpperCase)

; good
(^[] String/toUpperCase "noah")
```

### Reference

* <https://insideclojure.org/2024/02/12/method-values>

---

## lint/prefer-require-over-use

| Enabled by default | Version Added | Version Updated |
Expand Down Expand Up @@ -587,7 +616,7 @@ x

| Enabled by default | Version Added | Version Updated |
| ------------------ | ------------- | --------------- |
| true | <<next>> | <<next>> |
| false | 1.13 | 1.13 |

**NOTE**: Requires Clojure version 1.12.0.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Avoid use of `satisfies?` as it is extremely slow. Restructure your code to rely

Currently only checks string literals.

If `lint/prefer-method-values` is enabled, then the suggestion will use that syntax.

### Examples

```clojure
Expand All @@ -63,6 +65,7 @@ Currently only checks string literals.

; good
(.equals "foo" s)
(String/equals "foo" s)
```

---
Expand Down
2 changes: 1 addition & 1 deletion resources/SPLINT_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12
1.13
10 changes: 5 additions & 5 deletions resources/config/default.edn
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
lint/prefer-method-values
{:description "Use uniform Class/member syntax when writing interop."
:enabled true
:added "<<next>>"
:updated "<<next>>"
:added "1.13"
:updated "1.13"
:link "https://insideclojure.org/2024/02/12/method-values"}

lint/prefer-require-over-use
Expand All @@ -173,9 +173,9 @@

lint/require-explicit-param-tags
{:description "Require explicit :param-tags on method values."
:enabled true
:added "<<next>>"
:updated "<<next>>"
:enabled false
:added "1.13"
:updated "1.13"
:chosen-style :wildcard
:supported-styles [:both :missing :wildcard]
:link "https://insideclojure.org/2024/02/12/method-values"}
Expand Down

0 comments on commit b41a5af

Please sign in to comment.