Rust-based static analysis for TypeScript projects

Overview

FTA

Fast TypeScript Analyzer

FTA (Fast TypeScript Analyzer) is a super-fast TypeScript static analysis tool written in Rust. It captures static information about TypeScript code and generates easy-to-understand analytics that tell you about complexity and maintainability issues that you may want to address.

FTA uses swc to parse your code then runs various analytical routines against it to understand how complex and maintainable it is likely to be. JavaScript code is also supported.

Quickstart

There are several ways to use fta. The simplest is to use fta-cli:

npx fta-cli path/to/project

Example output against the Redux project:

| ----------------------------------------- | ------------ | ----------------------------- | ------------------- |
| File                                      |   Num. lines |   FTA Score (Lower is better) |          Assessment |
| ----------------------------------------- | ------------ | ----------------------------- | ------------------- |
| src\createStore.ts                        |          490 |                         70.25 | (Needs improvement) |
| website\src\pages\index.js                |          218 |                         64.94 | (Needs improvement) |
| src\combineReducers.ts                    |          202 |                         61.61 | (Needs improvement) |
| src\compose.ts                            |           62 |                         52.68 |   (Could be better) |
| src\bindActionCreators.ts                 |           84 |                         51.89 |   (Could be better) |
| src\utils\kindOf.ts                       |           71 |                         48.80 |                  OK |
| src\utils\warning.ts                      |           19 |                         35.00 |                  OK |
| src\utils\isPlainObject.ts                |           15 |                         34.32 |                  OK |
| src\utils\symbol-observable.ts            |           11 |                         31.89 |                  OK |
| website\docusaurus.config.js              |          197 |                         18.04 |                  OK |
| website\sidebars.js                       |          149 |                         15.82 |                  OK |
| rollup.config.js                          |           80 |                         15.79 |                  OK |
| tsup.config.ts                            |           73 |                         15.59 |                  OK |
| src\applyMiddleware.ts                    |           78 |                         15.45 |                  OK |
| website\src\pages\errors.js               |           63 |                         15.09 |                  OK |
| website\src\js\monokaiTheme.js            |           63 |                         14.32 |                  OK |
| src\utils\actionTypes.ts                  |           18 |                         11.91 |                  OK |
| src\index.ts                              |           47 |                         11.84 |                  OK |
| vitest.config.ts                          |           18 |                          9.92 |                  OK |
| docs\components\DetailedExplanation.jsx   |           16 |                          9.67 |                  OK |
| src\utils\formatProdErrorMessage.ts       |           14 |                          8.57 |                  OK |
| ----------------------------------------- | ------------ | ----------------------------- | ------------------- |
21 files analyzed in 0.1079s.

Call FTA from a script

  1. To call FTA from a script, install fta-cli as a dependency and call it:
yarn add fta-cli
# or
npm install fta-cli
# or
pnpm install fta-cli
  1. Call fta from a package.json script:
"scripts": {
  "fta": "fta src"
}

Call FTA from code

You can also call fta-cli from code:

import { runFta } from "fta-cli";
// CommonJS alternative:
// const { runFta } = require("fta-cli");

// Print the standard ascii table output
const standardOutput = runFta("path/to/project");

// Alternatively, get the full output as JSON so that you can interact with it
const output = runFta("path/to/project", { json: true });

Output

By default, fta outputs a table of output that summarizes the result. You can optionally supply the json argument to get the full output as JSON.

You can also get the JSON output in a scripting context:

fta /path/to/project --json

For more information on using FTA, be sure to check out the docs.

Configuring FTA

Various configuration options are available, including the ability to cause CI to fail if a certain score threshold is breached. See the full Configuration options on the docs.

Docs

Read the full documentation on the docs.

License

MIT

Comments
  • Needs distribution strategy

    Needs distribution strategy

    I need to decide how to distribute fta so that it can be consumed!

    Ideally, we want minimal prerequisites and to aim for maximum performance. The primary use case is calling it from CI. It should also support some basic configuration options, such as a threshold for making CI fail.

    I also have hopes of publishing it as a Rust library (the same as swc), but that is definitely a lower priority.

    opened by sgb-io 3
  • Publishing process results in 2 tags

    Publishing process results in 2 tags

    This isn't creating a specific problem, but could be confusing.

    e.g. v0.1.7 and 0.1.7

    I think that the GitHub release also creates a tag. Interestingly, this does not trigger the release CI, though.

    opened by sgb-io 1
  • Fix linux binary

    Fix linux binary

    • Build ubuntu binaries on 20.04 rather than latest, to ensure glibc requirements are met
    • Fix chmod patch for linux binaries which were missing the actual binary name (!)

    Fixes #27

    opened by sgb-io 0
  • Fix various npm teething issues

    Fix various npm teething issues

    • Named binary, since we've had to rename the npm dependency
    • Fix cases of old binary dir name
    • Fix wiring of binary calling script
    • Relocate readme so that NPM shows something proper
    opened by sgb-io 0
  • Add a frontend for the program

    Add a frontend for the program

    • The program now scans whole projects
    • Configuration options are supported
    • Code generally refactored
    • Failsafe added
    • Support for score_cap, too
    • Updated output + formatting
    opened by sgb-io 0
  • New option: exclude small files

    New option: exclude small files

    False by default, a handy option to filter out all small files (say, under 8 lines) - in a typical ts project this can remove dozens of .index.ts one-or-few liners

    opened by sgb-io 0
  • Look at capturing mapping of operands/operators/cyclo operators back to source code

    Look at capturing mapping of operands/operators/cyclo operators back to source code

    This could potentially enable a more fine grained output. Imagine an IDE extension that displays where complex areas in the code are making it difficult to maintain.

    opened by sgb-io 0
