Skip to content

Basic setup

Silvio Montanari edited this page Jan 2, 2017 · 12 revisions

1. Install code-forensics and its dependencies

code-forensics is installed as a npm package, and can be run through gulp, another Node.js module.

It is strongly advised to install code-forensics as a local module, to avoid dependencies conflicts with other global packages that could lead to other issues.

$ npm install code-forensics

Alternatively you can create your own Node.js project with npm init and then run npm install -S code-forensics Ultimately you should end up with a package.json similar to this:

{
  "name": "my-awesome-project",
  "dependencies": {
    "code-forensics": "^0.11.0"
  }
}

2. Create a gulpfile.js

A gulpfile.js is the entry point for any task you want to run in gulp, and it's also the place where you can configure code-forensics.

The main module of code-forensics exports a configure function that is used to setup everything necessary to execute any code analysis. This function takes two arguments: a configuration object and a parameters object:

require('code-forensics').configure(
  {
    // configuration options
  },
  {
    // default parameters values
  }
);

The minimal information required by code-forensics is the location of the root of the repository you want to inspect and analyse the code from:

require('code-forensics').configure(
  {
    repository: {
      rootPath: "<path-to-the-repo>"
    }
  }
);

Configuration and Task parameters describe in details all available configuration options or parameters.