🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@snyk/github-codeowners

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snyk/github-codeowners - npm Package Compare versions

Comparing version

to
1.1.0

dist/lib/stats/stats.test.js

2

dist/lib/ownership/OwnershipEngine.js

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

try {
const lines = fs.readFileSync(filePath).toString().split('\n');
const lines = fs.readFileSync(filePath).toString().replace(/\r/g, '').split('\n');
const owned = [];

@@ -47,0 +47,0 @@ for (const line of lines) {

@@ -127,2 +127,9 @@ "use strict";

});
it('should parse CRLF files (#4)', () => {
// Arrange
const codeowners = 'some/path @global-owner1 @org/octocat docs@example.com\r\n';
readFileSyncMock.mockReturnValue(Buffer.from(codeowners));
// Assert
expect(() => OwnershipEngine_1.OwnershipEngine.FromCodeownersFile('some/codeowners/file')).not.toThrow();
});
});

@@ -129,0 +136,0 @@ describe.each(patterns)('$name: "$pattern"', ({ name, pattern, paths }) => {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function percentageToFixed(dividend, divisor, precision = 2) {
return parseFloat(((dividend / divisor) * 100).toFixed(precision));
}
exports.percentageToFixed = percentageToFixed;
exports.calcFileStats = (files) => {

@@ -7,2 +11,3 @@ const total = {

lines: 0,
percentage: 0.0
};

@@ -12,2 +17,3 @@ const unloved = {

lines: 0,
percentage: 0
};

@@ -26,3 +32,3 @@ const ownerCount = new Map();

for (const owner of file.owners) {
const counts = ownerCount.get(owner) || { files: 0, lines: 0 };
const counts = ownerCount.get(owner) || { files: 0, lines: 0, percentage: 0 };
counts.files++;

@@ -36,7 +42,8 @@ if (typeof file.lines === 'number')

return {
total,
unloved,
total: Object.assign(Object.assign({}, total), { percentage: 100 }),
unloved: Object.assign(Object.assign({}, unloved), { percentage: percentageToFixed(unloved.lines, total.lines) }),
loved: {
files: total.files - unloved.files,
lines: total.lines - unloved.lines,
percentage: percentageToFixed(total.lines - unloved.lines, total.lines)
},

@@ -50,2 +57,3 @@ owners: Array.from(ownerCount.keys()).map((owner) => {

lines: counts ? counts.lines : 0,
percentage: counts ? percentageToFixed(counts.lines, total.lines) : 0
},

@@ -52,0 +60,0 @@ };

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

case (types_1.OUTPUT_FORMAT.CSV):
stream.write(`owner,files,lines\n`);
stream.write(`total,${stats.total.files},${stats.total.lines}\n`);
stream.write(`loved,${stats.loved.files},${stats.loved.lines}\n`);
stream.write(`unloved,${stats.unloved.files},${stats.unloved.lines}\n`);
stream.write(`owner,files,lines,percentage\n`);
stream.write(`total,${stats.total.files},${stats.total.lines},${stats.total.percentage}\n`);
stream.write(`loved,${stats.loved.files},${stats.loved.lines},${stats.loved.percentage}\n`);
stream.write(`unloved,${stats.unloved.files},${stats.unloved.lines},${stats.unloved.percentage}\n`);
orderedOwners.forEach((owner) => {
stream.write(`${owner.owner},${owner.counters.files},${owner.counters.lines}\n`);
stream.write(`${owner.owner},${owner.counters.files},${owner.counters.lines},${owner.counters.percentage}\n`);
});

@@ -28,7 +28,7 @@ break;

stream.write('\n--- Counts ---\n');
stream.write(`Total: ${stats.total.files} files (${stats.total.lines} lines)\n`);
stream.write(`Loved: ${stats.loved.files} files (${stats.loved.lines} lines)\n`);
stream.write(`Unloved: ${stats.unloved.files} files (${stats.unloved.lines} lines)\n`);
stream.write(`Total: ${stats.total.files} files (${stats.total.lines} lines) ${stats.total.percentage}%\n`);
stream.write(`Loved: ${stats.loved.files} files (${stats.loved.lines} lines) ${stats.loved.percentage}%\n`);
stream.write(`Unloved: ${stats.unloved.files} files (${stats.unloved.lines} lines ${stats.unloved.percentage}%\n`);
stream.write('--- Owners ---\n');
const owners = orderedOwners.map(owner => `${owner.owner}: ${owner.counters.files} files (${owner.counters.lines} lines)`).join('\n');
const owners = orderedOwners.map(owner => `${owner.owner}: ${owner.counters.files} files (${owner.counters.lines} lines) ${owner.counters.percentage}%`).join('\n');
stream.write(`${owners}\n`);

@@ -35,0 +35,0 @@ break;

@@ -48,3 +48,3 @@ {

},
"version": "1.0.0"
"version": "1.1.0"
}

@@ -42,7 +42,7 @@ # github-codeowners

--- Counts ---
Total: 24 files (1378 lines)
Loved: 10 files (494 lines)
Unloved: 14 files (884 lines)
Total: 24 files (1378 lines) 100%
Loved: 10 files (494 lines) 41.6%
Unloved: 14 files (884 lines) 58.4%
--- Owners ---
@jjmschofield: 10 files (494 lines)
@jjmschofield: 10 files (494 lines) 41.6%
```

@@ -49,0 +49,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet