Giter Site home page Giter Site logo

ctl's Introduction

Cytotoxic T Cells for your codebase *

*(Well, it's really just a fancy dead code reporter to be honest)

Usage: -lib ctl

Adding this library to your build will generate DCE reports, i.e. which classes are entirely eliminated, and on partially eliminated classes, which fields are eliminated.

Configuration:

  • -D ctl-skip: Skips reporting. Reporting is also skipped unless you use -dce full.
  • -D ctl-warn: Rather than producing a report, the lib will raise warnings at the relevant types/fields
  • -D ctl-out=<file>: Redirect reporting to file.
  • -D ctl-format=<json|hx>: Outputs as either JSON string or haxe serialized string of type cytotoxic.Data:
package cytotoxic;

typedef Item = {
  name:String,
  pos:String,
}

typedef Data = {
  deadTypes: Array<Item>,
  deadFields: Array<{
    type: Item,
    fields: Array<Item>
  }>,
}

ctl's People

Contributors

back2dos avatar

Stargazers

David Bruce avatar Dmytro Hryppa avatar sinh-png avatar  avatar Piotr Pawełczyk avatar  avatar  avatar Christopher Mandlbaur avatar Dimitri Pomier avatar  avatar Matan Uberstein avatar Rudy Ges avatar VirtualMaestro avatar  avatar Ben Morris avatar ANTW Games avatar Laurent Deketelaere avatar Marcelo Serpa avatar David Klein avatar Dan Korostelev avatar Adrian Veith avatar Jérémy Faivre avatar Jonathan Rose Dunlap avatar George Corney avatar Lars Doucet avatar  avatar

Watchers

Dan Korostelev avatar  avatar VirtualMaestro avatar  avatar Lars Doucet avatar Rudy Ges avatar  avatar

Forkers

sondro markknol

ctl's Issues

What is the purpose of inCwd() - all my files are absolutely referenced

In my project, the inCwd() function is always returning false, as all files happen to be referenced with absolute paths.

I see that inCwd is excluding absolute paths, but what is the purpose of that? To exclude other libraries? Or the Haxe std library?

I assume that it's not standard practice to reference all class paths absolutely, so this problem probably doesn't affect a lot of people...

Feature request: dead module / file detection

One aspect of a large codebases is the potential for files to simply never be included in the build in the first place. This macro doesn't pick those up, obviously, because they aren't part of the build. However, "dead module detection" is arguably as useful as "dead code detection."

Thought 1) Perhaps an easy way would be using the Compiler include macro for "all packages", maybe:

--macro include('')

But this actually doesn't work... It seems to be implying -cp . as it results in "invalid package" errors...

Thought 2) Perhaps another idea is to actually glob from all source paths in TCell.hx, and report unused modules / files from there.

Thought 3) Just mention in the README, this doesn't pick up types that are never referenced.

(all?) Interfaces get reported as unused

Simple test that shows that a (used) interface gets reported as unused:

package;

class Main {
  public static function main() {
    trace('Hey, I\'m some project!');
    var u = new SomeClass();
    u.greet();
  }
}

class SomeClass implements IUsedInterface {
  public function new() {
    trace('Hi, I\'m a used class');
  }

  public function greet() trace("Oh, hi!");
}

interface IUsedInterface {
  public function greet():Void;
}

Macro output:

Partially Dead Types:

  IUsedInterface @ src/Main.hx:19

    greet @ src/Main.hx:20

Feature request: ignore list

Thinking about how I'll use this -- and this is probably related to #1, because I had to disable inCwd to get any output at all -- but I'll want some way to ignore a set of dead classes / fields. Especially third party libraries. But perhaps not ignore the data entirely, it's just less important to me...

Perhaps, if I'm exporting to JSON, I put the "ignored" classed/fields in a sub-object, or perhaps a separate file.

I could also achieve this by post processing of the JSON output, so arguably it's beyond the scope of this macro. But, if it's something lots of people would want to do, perhaps consider it.

Or even just document in the readme how to output JSON and ignore. I'll probably do this, so minimally I could provide an example. I'll post back.

Unreported types

In trying to figure out why this isn't working for my large project, I've created a few simple tests, during which I noticed a few types that doesn't get reported. Perhaps these are arguably unimportant...

class UnreportedWithOnlyStaticVarFields {
  public static var SOMETHING = 4;
}
 
class UnreportedWithOnlyConstructorFunction {
  public function new() {
    trace('I never get called');
  }
}

The former is arguably only collections of constants / etc. The latter is arguably not important.

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.