Git Product home page Git Product logo

typescript-analyzer's Introduction

@exercism/typescript-analyzer

typescript-analyzer / main typescript-analyzer / deploy

Runs static analysis using @exercism/static-analysis on exercises from the @exercism/typescript track.

Installation

Clone this repository and then run:

yarn install

You'll need at least Node LTS for this to work.

yarn build

Usage

You can run this either via yarn:

yarn analyze:bat --debug --console two-fer ~/path/to/solution/folder

Or directly via the provided shell script:

./bin/analyze.sh --debug --console two-fer ~/path/to/solution

Add the --debug and --console flags to get output in the terminal window.

Using docker

To create the image, execute the following command from the repository root:

docker build -t exercism/typescript-analyzer .

To run from docker pass in the solutions path as a volume and execute with the necessary parameters:

docker run -v $(PATH_TO_SOLUTION):/solution exercism/typescript-analyzer ${SLUG} /solution

Example:

docker run -v ~/solution-238382y7sds7fsadfasj23j:/solution exercism/typescript-analyzer two-fer /solution

Tools

We use various tools to maintain this repository and this analyzer. In order to contribute to the code of this track, you'll need NodeJS (LTS or higher) installed, with some of the bin/* files having extra dependencies, as listed in their file-level commentary.

analyze (.sh, .bat)

./bin/analyze.sh two-fer ~/folder/to/solution -dcp

This runs the analyzer using two-fer as exercise and a path to a solution. Most scripts, including this one, accept a wide range of flags to change or enhance the behaviour, as coded in execution_options.ts.

Run with the -h / --help flag to get a list of flags and their description.

./bin/analyze.sh --help

You'll most likely want -dcp (--debug,--console and --pretty) during development, which enables console output (instead of stdout/stderr) and shows logger.log as well as logger.error and logger.fatal. It will also format the output JSON with 2 space indentation, both in the output file and the console.

If you wish to preview the actual messages, pass in --noTemplates to use the analyzer CommentFactories to generate actual messages. If the comment factories are kept in-sync with website-copy, it will be the exact same output as on the site.

batch (.sh, .bat)

./bin/batch.sh two-fer -cp

Runs all the fixtures in ~/test/fixtures/two-fer through the analyzer, giving a summary at the end with all results. This places an analysis.json in the source fixture folder.

You'll most likely want -cp (--console and --pretty) during development, which enables console output (instead of stdout/stderr) and formats the output JSON with 2 space indentation.

If you wish to preview the actual messages, pass in --noTemplates to use the analyzer CommentFactories to generate actual messages. If the comment factories are kept in-sync with website-copy, it will be the exact same output as on the site.

remote (.sh, .bat)

./bin/remote.sh https://exercism.io/tracks/typescript/exercises/two-fer/solutions/41ff482d158e4a708677d1ccac0af013 -dcp --dry

You need the exercism cli in order for this to work. It takes an exercism solution url and downloads it using the exercism cli. It then runs the analyzer on it.

You'll most likely want -dcp --dry (--debug, --pretty, --console and dry run) during development, which enables console output (instead of stdout/stderr), shows logger.log as well as logger.error and logger.fatal, pretty prints the JSON output and disables writing the output to analysis.json.

You can pass the following type of URLs:

  • Published solutions: /tracks/typescript/exercises/<slug>/<id>
  • Mentor solutions: /mentor/solutions/<id>
  • Your solutions: /my/solutions/<id>
  • Private solutions: /solutions/<id>

If you wish to preview the actual messages, pass in --noTemplates to use the analyzer CommentFactories to generate actual messages. If the comment factories are kept in-sync with website-copy, it will be the exact same output as on the site.

typescript-analyzer's People

Contributors

ccare avatar dependabot[bot] avatar erikschierboom avatar exercism-bot avatar kytrinyx avatar pertrai1 avatar roshanjossey avatar sleeplessbyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-analyzer's Issues

Incorrect Analysis: Analyzer giving incorrect example on Two-Fer exercise

Describe the incorrectness
The analyzer commented on my solution that it could be helpful to use string interpolation. In the example it provides it show this: "Hello there \${firstName}, I will give you \${calculateInventory()} apples.". However, this does not work. The only way I get it to work is by using backticks (`) instead of single or double quotes. Even when escaping the $, running yarn test fails.

Which exercise
Two Fer

Source file(s)

two-fer.ts

Expected analysis
I expect the example to use backticks instead of double quotes.

Additional context
Screenshot of my code and the output of running yarn test
299AFBCF-4BB8-48E6-B895-C3A3608FFFE4

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.

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.