Code Monkey home page Code Monkey logo

szero's People

Contributors

danbev avatar evanshortiss avatar felipewmartins avatar helio-frota avatar lance avatar lholmquist avatar tiagofabre avatar vitaly-t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

szero's Issues

Code review

Goals:

  • Make changes on the code to be more close to ES6.
  • Better code.

Weird behavior when using npm run

working:

[hf@archT440 genet]$ szero . --ci=true
----------------------------------------------------------------------
[ Declaration and file lines ]
----------------------------------------------------------------------
Fidelity-require('fidelity'):
./index.js:9
./index.js:55
./index.js:68
./lib/console_reporter.js:3
./lib/console_reporter.js:18
./lib/file_reporter.js:4
./lib/file_reporter.js:19
./lib/flamegraph_reporter.js:4
./lib/flamegraph_reporter.js:10
processor-require('huilu/lib/cpuprofile-processor'):
./index.js:8
./index.js:122
profiler-require('v8-profiler'):
./index.js:6
./index.js:7
./index.js:40
./index.js:56
./index.js:65
huilu-require('huilu/from-stream'):
./lib/flamegraph_reporter.js:5
./lib/flamegraph_reporter.js:11
Table-require('cli-table2'):
./lib/table.js:3
./lib/table.js:5
./lib/table.js:6
./lib/table.js:54
----------------------------------------------------------------------
[ Declaration and amount ]
----------------------------------------------------------------------
Fidelity-require('fidelity') --> [ 9 ]
processor-require('huilu/lib/cpuprofile-processor') --> [ 2 ]
profiler-require('v8-profiler') --> [ 5 ]
huilu-require('huilu/from-stream') --> [ 2 ]
Table-require('cli-table2') --> [ 4 ]
----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
None.

not working:

[hf@archT440 genet]$ npm run dependencyCheck

> [email protected] dependencyCheck /mnt/datadisk/genet
> szero . --ci=true

----------------------------------------------------------------------
[ Declaration and file lines ]
----------------------------------------------------------------------
Fidelity-require('fidelity'):
./index.js:9
./index.js:55
./index.js:68
./lib/console_reporter.js:3
./lib/console_reporter.js:18
./lib/file_reporter.js:4
./lib/file_reporter.js:19
./lib/flamegraph_reporter.js:4
./lib/flamegraph_reporter.js:10
processor-require('huilu/lib/cpuprofile-processor'):
./index.js:8
./index.js:122
profiler-require('v8-profiler'):
./index.js:6
./index.js:7
./index.js:40
./index.js:56
./index.js:65
huilu-require('huilu/from-stream'):
./lib/flamegraph_reporter.js:5
./lib/flamegraph_reporter.js:11
Table-require('cli-table2'):
./lib/table.js:3
./lib/table.js:5
./lib/table.js:6
./lib/table.js:54
----------------------------------------------------------------------
[ Declaration and amount ]
----------------------------------------------------------------------
Fidelity-require('fidelity') --> [ 9 ]
processor-require('huilu/lib/cpuprofile-processor') --> [ 2 ]
profiler-require('v8-profiler') --> [ 5 ]
huilu-require('huilu/from-stream') --> [ 2 ]
Table-require('cli-table2') --> [ 4 ]
----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
None.

npm ERR! Linux 4.7.1-1-ARCH
npm ERR! argv "/home/hf/.nvm/versions/node/v4.5.0/bin/node" "/home/hf/.nvm/versions/node/v4.5.0/bin/npm" "run" "dependencyCheck"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dependencyCheck: `szero . --ci=true`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dependencyCheck script 'szero . --ci=true'.
npm ERR! This is most likely a problem with the genet package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     szero . --ci=true
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs genet
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls genet
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/datadisk/genet/npm-debug.log

File report bug

[ Declaration and file lines ]
undefined:
./from-stream.js:5
./from-stream.js:5
./from-stream.js:41
./from-stream.js:4
./from-stream.js:4
./from-stream.js:29
./index.js:6
./index.js:6
./index.js:25
./index.js:49
./index.js:51
./index.js:55
./index.js:49
./index.js:7
./index.js:9
./index.js:10
./index.js:25
./index.js:44
./index.js:49
./index.js:51
./index.js:53
./index.js:60
./index.js:61
./lib/contextify.js:3
./lib/contextify.js:3
./lib/contextify.js:147
./lib/contextify.js:147
./lib/contextify.js:151
./lib/contextify.js:152
./lib/svg-template.js:3
./lib/svg-template.js:3
./lib/svg-template.js:6
./lib/svg-template.js:8
./lib/svg.js:3
./lib/svg.js:3
./lib/svg.js:31
./lib/svg.js:31
./lib/svg.js:6
./lib/svg.js:8
./lib/svg.js:17
./lib/svg.js:27
./lib/svg.js:30
./lib/svg.js:31
./lib/svg.js:32
./lib/svg.js:33

[ Declaration and amount ]
undefined --> [45]

[ Unused dependencies ]

License GET can run twice

It looks like there is the possibility that the license report can be run twice when using the API.

https://github.com/bucharest-gold/szero/blob/master/bin/cli.js#L61 that block of code will run if the consoleReporter is true and the license flag is true. We should probably just return after doing the console/filereporter.

It might make sense to break this out, so this one run function isn't doing everything, lets focus on that for another release.

license info optional

related to #42 , i wonder if showing the license info should be behind a flag? We are doing a GET for each of the dependencies, so for a project with lots of dependencies, it could take a while.

@helio-frota @jaredsmith @lance thoughts?

I'll create this as another issue, but we should also have the ability to output that license info in the public API(maybe also behind a flag).

Promise rejection handler warning

While running in Node 7, There is a test that produces the

(node:80749) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): package.json is require

(node:80749) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

we should probably fix that. Not sure if it is the test or the lib that is the issue

bug unused dependencies console report

----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
concat-stream,concat-stream,concat-stream,concat-stream,
concat-stream,concat-stream,concat-stream,concat-stream,
concat-stream,concat-stream,concat-stream,concat-stream,
concat-stream,concat-stream,concat-stream,concat-stream,
concat-stream,concat-stream,concat-stream,concat-stream,
concat-stream,concat-stream,
....
....

Add a silent option

Sometimes we need to focus only the "break CI feature" in case unused dependencies found, instead see the information about amount of use etc.

Something like:

szero . --ci --silent

Minor bug on report

    ----------------------------------------------------------------------
    [ Declaration and file lines ]
    ----------------------------------------------------------------------
    require('roi'):
    x.js:4
    roi:
    x.js:4
    x.js:7
    ----------------------------------------------------------------------
    [ Declaration and amount ]
    ----------------------------------------------------------------------
    require('roi') --> [ 1 ]
    roi --> [ 2 ]
    undefined <-------------------------------------------------------------------------

Ignore directories

Description

There is some directories we don't need to track when using szero, an example of that is to run szero inside a project that has bower dependencies.

require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/affix.js')

This code is from bootstrap dependency using bower and that syntax is equal node modules, but most of the time we don't want to track bower modules.

Steps to reproduce

  • Execute szero in a project that has bower dependencies

Expected behavior

  • The expected is to have any parameter to pass directories that will be ignored. This way we can prevent to check code we don't need just like bower or other future directories

Actual behavior

Actually the output of szero inside projects with bower returns:

