Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

danger-plugin-lint-report

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

danger-plugin-lint-report - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4

16

dist/index.test.js

@@ -73,5 +73,7 @@ "use strict";

</issues>`);
const mockFileExistsSync = jest.fn();
jest.mock("glob", () => (_, cb) => cb(null, mockGlob()));
jest.mock("fs", () => ({
readFileSync: (path) => mockFileSync(path),
existsSync: (path) => mockFileExistsSync(path),
}));

@@ -167,2 +169,16 @@ describe("scan()", () => {

}));
it("returns correct file location when root is different", () => __awaiter(void 0, void 0, void 0, function* () {
const git = {
modified_files: ["feature/src/main/res/layout/fragment_password_reset.xml"],
created_files: [],
};
mockFileExistsSync.mockImplementation((path) => ["/otherRoot/feature/src/main/res/layout/fragment_password_reset.xml"].includes(path));
const messageCallback = jest.fn();
yield _1.scanXmlReport(git, xmlReport, "/otherRoot/", false, messageCallback);
const msg = "Hardcoded text";
const file = "feature/src/main/res/layout/fragment_password_reset.xml";
const line = 13;
const severity = "Warning";
expect(messageCallback).toBeCalledWith(msg, file, line, severity);
}));
});

34

dist/parse/checkstyle_parser.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCheckstyle = void 0;
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
function parseCheckstyle(report, root) {

@@ -39,3 +44,3 @@ if (!report.elements || !report.elements[0]) {

}
report.elements[0].elements.forEach(issueElement => {
report.elements[0].elements.forEach((issueElement) => {
if (issueElement.name !== "issue") {

@@ -55,3 +60,3 @@ console.log(`Illegal element: ${issueElement.name}, expected issue. Ignoring.`);

const errorLine2 = attributes.errorLine2;
issueElement.elements.forEach(fileElement => {
issueElement.elements.forEach((fileElement) => {
if (fileElement.name !== "location") {

@@ -62,3 +67,3 @@ console.warn(`Illegal element ${fileElement.name}, expected location. Ignoring.`);

const locationAttributes = fileElement.attributes;
const fileName = locationAttributes.file.replace(root, "").replace(/^\/+/, "");
const fileName = calculateRelativeFileName(locationAttributes.file, root);
const line = +locationAttributes.line;

@@ -80,2 +85,19 @@ const column = +locationAttributes.column;

/**
* Calculates the relative filename by checking the existance of `file` in `root`
* @param file the absolute file present in the lint report
* @param root current folder
* @returns relative filename in `root` or filename with `root` removed if the file was not found
*/
function calculateRelativeFileName(file, root) {
const components = file.split(path_1.default.sep);
for (let i = 1; i < components.length; i++) {
const suffixComponents = components.slice(-i);
const candidateFile = path_1.default.resolve(root, ...suffixComponents);
if (fs_1.default.existsSync(candidateFile)) {
return path_1.default.relative(root, candidateFile);
}
}
return file.replace(root, "").replace(/^\/+/, "");
}
/**
*

@@ -90,5 +112,5 @@ * @param report Checktyle report as JavaScript object

}
report.elements[0].elements.forEach(fileElement => {
const fileName = fileElement.attributes.name.replace(root, "").replace(/^\/+/, "");
fileElement.elements.forEach(errorElement => {
report.elements[0].elements.forEach((fileElement) => {
const fileName = calculateRelativeFileName(fileElement.attributes.name, root);
fileElement.elements.forEach((errorElement) => {
const attributes = errorElement.attributes;

@@ -95,0 +117,0 @@ const line = +attributes.line;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const checkstyle_parser_1 = require("./checkstyle_parser");
const mockFiles = [];
jest.mock("fs", () => ({
existsSync: (path) => mockFiles.includes(path),
}));
describe("parseCheckstyle()", () => {

@@ -5,0 +9,0 @@ it("maps checkstyle 8.0 violations properly", () => {

2

package.json

@@ -20,3 +20,3 @@ {

],
"version": "1.5.3",
"version": "1.5.4",
"main": "dist/index.js",

@@ -23,0 +23,0 @@ "types": "types/index.d.ts",

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