New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

smelly-cli

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smelly-cli - npm Package Compare versions

Comparing version 0.0.11 to 0.0.13

46

build/src/find-smells.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -30,5 +7,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const path_1 = __importDefault(require("path"));
const promises_1 = __importStar(require("node:fs/promises"));
const promises_1 = __importDefault(require("node:fs/promises"));
const glob_1 = require("glob");
const node_path_1 = require("node:path");
const smelly_detector_1 = require("smelly-detector");

@@ -46,6 +22,2 @@ const reports_1 = require("smelly-detector/reports");

}
const walk = async (dirPath) => Promise.all(await (0, promises_1.readdir)(dirPath, { withFileTypes: true }).then((entries) => entries.map((entry) => {
const childPath = (0, node_path_1.join)(dirPath, entry.name);
return entry.isDirectory() ? walk(childPath) : childPath;
})));
function isDirectorySync(path) {

@@ -70,10 +42,12 @@ try {

const aggregator = [];
const testCases = [];
for (const file of pathWithAllFilesFound) {
const fileContents = await promises_1.default.readFile(file, { encoding: 'utf8' });
const smellDetector = new smelly_detector_1.SmellDetector(fileContents, language);
const smells = smellDetector.findAll().smells;
aggregator.push({ fileName: file, smells, language });
const fileContent = await promises_1.default.readFile(file, { encoding: 'utf8' });
const smellDetector = new smelly_detector_1.SmellDetector(file, fileContent, language);
const smells = smellDetector.findAll();
aggregator.push(smells.smellsList);
testCases.push(...smells.testCases);
}
const to = path_1.default.resolve(reportOutput.replace('--report-output=', ''));
const report = new reports_1.SmellsAggreagtor(aggregator, { to });
const report = new reports_1.SmellsAggreagtor(testCases, aggregator, { to });
await report.build();

@@ -86,4 +60,4 @@ console.info('Report HTML generated');

const fileContents = await promises_1.default.readFile(file, { encoding: 'utf8' });
const smellDetector = new smelly_detector_1.SmellDetector(fileContents, language);
const result = smellDetector.findAll().smells;
const smellDetector = new smelly_detector_1.SmellDetector(file, fileContents, language);
const result = smellDetector.findAll().smellsList.smells;
if (result.length) {

@@ -90,0 +64,0 @@ result.forEach((e) => {

{
"name": "smelly-cli",
"version": "0.0.11",
"version": "0.0.13",
"private": false,

@@ -18,3 +18,3 @@ "description": "Find out the smells in your tests, suggestions for correction and the theory behind them",

"@types/mocha": "^10.0.8",
"@types/node": "^20.14.8",
"@types/node": "*",
"@types/sinon": "^17.0.3",

@@ -21,0 +21,0 @@ "@typescript-eslint/eslint-plugin": "^5.53.0",

import path from 'path';
import fs, { readdir } from 'node:fs/promises';
import { glob, globSync, globStream, globStreamSync, Glob } from 'glob';
import { join } from 'node:path';
import { Smell, SmellDetector, SupportedLanguages } from 'smelly-detector';
import fs from 'node:fs/promises';
import { glob } from 'glob';
import { Smell, SmellDetector, SupportedLanguages, TestCase } from 'smelly-detector';
import { SmellsAggreagtor, SmellsList } from 'smelly-detector/reports';

@@ -20,9 +19,2 @@ import { statSync } from 'fs';

const walk: any = async (dirPath: string) => Promise.all(
await readdir(dirPath, { withFileTypes: true }).then((entries: any) => entries.map((entry: any) => {
const childPath = join(dirPath, entry.name);
return entry.isDirectory() ? walk(childPath) : childPath;
}))
);
function isDirectorySync(path: string): boolean {

@@ -49,12 +41,14 @@ try {

const aggregator: SmellsList[] = [];
const testCases: TestCase[] = [];
for (const file of pathWithAllFilesFound) {
const fileContents = await fs.readFile(file, { encoding: 'utf8' });
const smellDetector = new SmellDetector(fileContents, language);
const smells = smellDetector.findAll().smells;
aggregator.push({ fileName: file, smells, language });
const fileContent = await fs.readFile(file, { encoding: 'utf8' });
const smellDetector = new SmellDetector(file, fileContent, language);
const smells = smellDetector.findAll();
aggregator.push(smells.smellsList);
testCases.push(...smells.testCases);
}
const to = path.resolve(reportOutput.replace('--report-output=', ''));
const report = new SmellsAggreagtor(aggregator, { to });
const report = new SmellsAggreagtor(testCases, aggregator, { to });
await report.build();

@@ -69,4 +63,4 @@

const fileContents = await fs.readFile(file, { encoding: 'utf8' });
const smellDetector = new SmellDetector(fileContents, language);
const result = smellDetector.findAll().smells;
const smellDetector = new SmellDetector(file, fileContents, language);
const result = smellDetector.findAll().smellsList.smells;

@@ -73,0 +67,0 @@ if (result.length) {

@@ -5,2 +5,3 @@ import { test, describe, expect, beforeEach, afterEach } from 'vitest';

import { rmSync } from 'fs';
import * as path from 'path';

@@ -12,3 +13,3 @@ const execPromise = promisify(exec);

describe('html report', () => {
const filePath = `./smelly-report.html`;
const filePath = path.resolve(__dirname, 'smelly-report.html');

@@ -15,0 +16,0 @@ beforeEach(() => {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc