danielstjules / buddy.js Goto Github PK
View Code? Open in Web Editor NEWMagic number detection for JavaScript
License: MIT License
Magic number detection for JavaScript
License: MIT License
Hello!
For myself, I've created gulp plugin. Perhaps it may be necessary to someone else.
It would be great if you added my plugin to README as grunt plugin.
This is great! Would it be possible to add a plugin for grunt to execute this at build time?
If you make a file with the following contents:
console.log(0x1A + 0x02);
console.log(071);
The output from Buddy is rather interesting:
$ buddy .
./test.js:1 | console.log(26 + 0x02);
./test.js:1 | console.log(0x1A + 2);
./test.js:2 | console.log(57);
3 magic numbers found across 1 file
Notice how the hex/octal numbers are converted to decimal before being logged.
I added a local version of jQuery to my a repo, and now Buddy is failing with over 60 magic numbers found.
Is there any way to ignore a path?
Or can --ignorePath be added as a cli option?
Thank you!
Node allows executable scripts to use the unix shebang (#!/usr/bin/env node
) convention. It seems buddy.js chokes on this, which is probably an issue with the upstream parser or the configuration thereof:
{ [SyntaxError: Unexpected character '#' (1:0)] pos: 0, loc: { line: 1, column: 0 }, raisedAt: 0 }
Hi Daniel,
unfortunately buddy
binary returns wrong version number if called with:
$ ./bin/buddy --version
0.0.1
Although dependencies
are declared the following:
"buddy.js": "^0.2.1"
and the downloaded version contains 0.2.1
in it's own package.json
.
Maybe this issue is already fixed in newer versions.
With kind regards
Marco
I have a case where I am converting seconds to ms. e.g.
var MS = SECONDS * 1000;
Currently, I'd have to rewrite 1000 as a const or ignore it everywhere. Instead, I'd like to be able to ignore that line with a comment.
Thanks for this useful and cool package. For my project, typescript support would greatly improve impact. Is this a feature that might be implemented?
how to add class,interface and enum in leadbolt codes
Seems like these should be allowed to pass.
breakpoint.SMALL_MAX = 640;
breakpoint.MED_MAX = 959;
breakpoint.LARGE_MAX = 1204;
Buddy.js report negative number even though they are stored in const
:
src/attachmentMappers/retailMappers.js:3 | const EMPTY_INDEX_OF = -1;
1 magic number found across 34 files
v0.9
Hi Daniel,
I'm using buddy.js
in version 0.7.0
:
./node_modules/buddy.js/bin/buddy --version
My source snippet is:
return b = Math.random() * 16, (a === 'y' ? (b & 3 | 8) : (b | 0)).toString(16); // buddy ignore: line
Calling buddy.js
returns warnings:
./snippet.js:1 | return b = Math.random() * 16, (a === 'y' ? (b & 3 | 8) : (b | 0)).toString(16); // buddy ignore: line
./snippet.js:1 | return b = Math.random() * 16, (a === 'y' ? (b & 3 | 8) : (b | 0)).toString(16); // buddy ignore: line
./snippet.js:1 | return b = Math.random() * 16, (a === 'y' ? (b & 3 | 8) : (b | 0)).toString(16); // buddy ignore: line
./snippet.js:1 | return b = Math.random() * 16, (a === 'y' ? (b & 3 | 8) : (b | 0)).toString(16); // buddy ignore: line
4 magic numbers found across 6 files
Did I miss something?
With kind regards
Marco
Hey!
The latest version of this project on GitHub is 0.9.0, but the latest version on npm is 0.8.0. Would you be able to publish it, please? Thanks!
I've been having an issue with buddyjs recently where in my grunt task it will error out saying something along the lines of:
Running "buddyjs:src" (buddyjs) task
[TypeError: Object
## CONTENTS OF ONE OF MY JS FILES ##
has no method 'split']
Warning: Task "buddyjs:src" failed. Use --force to continue.
Aborted due to warnings.
Now this seems to be because its expecting a large string to split on newlines, however it's an object.
Line of code that assumes this:
Line 152 in 8558a9d
The method expects contents to be a string, where in this case it seems to be the raw buffer and not a string, causing the split on newlines to fail.
Much like one can use ls .
or ls
, it would be cool if buddy would default to the current working directory when an argument isn't provided.
NOTE: I know nodeJS v0.11.x does not have a stable release yet, so it is not really that important I guess?
With ECMAScript 6, support for generators is added. Currently, this requires one to use the --harmony
flag to run node scripts that make use of generators. There is an issue with buddy.js, because these functions are indicated by asterisk notation.
function* foo(x) {
yield x + 1;
var y = yield null;
return x + y;
}
The issue is that buddy.js notices an unexpected token (the *) and shuts down by this error.
Consider the following file:
var x = {
statusCode: 200,
y: function() {
z = 100;
}
};
Buddy doesn't report the 200 as being a magic number. Though it will report the 100.
Location of the broken image is README.md
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.