Git Product home page Git Product logo

clojure-analyzer's Introduction

Exercism Clojure analyzer

Exercism's Automated Analysis a long-term endeavour to provide rapid feedback to students through the use of automated code analysis. The Clojure analyzer is based on clj-kondo, rewrite-clj and clojure/tools.analyzer.

Usage

To run the analyzer, pass it an exercise <slug>, an input solution file and an output directory for the AST:

$ clojure -m exercism.clojure-analyzer two-fer resources/example.clj resources/output/
Analyzing: two-fer
Saved to: resources/output/analysis.json

To generate a JSON static analysis report for a solution file using clj-kondo:

$ clj-kondo --lint resources/example.clj --config '{:output {:analysis true :format :json}}'
{"findings":[],"summary":{"error":0,"warning":0,"info":0,"type":"summary","duration":53},"analysis":{"namespace-definitions":[{"filename":"resources/example.clj","row":1,"col":1,"name":"two-fer"}],"namespace-usages":[],"var-definitions":[{"filename":"resources/example.clj","row":3,"col":1,"ns":"two-fer","name":"two-fer","fixed-arities":[0,1]}],"var-usages":[{"fixed-arities":[0,1],"name":"str","filename":"resources/example.clj","from":"two-fer","col":8,"from-var":"two-fer","arity":1,"varargs-min-arity":1,"row":4,"to":"clojure.core"},{"fixed-arities":[0,1],"name":"str","filename":"resources/example.clj","from":"two-fer","col":12,"from-var":"two-fer","arity":3,"varargs-min-arity":1,"row":5,"to":"clojure.core"},{"name":"defn","filename":"resources/example.clj","from":"two-fer","macro":true,"col":2,"arity":3,"varargs-min-arity":2,"row":3,"to":"clojure.core"}]}}

Run the project's tests:

$ clojure -A:test:runner

Build an uberjar:

$ clojure -A:uberjar

Run that uberjar:

$ java -jar clojure-analyzer.jar

Documentation

The specification of the analyzer interface is found in the track-tooling section of the v3-docs repo.

Copyright

All content in this repository is Copyright to Exercism and licensed under AGPL.

clojure-analyzer's People

Contributors

bobbicodes avatar erikschierboom avatar exercism-bot avatar ihid avatar kytrinyx avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clojure-analyzer's Issues

Do better analysis

Clerk was just open sourced today and I am very excited. Nextjournal has been doing amazing things and I've taken much inspiration from their work, we seem to have the same taste in tooling. They provide a next-generation coding notebook experience, and have previously open-sourced clojure-mode for Codemirror 6 which I'd love to integrate into our web editor as well... but that's another issue.

The reason I'm so excited about Clerk is that it makes wonderful use of tools.analyzer, and I tend to work best when given good examples to follow. The techniques they use to analyze Clojure files and gather comprehensive data to provide their live notebook environment will also apply to our purpose for analyzing user submissions.

Launch analyzer

Seems we have a run script, which calls the main function with the right args, and the Dockerfile. Details are still left to work out but the pieces are in place. I'm very slow when it comes to docker stuff because it often causes my machines to explode.

Probably ought to complete #20 because it will avoid the JVM and make analysis time nearly instantaneous.

The next thing that I know of is to create the template file in https://github.com/exercism/website-copy/tree/main/analyzer-comments to display the analysis results. Since we are just displaying the results of the script (and not creating individual analyzer comments), it will just be one file called generic.md. For example, the bash track uses results from ShellCheck: https://github.com/exercism/website-copy/blob/main/analyzer-comments/bash/shellcheck/generic.md

The master branch will be renamed to main

In line with our new org-wide policy, the master branch of this repo will be renamed to main. All open PRs will be automatically repointed.

GitHub will show you a notification about this when you look at this repo after renaming:

Screenshot 2021-01-27 at 15 31 45

In case it doesn't, this is the command it suggests:

git branch -m master main
git fetch origin
git branch -u origin/main main

You may like to update the primary branch on your forks too, which you can do under Settings->Branches and clicking the pencil icon on the right-hand-side under Default Branch:

Screenshot 2021-01-27 at 18 50 08

We will post a comment below when this is done. We expect it to happen within the next 12 hours.

Use clj-kondo as native binary

The analyzer currently uses clj-kondo as a Clojure library to extract analysis data which is then processed into JSON. This is not ideal for production, because clj-kondo is already shipped as a native binary that runs on Alpine.

I think it would certainly be preferable to instead use an image with clj-kondo in it and call it as a CLI, then have another script that handles those results.

Doc for getting analysis data via CLI: https://github.com/clj-kondo/clj-kondo/tree/master/analysis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.