Trust-Machines / BNS-V2

MIT License
10 stars 3 forks source link

Run static analysis as part of build/CI #72

Open moodmosaic opened 1 month ago

moodmosaic commented 1 month ago

In addition to https://github.com/Trust-Machines/BNS-V2/issues/70#issuecomment-2236031501, here's some more output from running stacy-analyzer, which suggests that it should run as a build/CI step:

https://github.com/Trust-Machines/BNS-V2/blob/97be5fd93e7676f74bfca5aecdbd84008e52e474/contracts/BNS-V2.clar

Warning: Behavior of 'element-at' changed from Clarity1 to Clarity2, now outputs optional value.
     |
 207 |         (ok (unwrap! (element-at NAMESPACE-PRICE-TIERS (min u7 (- namespace-len u1))) ERR-UNWRAP))
     |                       ^^^^^^^^^^
     Note: Suggestion: use 'element-at?' to make this behavior explicit.

Warning: Behavior of 'element-at' changed from Clarity1 to Clarity2, now outputs optional value.
      |
 1402 |     (unwrap-panic (element-at buckets index))
      |                    ^^^^^^^^^^
      Note: Suggestion: use 'element-at?' to make this behavior explicit.

https://github.com/Trust-Machines/BNS-V2/blob/97be5fd93e7676f74bfca5aecdbd84008e52e474/contracts/BNS-V2.clar

Warning: Use of unwrap-panic.
     |
 360 |         (asserts! (is-eq contract-caller (unwrap-panic manager)) ERR-NOT-AUTHORIZED)
     |                                           ^^^^^^^^^^^^
     Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1289 |         (map-set name-properties { name: name, namespace: namespace } (merge (unwrap-panic (map-get? name-properties { name: name, namespace: namespace })) {stx-burn: (try! (compute-name-price name (get price-function namespace-props)))}))
      |                                                                               ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1330 |                         (if (< burn-block-height (unwrap-panic (get-renewal-height (unwrap-panic (get-id-from-bns name namespace)))))
      |                                                   ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1330 |                         (if (< burn-block-height (unwrap-panic (get-renewal-height (unwrap-panic (get-id-from-bns name namespace)))))
      |                                                                                     ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1331 |                             (+ (unwrap-panic (get-renewal-height (unwrap-panic (get-id-from-bns name namespace)))) lifetime)
      |                                 ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1331 |                             (+ (unwrap-panic (get-renewal-height (unwrap-panic (get-id-from-bns name namespace)))) lifetime)
      |                                                                   ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1402 |     (unwrap-panic (element-at buckets index))
      |      ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of divide inside a multiplication. This could result in a precision loss.
      |
 1552 |         (ok (* (/ (* (get coeff price-function) (pow (get base price-function) exponent)) (max nonalpha-discount no-vowel-discount)) u10))
      |              ^
      Note: Try multiplication before division.

Warning: Use of unwrap-panic.
      |
 1631 |             (name-index (unwrap-panic (map-get? name-to-index {name: name, namespace: namespace})))
      |                          ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1639 |             (asserts! (> (unwrap-panic (get created-at (map-get? name-preorders {hashed-salted-fqn: fqn, buyer: (unwrap-panic (get preordered-by name-props))}))) tx-sender-preorder-height) ERR-PREORDERED-BEFORE)
      |                           ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1639 |             (asserts! (> (unwrap-panic (get created-at (map-get? name-preorders {hashed-salted-fqn: fqn, buyer: (unwrap-panic (get preordered-by name-props))}))) tx-sender-preorder-height) ERR-PREORDERED-BEFORE)
      |                                                                                                                  ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

Warning: Use of unwrap-panic.
      |
 1641 |             (asserts! (> (unwrap-panic (get registered-at name-props)) tx-sender-preorder-height) ERR-FAST-MINTED-BEFORE)
      |                           ^^^^^^^^^^^^
      Note: Use unwrap! and handle the error.

/cc @BowTiedRadone @wileyj