New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

codehawk-cli

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codehawk-cli - npm Package Compare versions

Comparing version
8.3.0
to
8.3.1
+4
-4
build/analyze.js

@@ -13,3 +13,3 @@ "use strict";

if (isTypescript) {
const transformed = core_1.transformSync(contents, {
const transformed = (0, core_1.transformSync)(contents, {
plugins: [

@@ -30,3 +30,3 @@ [

contents = enableFlow
? flow_remove_types_1.default(contents, { pretty: true }).toString()
? (0, flow_remove_types_1.default)(contents, { pretty: true }).toString()
: contents;

@@ -38,3 +38,3 @@ }

const calculateComplexity = (sourceCode, fileExtension, isTypescript, enableFlow) => {
return escomplex_1.default(exports.transpileFileSource(sourceCode, fileExtension, isTypescript, enableFlow));
return (0, escomplex_1.default)((0, exports.transpileFileSource)(sourceCode, fileExtension, isTypescript, enableFlow));
};

@@ -70,3 +70,3 @@ exports.calculateComplexity = calculateComplexity;

try {
const complexityReport = escomplex_1.default(trimmed);
const complexityReport = (0, escomplex_1.default)(trimmed);
if (complexityReport) {

@@ -73,0 +73,0 @@ report = {

@@ -28,3 +28,3 @@ "use strict";

const badgesPath = badgesDirectory[0] || ''; // Fall back to root
const actualPath = slash_1.default(process.cwd()) + badgesPath;
const actualPath = (0, slash_1.default)(process.cwd()) + badgesPath;
if (badgesPath !== '' && !fs_1.default.existsSync(actualPath)) {

@@ -37,3 +37,3 @@ // Fire a specific error message, but also let the upstream generic handling kick in

try {
fs_1.default.writeFileSync(`${actualPath}/avg-maintainability.svg`, badgen_1.badgen({
fs_1.default.writeFileSync(`${actualPath}/avg-maintainability.svg`, (0, badgen_1.badgen)({
label: 'maintainability (avg)',

@@ -48,3 +48,3 @@ status: `${average.toFixed(2)}`,

try {
fs_1.default.writeFileSync(`${actualPath}/worst-maintainability.svg`, badgen_1.badgen({
fs_1.default.writeFileSync(`${actualPath}/worst-maintainability.svg`, (0, badgen_1.badgen)({
label: 'maintainability (worst)',

@@ -51,0 +51,0 @@ status: `${worst.toFixed(2)}`,

@@ -37,10 +37,10 @@ "use strict";

const utils_1 = require("./utils");
const cwd = slash_1.default(process.cwd());
const cwd = (0, slash_1.default)(process.cwd());
const analyzeProject = (rawPath, isCliContext) => {
// When using CLI, execute from the cwd rather than a relative path
const actualRoot = isCliContext ? cwd : rawPath;
const projectOptions = options_1.getConfiguration(actualRoot);
const projectOptions = (0, options_1.getConfiguration)(actualRoot);
let options = {};
try {
options = options_1.buildOptions(projectOptions);
options = (0, options_1.buildOptions)(projectOptions);
}

@@ -57,3 +57,3 @@ catch (e) {

const dirPath = path.resolve(`${actualRoot}/`);
const projectCoverage = coverage_1.getCoverage(dirPath);
const projectCoverage = (0, coverage_1.getCoverage)(dirPath);
const addComplexityToFile = (file) => {

@@ -63,3 +63,3 @@ let fileContents;

if (file.shouldAnalyze) {
fileContents = traverseProject_1.getFileContents(file.fullPath, options.enableFlow);
fileContents = (0, traverseProject_1.getFileContents)(file.fullPath, options.enableFlow);
}

@@ -72,3 +72,3 @@ }

? null
: analyze_1.analyzeFile(dirPath, {
: (0, analyze_1.analyzeFile)(dirPath, {
path: file.path,

@@ -97,3 +97,3 @@ filename: file.filename,

...file,
timesDependedOn: dependencies_1.getTimesDependedOn(projectDeps, file.fullPath),
timesDependedOn: (0, dependencies_1.getTimesDependedOn)(projectDeps, file.fullPath),
});

@@ -110,9 +110,9 @@ const addDependencyCounts = (projectDeps, entities) => entities.map((entity) => {

// First run of all files: generate complexity & coverage metrics
const entities = traverseProject_1.walkSync(dirPath, options);
const entities = (0, traverseProject_1.walkSync)(dirPath, options);
const firstRunResults = addComplexityToEntities(entities);
// Second run: generate timesDependedOn (can only be calculated after first run)
const projectDeps = dependencies_1.getProjectDeps(firstRunResults);
const projectDeps = (0, dependencies_1.getProjectDeps)(firstRunResults);
const secondRunResults = addDependencyCounts(projectDeps, firstRunResults);
const resultsAsList = utils_1.getResultsAsList(secondRunResults);
const summary = utils_1.getResultsSummary(resultsAsList);
const resultsAsList = (0, utils_1.getResultsAsList)(secondRunResults);
const summary = (0, utils_1.getResultsSummary)(resultsAsList);
// When in a CLI context, exit if the worst case fails to meet the minimum threshold

@@ -119,0 +119,0 @@ if (isCliContext && summary.worst < options.minimumThreshold) {

@@ -13,3 +13,3 @@ "use strict";

const getProjectDeps = (firstRunResults) => {
const flatItems = utils_1.flattenEntireTree(firstRunResults);
const flatItems = (0, utils_1.flattenEntireTree)(firstRunResults);
const allAbsoluteDeps = [];

@@ -39,3 +39,3 @@ for (let i = 0; i < flatItems.length; i += 1) {

// eslint-disable-next-line no-useless-escape
const cleanD = slash_1.default(d).replace(/\w\:/, '');
const cleanD = (0, slash_1.default)(d).replace(/\w\:/, '');
// Match exactly, or fall back to index (index is a reserved case in nodejs)

@@ -42,0 +42,0 @@ // Note: by design, only javascript dependencies are counted (e.g. svg imports will not count as a TDO)

@@ -15,5 +15,5 @@ #!/usr/bin/env node

if (scanDir && scanDir !== '') {
const output = codehawk_1.analyzeProject(`${process.cwd()}/${scanDir}`, true);
const output = (0, codehawk_1.analyzeProject)(`${process.cwd()}/${scanDir}`, true);
const formattedAsTable = output.resultsList.slice(0, output.options.cliOutputLimit);
console.log(cli_util_1.formatResultsAsTable(formattedAsTable));
console.log((0, cli_util_1.formatResultsAsTable)(formattedAsTable));
if (!createBadge) {

@@ -24,3 +24,3 @@ return;

console.log('[codehawk-cli] Generating maintainability badge...');
codehawk_1.generateBadge(output);
(0, codehawk_1.generateBadge)(output);
console.log('[codehawk-cli] Badge was generated');

@@ -36,4 +36,4 @@ }

};
const rawArgs = helpers_1.hideBin(process.argv);
const argv = yargs_1.default(rawArgs)
const rawArgs = (0, helpers_1.hideBin)(process.argv);
const argv = (0, yargs_1.default)(rawArgs)
.demandCommand(1, 'Please provide a directory argument')

@@ -40,0 +40,0 @@ .describe('no-badge', 'Exclude generated badges')

@@ -111,7 +111,7 @@ "use strict";

try {
if (fs_1.existsSync(path_1.resolve(`${rootDirectory}/codehawk.json`))) {
const configContents = fs_1.readFileSync(path_1.resolve(`${rootDirectory}/codehawk.json`), 'utf8');
if ((0, fs_1.existsSync)((0, path_1.resolve)(`${rootDirectory}/codehawk.json`))) {
const configContents = (0, fs_1.readFileSync)((0, path_1.resolve)(`${rootDirectory}/codehawk.json`), 'utf8');
return JSON.parse(configContents);
}
const packageConfig = fs_1.readFileSync(path_1.resolve(`${rootDirectory}/package.json`), 'utf-8');
const packageConfig = (0, fs_1.readFileSync)((0, path_1.resolve)(`${rootDirectory}/package.json`), 'utf-8');
const parsedPackageConfig = JSON.parse(packageConfig);

@@ -118,0 +118,0 @@ if ('codehawk' in parsedPackageConfig) {

@@ -38,6 +38,6 @@ "use strict";

fullPath: path.join(dir, filename),
entity: utils_1.getFsEntity(path.join(dir, filename)),
relativeDir: slash_1.default(dir).replace(slash_1.default(process.cwd()), ''),
entity: (0, utils_1.getFsEntity)(path.join(dir, filename)),
relativeDir: (0, slash_1.default)(dir).replace((0, slash_1.default)(process.cwd()), ''),
}));
const visibleEntities = parsedEntities.filter((item) => utils_1.shouldSeeEntity({
const visibleEntities = parsedEntities.filter((item) => (0, utils_1.shouldSeeEntity)({
filename: item.filename,

@@ -53,5 +53,5 @@ dir,

const baseParsedEntity = {
fullPath: slash_1.default(item.fullPath),
fullPath: (0, slash_1.default)(item.fullPath),
filename,
shouldAnalyze: utils_1.shouldAnalyzeEntity({
shouldAnalyze: (0, utils_1.shouldAnalyzeEntity)({
entity,

@@ -68,3 +68,3 @@ filename,

type: 'dir',
files: exports.walkSync(fullPath, options),
files: (0, exports.walkSync)(fullPath, options),
});

@@ -75,3 +75,3 @@ }

...baseParsedEntity,
path: slash_1.default(dir),
path: (0, slash_1.default)(dir),
type: 'file',

@@ -99,4 +99,4 @@ });

const isTypescript = extension === '.ts' || extension === '.tsx';
return analyze_1.transpileFileSource(contents, extension, isTypescript, enableFlow);
return (0, analyze_1.transpileFileSource)(contents, extension, isTypescript, enableFlow);
};
exports.getFileContents = getFileContents;

@@ -41,4 +41,4 @@ "use strict";

const isDotEntity = (fullPath) => {
const dotDir = is_dotdir_1.default(fullPath) || is_dotdir_1.default(slash_1.default(fullPath));
const dotFile = is_dotfile_1.default(fullPath) || is_dotfile_1.default(slash_1.default(fullPath));
const dotDir = (0, is_dotdir_1.default)(fullPath) || (0, is_dotdir_1.default)((0, slash_1.default)(fullPath));
const dotFile = (0, is_dotfile_1.default)(fullPath) || (0, is_dotfile_1.default)((0, slash_1.default)(fullPath));
return dotDir || dotFile;

@@ -103,3 +103,3 @@ };

// Is the path/filename excluded by user options?
if (blocklist_1.isBlocklisted(relativeDir, filename, options)) {
if ((0, blocklist_1.isBlocklisted)(relativeDir, filename, options)) {
return false;

@@ -106,0 +106,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

if (item.type === 'dir') {
flattened = flattened.concat(exports.flattenEntireTree(item.files));
flattened = flattened.concat((0, exports.flattenEntireTree)(item.files));
}

@@ -19,3 +19,3 @@ else {

const getResultsAsList = (analyzedEntities, limit) => {
const flatFileResults = exports.flattenEntireTree(analyzedEntities)
const flatFileResults = (0, exports.flattenEntireTree)(analyzedEntities)
.filter((entity) => {

@@ -22,0 +22,0 @@ return entity.type === 'file' && !!entity.complexityReport;

{
"name": "codehawk-cli",
"version": "8.3.0",
"version": "8.3.1",
"description": "Static analysis tool for JavaScript projects",

@@ -47,3 +47,3 @@ "scripts": {

"@types/is-dotfile": "^2.0.0",
"@types/jest": "^26.0.19",
"@types/jest": "^27.0.2",
"@types/node": "^14.0.11",

@@ -61,6 +61,6 @@ "@types/yargs": "^15.0.12",

"eslint-plugin-standard": "4",
"jest": "^26.6.3",
"np": "^7.2.0",
"jest": "^27.2.4",
"np": "^7.5.0",
"prettier": "^2.0.5",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.5",
"typescript": "^4.1.3"

@@ -67,0 +67,0 @@ },