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

@zohodesk/codestandard-analytics

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zohodesk/codestandard-analytics - npm Package Compare versions

Comparing version 0.0.1-exp-13 to 0.0.1-exp-14

16

build/core/eslint/filterReports.js

@@ -34,5 +34,18 @@ "use strict";

// To set pipeline status
message["severity"] == 2 ? global.analytics.reportStatus = false : null;
if (message["severity"] == 2) {
global.analytics.reportStatus = false;
global.analytics.pipelineStatus = "failed";
}
return true;
}
// const eslintErrorLineNumber = message.line
// const { _changedLinesStartArray, _changedLinesEndArray} = impactedLines
// for(var lineNumber in _changedLinesStartArray){
// if(eslintErrorLineNumber >= _changedLinesStartArray[lineNumber] &&
// eslintErrorLineNumber <= _changedLinesEndArray[lineNumber]){
// // To set pipeline status
// message["severity"] == 2 ? (global.analytics.reportStatus = false) : null;
// return true;
// }
// }
return false;

@@ -72,4 +85,5 @@ });

*/
function filterNotDefinedRule(message, regex) {
return regex.test(message);
}

@@ -22,2 +22,3 @@ "use strict";

var _fs = require("fs");
var _cliArgsToObject = require("../../utils/cliArgsToObject");
/**

@@ -67,2 +68,8 @@ * @function getFilesFromBranchDiff - filter file path From git diff json

}
/**
* @function {getStagedFiles_preCommit} - methods get staged files
* @returns {Array<String>}
*/
function getStagedFiles_preCommit() {

@@ -112,6 +119,15 @@ const command = "git diff --cached -U0 HEAD --name-only";

*/
function getFiles(env, dir, branchDiffPath = false) {
if (env == 'dev') {
const listOfFiles = dir && (0, _fileUtils.checkIfFileExists)(dir) ? dir : false;
return (0, _fileUtils.getFilesPathFromRootDir)(listOfFiles, []);
const multipleFiles = dir.split(',');
const filesAfterFilter = multipleFiles.map(_dir => {
const listOfFiles = (0, _fileUtils.checkIfFileExists)(_dir) ? _dir : false;
if (!listOfFiles && typeof listOfFiles === 'boolean') {
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Given file or directory does not exist ...`);
process.exit(0);
}
return (0, _fileUtils.getFilesPathFromRootDir)(listOfFiles, []);
});
return (0, _cliArgsToObject.mergeArrayObjects)(filesAfterFilter);
}

@@ -130,2 +146,8 @@ if (env == 'ci') {

}
/**
* @function {constructConfigPath} - construct path of configuration file
* @returns {string}
*/
function constructConfigPath() {

@@ -159,2 +181,8 @@ return _path.default.resolve(process.cwd(), "lint.config.js");

}
/**
* @function {removeDiffFile} - this methods remove diff json file
* @returns {void}
*/
function removeDiffFile() {

@@ -165,2 +193,18 @@ const {

(0, _fs.unlinkSync)(branchDiffPath);
}
/**
* @function {filterExemptionFiles} - method filter exemption need files
* @param {Array>String>} exemptionFiles - exemption needed files
* @param {Array>String>} actualFiles - actualFiles from git diff
* @returns {Array>String>}
*/
function filterExemptionFiles(exemptionFiles, actualFiles) {
return actualFiles.filter(file => {
if (exemptionFiles.includes(file)) {
return false;
}
return true;
});
}

@@ -6,2 +6,3 @@ "use strict";

});
exports.getModifiedLine_PreCommit = getModifiedLine_PreCommit;
exports.getModifiedLines = getModifiedLines;

@@ -83,2 +84,21 @@ const {

};
}
function getModifiedLine_PreCommit(git_diff) {
const changedLinesArray = git_diff.split('\n').filter(line => line.startsWith('@@'));
let changedLinesStartArray = [];
let changedLinesEndArray = [];
for (var number of changedLinesArray) {
let changesStartLine = parseInt(number.split(' ')[2].split(',')[0]);
changedLinesStartArray.push(changesStartLine);
let changesEndLine = number.split(' ')[2].split(',')[1];
if (changesEndLine === undefined) {
changedLinesEndArray.push(changesStartLine);
} else {
changedLinesEndArray.push(changesStartLine + parseInt(changesEndLine) - 1);
}
}
return {
_changedLinesStartArray: changedLinesStartArray,
_changedLinesEndArray: changedLinesEndArray
};
}

51

build/index.js

@@ -1,27 +0,26 @@

"use strict";
/**
* @module Lint and Analytics
*/
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "EsLint", {
enumerable: true,
get: function () {
return _Eslint.default;
}
});
Object.defineProperty(exports, "Execution", {
enumerable: true,
get: function () {
return _Execution.default;
}
});
Object.defineProperty(exports, "SonarQube", {
enumerable: true,
get: function () {
return _SonarQube.default;
}
});
var _Execution = _interopRequireDefault(require("./core/handlers/libraryInterface/Execution"));
var _Eslint = _interopRequireDefault(require("./core/handlers/libraryInterface/Eslint"));
var _SonarQube = _interopRequireDefault(require("./core/handlers/libraryInterface/SonarQube"));
// import Execution from "./core/handlers/libraryInterface/Execution";
// import EsLint from "./core/handlers/libraryInterface/Eslint";
// import SonarQube from "./core/handlers/libraryInterface/SonarQube";
// /**
// * Execution handler.
// * @type {Execution}
// */
// export { Execution };
// /**
// * EsLint handler.
// * @type {EsLint}
// */
// export { EsLint };
// /**
// * SonarQube handler.
// * @type {SonarQube}
// */
// export { SonarQube };
"use strict";

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

case "lint-ci":
case "check-local":
case "local":
{

@@ -54,2 +54,15 @@ (0, _fileUtils.checkConfigurationFileExist)();

}
// case "check-local":{
// checkConfigurationFileExist();
// createBranchDiff();
// const $cliObjects = cliArgsToObject(option);
// $cliObjects.cmdExecuted = action;
// const execute = new Execution(EsLint, SonarQube, $cliObjects);
// await execute.executeLintHandler().finally(() => {
// execute.executeMetricHandler();
// });
// break;
// }
case "init":

@@ -56,0 +69,0 @@ {

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

_logger.Logger.log(_logger.Logger.INFO_TYPE, `Usage: npx ZDLintingFramework [command] [options]`);
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Commands:\n' + ' lint Lint directory and files locally.\n' + ' lint-ci Lint files in CI with optional SonarQube integration.\n' + ' check-locally Lint files locally with optional SonarQube integration.\n' + ' init Initialize configuration file.\n' + ' help Display list of supported commands.');
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Commands:\n' + ' lint Lint directory and files locally.\n' + ' lint-ci Lint files in CI with optional SonarQube integration.\n' + ' init Initialize configuration file.\n' + ' help Display list of supported commands.');
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Options:\n' + ' --dir <path> Specify directory or file to lint (Usage: npx ZDLintingFramework lint --dir=path/to/file)\n' + ' -h, --help display help for command');
}

@@ -27,4 +27,5 @@ const path = require("path");

gitEndPoint:"https://zgit.csez.zohocorpin.com",
projectId:`project-id`,
token:"w-OkG3f5OOM1Rkly8phZ",
compareBranch:'release'
};

@@ -7,2 +7,3 @@ "use strict";

exports.cliArgsToObject = cliArgsToObject;
exports.mergeArrayObjects = mergeArrayObjects;
exports.objectToCliArgs = objectToCliArgs;

@@ -51,2 +52,13 @@ /**

return argsArray;
}
function mergeArrayObjects(array) {
return array.reduce((acc, obj) => {
for (const key in obj) {
if (!acc[key]) {
acc[key] = [];
}
acc[key] = acc[key].concat(obj[key]);
}
return acc;
}, {});
}

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

if (_fs.default.statSync(absoluteDirPath).isFile()) {
return [absoluteDirPath];
return (0, _getFileUtils.filterFiles)([absoluteDirPath]);
}

@@ -123,0 +123,0 @@ const fileList = _fs.default.readdirSync(absoluteDirPath);

@@ -7,2 +7,3 @@ "use strict";

exports.createBranchDiff = createBranchDiff;
exports.getGitProjectId = getGitProjectId;
exports.requestGit = requestGit;

@@ -15,2 +16,3 @@ exports.requestUtils = requestUtils;

var _hash = require("./hash");
var _logger = require("./logger");
async function requestGit(apiDetails, options = {}) {

@@ -38,3 +40,3 @@ const {

response.on("error", error => {
Logger.log(Logger.FAILURE_TYPE, `Error - ${error}`);
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error - ${error}`);
});

@@ -65,11 +67,37 @@ response.on("end", end => {

function createBranchDiff() {
const {
var command;
var {
token,
gitEndPoint,
branchDiffPath,
compareBranch
compareBranch,
projectId
} = (0, _fileUtils.getLintConfiguration)();
const endPoint = `${gitEndPoint}/api/v4/projects/7761/repository/compare?from=${compareBranch}&to=${(0, _getSonarProperties.getBranchName)()}`;
const command = `curl --header "PRIVATE-TOKEN:${(0, _hash.decrypt)(token, 12)}" "${endPoint}"`;
if (projectId == "project-id") {
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that project id is properly configured`);
projectId = getGitProjectId();
}
const endPoint = `${gitEndPoint}/api/v4/projects/${projectId}/repository/compare?from=${compareBranch}&to=${(0, _getSonarProperties.getBranchName)()}`;
try {
command = `curl --header "PRIVATE-TOKEN:${(0, _hash.decrypt)(token, 12)}" "${endPoint}"`;
} catch (err) {
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that you have access to this repository ${(0, _getSonarProperties.getRepoName)()}`);
}
(0, _fs.writeFileSync)(branchDiffPath, requestUtils(command));
}
function getGitProjectId() {
var command;
const {
token,
gitEndPoint
} = (0, _fileUtils.getLintConfiguration)();
const endPoint = `${gitEndPoint}/api/v4/projects?search=${(0, _getSonarProperties.getRepoName)()}`;
try {
command = (0, _child_process.execSync)(`curl --header "PRIVATE-TOKEN:${(0, _hash.decrypt)(token, 12)}" "${endPoint}"`);
console.log(JSON.parse(command.toString()).pop().id);
return JSON.parse(command.toString()).pop().id;
} catch (err) {
console.log(err);
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `make sure that you have access to this repository ${(0, _getSonarProperties.getRepoName)()}`);
}
}
{
"name": "@zohodesk/codestandard-analytics",
"version": "0.0.1-exp-13",
"version": "0.0.1-exp-14",
"description": "linting tool",

@@ -5,0 +5,0 @@ "dependencies": {

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