Skip to content

Commit

Permalink
feat: Add plato to analyse the code complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincaradant committed Feb 29, 2016
1 parent 44e9b53 commit 4177b26
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/*
docs/*
coverage/*
.publish/*
complexity_report/*

# files
*.zip
Expand Down
2 changes: 2 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let gulp = require('gulp'),
$.notifier = require('node-notifier');
$.conventionalGithubReleaser = require('conventional-github-releaser');
$.critical = require('critical').stream;
$.plato = require('plato');

process.env.NODE_ENV = $.argv.production ? 'production' : 'development';
process.env.PORT = $.argv.PORT ? $.argv.PORT : '8080';
Expand Down Expand Up @@ -47,6 +48,7 @@ function runTask(task) {
}

let tasks = [
'plato',
'sass',
'build-zip',
'clean-zip',
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Note: To view the app please open a new tab and go to `http://localhost:8080/`.
- `$ gulp build`: Create distribution package for the development and production environment
- `$ gulp serve`: Start web-server and live-reload.
- `$ gulp tests`: execute unit tests with Karma
- `$ gulp plato`: build a static analysis and complexity report
- `$ gulp xo`: Linter to scan src js files
- `$ gulp release`: Automate release workflow
- `$ gulp release --patch`: Automate release workflow for a patch release (ex: v.0.0.1)
Expand Down
5 changes: 3 additions & 2 deletions gulp-tasks/clean-js.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

module.exports = (gulp, $) => {
return () => {
return (cb) => {
if($.env.isProd){
return $.del(['build/js']);
}else{
return $.del(['nothing']);
cb();
}
}
}

17 changes: 17 additions & 0 deletions gulp-tasks/plato.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

module.exports = (gulp, $) => {
return (cb) => {
let files = [
'build/**/*.js',
];

let outputDir = 'complexity_report';

let options = {
title: 'Report'
};

return $.plato.inspect(files, outputDir, options, cb());
}
}
10 changes: 9 additions & 1 deletion gulp-tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ module.exports = (gulp, $) => {
.pipe($.if($.env.isProd, $.size({title: 'Annotate and StripDebug NodeModules Libs JS'})))
.pipe($.if($.env.isDev, $.size({title: 'Annotate NodeModules Libs JS'})))
.pipe($.if($.env.isDev, gulp.dest('build/libs')))
,
,

gulp.src(allLibsJsApp, {base: '.'})
.pipe($.plumber())
.pipe($.ngAnnotate())
.pipe($.babel())
.pipe($.if($.env.isProd,$.complexity({
breakOnErrors: false,
errorsOnly: false,
cyclomatic: [5],
halstead: [15],
maintainability: 100,
hideComplexFunctions: true,
})))
.pipe($.if($.env.isProd, $.stripDebug()))
.pipe($.if($.env.isProd, $.size({title: 'Annotate, Babel and StripDebug App Libs JS'})))
.pipe($.if($.env.idDev, $.size({title: 'Annotate, Babel App Libs JS'})))
Expand Down

0 comments on commit 4177b26

Please sign in to comment.