bower_components/bootstrap/dist/js/)
bower_components/bootstrap/fs
bower_components/bootstrap/grunt
bower_components/bootstrap/grunt/bs-commonjs-generator.js
bower_components/bootstrap/grunt/bs-glyphicons-data-generator.js
bower_components/bootstrap/grunt/bs-lessdoc-parser.js
bower_components/bootstrap/grunt/bs-raw-files-generator.js
bower_components/bootstrap/grunt/btoa
bower_components/bootstrap/grunt/fs
bower_components/bootstrap/grunt/glob
bower_components/bootstrap/grunt/markdown-it
bower_components/bootstrap/grunt/path
bower_components/bootstrap/grunt/shelljs
bower_components/bootstrap/js/)
bower_components/bootstrap/js/affix.js
bower_components/bootstrap/js/alert.js
bower_components/bootstrap/js/button.js
bower_components/bootstrap/js/carousel.js
bower_components/bootstrap/js/collapse.js
bower_components/bootstrap/js/dropdown.js
bower_components/bootstrap/js/modal.js
bower_components/bootstrap/js/popover.js
bower_components/bootstrap/js/scrollspy.js
bower_components/bootstrap/js/tab.js
bower_components/bootstrap/js/tooltip.js
bower_components/bootstrap/js/transition.js
bower_components/bootstrap/load-grunt-tasks
socket.io
socket.io-redis
...

flag for which reporters to use

I believe currently when the command is run, both reporters(console and file) are run.

I think this should change a little bit, since this will affect #16 . Here is my suggestion.

When run from the command line, it should default to just do console output and if some flag is provided, maybe like --reporter=file or something like that, then it will also do the file reporter.

When calling the api directly, console and file reporters are not run(i'll create a future issue about also returning a file in the api) and just the JSON object is returned.

@helio-frota any strong objections or agreements :)

Output license info through the API

Now that #42 is in there, we should add the ability for this information to be accessible in the programmatic API.

possibly behind a flag, so the user needs to opt-in

unused dependencies showing 'object'

----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
[object Object],[object Object]

Problem with same require but different usage

require('../index.js')
require('../index')

This is the same file, but since node do a cache, we need to keep only one.
Suggestion to keep require('../index.js') or what is with the nearest path.

szero is using a Set so if we do a require('foo') inside A.js
When szero found another require('foo') inside B.js it will be discarded automatically due Set.
So we need also to solve the issue with relative path like:

require('../index.js')
require('../../index')
require('../../../index')
require('../../../../index.js')

Because the Set will will treat this as different elements.

Count only require()

Today szero mix require and usage.
It would be good to know only the unique require('something').
As a new section on output report.

Consider adding license information

Would you please consider adding licensing information about each dependency, so that it's easy to scan a program and tell which licenses are getting pulled in by each dependency?

Show something when zero unused dependencies

actual :

----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------

should be something:

----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
none.
` ``

or not show this section ^

api for Programmatic use

We need to create an entry point, like index.js, that exports the api so someone could use it in code

Ignore commented requires

szero is tracking commented requires but it is not something expected since that modules are not being loaded from node and it is not using resources.

My test to check if a commented module is being tracked was to comment a require and checked if it is in the output of szero.

const indexOnRootDirectoryRequiredFromC = require('../index.js');
const indexOnRootDirectoryRequiredFromD = require('./d/index.js');
// const indexOnRootDirectoryRequiredFromD = require('../a/commentedModule.js');
/* const indexOnRootDirectoryRequiredFromE = require('../a/commentedModule1.js'); */

and my output was

require('../index.js'),
require('./d/index.js'),
require('../a/commentedModule.js')
require('../a/commentedModule1.js')

Output file format from API

We should probably add a new method that returns the formatted string that eventually can be turned into a file

edited: i changed the the return type from buffer/stream, to just the formatted string. This allows the user to write it to the file however they want to

Filename should be configurable

possible add a flag on the command line to allow for different naming of the szero.txt file that gets output using the fileReporter

Improve declaration handling

example:

require('concat-stream') --> [ 1 ]
concatStream --> [ 2 ]
require('through2') --> [ 1 ]
through --> [ 2 ]

Since the variable name is not the same as required dependency , the report shows this for unused dependencies:

----------------------------------------------------------------------
[ Unused dependencies ]
----------------------------------------------------------------------
concat-stream,through2

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.