Skip to content

Quality Assurance

Tommi Jalkanen edited this page Jun 19, 2018 · 8 revisions

For more extensive documentation for the tools, please visit the links provided below.

Project dependencies

Lein-ancient is a plugin for checking a project for outdated dependencies. To take it into use put [lein-ancient "0.6.10"] into the :plugins vector of the :user profile. This can be done my editing the file ~/.lein/profiles.clj. If the file doesn't exist you can create it and add the following code:

{:user {:plugins [] :dependencies []}}

To check the project dependencies run:

lein ancient

Lein-ancient can be also used to check dependencies found in ~/.lein/profiles.clj with:

lein ancient check-profiles

If you run into problems caused by various project dependencies, it can be useful to visualize the dependency hierarchy with:

lein deps :tree

The tool also suggests mofications to sidestep conflicting dependency requests.

Code lint tools

The following tools should be used with your own discretion. While the tools described below can potentially reveal useful improvements to the codebase, all of the output might not necessarily be correct or worth the effort. However, following best practices is encouraged. After all we are not living in Messocracy.

Always check that nothing breaks and that tests pass after following suggestions provided by the linting tools.

Kibit

Kibit is a static code analyzer that can be used to automatically search for patterns that can be writter in a more idiomatic way. Just like lein-ancient, we can start using it by modifying ~/.lein/profiles.clj. Add[lein-kibit "0.1.3"] to your :plugins vector in the :user profile. Then run:

lein kibit

Eastwood

Let's start with a warning. Eastwood will load your code for analyzing purposes and this may trigger side effects that happen when your code is loaded.

However, the loaded code will not be executed.

Eastwood is similar to Kibit in terms of functionality. It will examine the code inside the JVM. Once again we will need to add [jonase/eastwood "0.2.3"] into ~/.lein/profiles.clj just like we did with kibit. To run eastwood confined to :source-path:

lein eastwood "{:namespaces [:source-paths]}"

For further use cases visit the link for a more comprehensive documentation.

Bikeshed

Bikeshed is not really a linting tool, but it will automatically check your code for badly formatted code and provide information about documentation coverage. Taken into use by modifying the :user profile just like the previous tools with [lein-bikeshed "0.4.1"].Running bikeshed is as easy as issuing the command:

lein bikeshed

Slamhound

Warning: slamhound makes changes to your .clj files. Make sure you have a way to rollback unwanted changes.

Slamhound can be used to automatically manage namespaces. Missing namespaces can be imported and stale ones removed by the plugin. Unlike the other plugins, [slamhound "1.5.5"] is added to the :dependencies of your :user profile in ~/.lein/profiles.clj. Slamhound plugin is run by:

lein run -m slam.hound src/my/namespace.clj

To make your life easier, canonize slamhound usage by adding an alias inside your :user profile:

:aliases {"slamhound" ["run" "-m" "slam.hound"]}

Now we can run the plugin with:

lein slamhound src/my/namespace.clj

Running on a directory will do the same for all .clj files inside it.

Test coverage

cloverage is a yet another plugin you can use in your workflow. Cloverage will output how much of your code is being covered by the test suite. Add [lein-cloverage "1.0.9"] to :user profile in ~/.lein/profiles.clj. Run the tool with:

lein with-profile test cloverage