Releases(v0.1.10)
Owner
Sam Brown
Making & breaking stuff.
Sam Brown
Modrinth API is a simple library for using Modrinth's API in Rust projects

Ferinth is a simple library for using the Modrinth API in Rust projects. It uses reqwest as its HTTP(S) client and deserialises responses to typed structs using serde.

null 20 Dec 8, 2022
Testing interactions with other NFT projects locally is difficult

Terra NFT Stub contract Testing interactions with other NFT projects locally is difficult. Terra NFT Stub makes things a bit easier by providing a con

smaster0517 5 Apr 6, 2022
Futures-based QUIC implementation in Rust

Pure-rust QUIC protocol implementation Quinn is a pure-rust, future-based implementation of the QUIC transport protocol undergoing standardization by

null 2.6k Jan 8, 2023
A multiplayer web based roguelike built on Rust and WebRTC

Gorgon A multiplayer web-based roguelike build on Rust and WebRTC. License This project is licensed under either of Apache License, Version 2.0, (LICE

RICHΛRD ΛNΛYΛ 2 Sep 19, 2022
Dropping GFW DNS contaminated packets based on Rust + eBPF

Dropping GFW DNS contaminated packets based on Rust + eBPF

ihc童鞋@提不起劲 1k Jan 3, 2023
A rust-based command line tool to serve as a gateway for a Internet Computer replica.

icx-proxy A command line tool to serve as a gateway for a Internet Computer replica. Contributing Please follow the guidelines in the CONTRIBUTING.md

DFINITY 25 Sep 6, 2022
A minimalistic encryption protocol for rust async streams/packets, based on noise protocol and snow.

Snowstorm A minimalistic encryption protocol for rust async streams / packets, based on noise protocol and snow. Quickstart Snowstorm allows you to se

Black Binary 19 Nov 22, 2022
A Rust based DNS client, server, and resolver

Trust-DNS A Rust based DNS client, server, and Resolver, built to be safe and secure from the ground up. This repo consists of multiple crates: Librar

Benjamin Fry 2.7k Dec 30, 2022
Peer-to-peer communications library for Rust based on QUIC protocol

qp2p Crate Documentation MaidSafe website SAFE Dev Forum SAFE Network Forum Overview This library provides an API to simplify common tasks when creati

MaidSafe 337 Dec 14, 2022
A minimalist socket-based client/server in Rust to illustrate a tutorial

The basics of unix sockets This repository serves as a reference for this tutorial blogpost How to run Install Rust and Cargo, and then do: cargo run

Emmanuel Bosquet 4 Dec 4, 2022
A generic Rust based Bigtable connection library implemented using gRPC

A generic Rust based Bigtable connection library refactored out the solana mono-repo so that can be shared for different applications.

Lijun Wang 3 Sep 25, 2022
A performant but not-so-accurate time and capacity based cache for Rust.

fastcache A performant but not-so-accurate time and capacity based cache for Rust. This crate provides an implementation of a time-to-live (TTL) and c

Pure White 3 Aug 17, 2023
A simple message based networking library for the bevy framework

Spicy Networking for Bevy bevy_spicy_networking is a solution to the "How do I connect multiple clients to a single server" problem in your bevy games

Cabbit Studios 67 Jan 1, 2023
Fullstack development framework for UTXO-based dapps on Nervos Network

Trampoline-rs The framework for building powerful dApps on the number one UTXO chain, Nervos Network CKB. This is an early-stage, currently very incom

TannrA 2 Mar 25, 2022
Modular IPC-based desktop launcher service

Pop Launcher Modular IPC-based desktop launcher service, written in Rust. Desktop launchers may interface with this service via spawning the pop-launc

Pop!_OS 125 Dec 23, 2022
A Markov chain based Discord chat bot.

A Markov chain based Discord chat bot. Building It is recommended to use cargo.

Dominik Miedziński 1 Dec 26, 2021
Userspace libpcap-based tool to mirror your dns traffic

DNS traffic mirroring tool (dns-mirror) Description Userspace libpcap-based tool. dns-mirror sniffs dns packets on the given interface and proxies it

Timofey 1 Mar 15, 2022
This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility

This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility (connected and autonomous vehicles, road side units, vulnerable road users,...). Let's connect your device or application to our Intelligent Transport Systems (ITS) platform!

Orange 4 Nov 29, 2022
Astar Network is an interoperable blockchain based the Substrate framework and the hub for dApps within the Polkadot Ecosystem

Astar Network is an interoperable blockchain based the Substrate framework and the hub for dApps within the Polkadot Ecosystem. With Astar Network and

Astar Network (Plasm) 43 Dec 14, 2022