kibit icon indicating copy to clipboard operation
kibit copied to clipboard

Kibit blows up on qualified keywords when require has a `:refer`

Open splayemu opened this issue 4 years ago • 1 comments

Overview

Running kibit blows up on qualified keywords when the :refer statement comes before the :as statement in the require.

$ lein kibit
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Retrieving lein-kibit/lein-kibit/0.1.8/lein-kibit-0.1.8.pom from clojars
Retrieving org/clojure/clojure/1.4.0/clojure-1.4.0.pom from central
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.pom from central
Retrieving org/clojure/clojure/1.6.0/clojure-1.6.0.pom from central
Retrieving org/clojure/clojure/1.5.1/clojure-1.5.1.pom from central
Retrieving org/clojure/clojure/1.4.0/clojure-1.4.0.jar from central
Retrieving lein-kibit/lein-kibit/0.1.8/lein-kibit-0.1.8.jar from clojars
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.jar from central
Check failed -- skipping rest of file (src/repro/core.clj:4:null)
[line 4, col 10] Invalid keyword: ::s/derp.

Steps to reproduce:

  1. Create a clj project:
lein new repro
  1. Add kibit to leiningen plugins
(defproject repro "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "https://www.eclipse.org/legal/epl-2.0/"}
  :dependencies [[org.clojure/clojure "1.10.1"]]
  :plugins [[lein-kibit "0.1.8"]]
  :repl-options {:init-ns repro.core})
  1. Update src/repro/core.clj to be:
(ns repro.core
  (:require [clojure.string :refer [join] :as s]))

(::s/derp {})
  1. run kibit
lein kibit

Context

Clojure: 1.10.1 kibit version: 0.1.8

Note: didn't happen in kibit version: 0.1.6

splayemu avatar Apr 29 '20 23:04 splayemu

Looks like this line does not register the namespace alias if the position of :refer and :as are different. https://github.com/jonase/kibit/blob/ed2f8e57d28e77037f806a8ffa8da53efb308245/kibit/src/kibit/check/reader.clj#L64

iku000888 avatar Apr 29 '20 23:04 iku000888