Skip to content

Commit 1d6705a

Browse files
committed
fix: code smell
1 parent 0038db1 commit 1d6705a

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/file.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@ const findSimilarFiles = (files: Map<string, Buffer>): string[][] => {
1717
const hash = createHash('sha256').update(content).digest('hex');
1818
const existingFiles = contentComparer.get(hash);
1919

20-
if (existingFiles) {
21-
existingFiles.push(filename);
22-
} else {
23-
contentComparer.set(hash, [filename]);
24-
}
20+
if (existingFiles) existingFiles.push(filename);
21+
else contentComparer.set(hash, [filename]);
2522
}
2623

2724
const result: string[][] = [];
2825
for (const filenames of contentComparer.values()) {
29-
if (filenames.length > 1) {
30-
result.push(filenames);
31-
}
26+
if (filenames.length > 1) result.push(filenames);
3227
}
3328

3429
return result;

src/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ const formatCompressionLog = (
5555
const ratio = calculateCompressionRatio(originalSize, compressedSize);
5656
const sizeInfo = `(${originalSize} -> ${compressedSize} = ${ratio}%)`;
5757

58-
if (useGzip) {
59-
return greenLog(` [${filename}] ${padding} ✓ gzip used ${sizeInfo}`);
60-
}
58+
if (useGzip) return greenLog(` [${filename}] ${padding} ✓ gzip used ${sizeInfo}`);
6159

6260
const tooSmall = originalSize <= GZIP_MIN_SIZE ? '(too small) ' : '';
6361
return yellowLog(` [${filename}] ${padding} x gzip unused ${tooSmall}${sizeInfo}`);
@@ -90,11 +88,8 @@ const createSourceEntry = (
9088
*/
9189
const updateExtensionGroup = (extension: string): void => {
9290
const group = filesByExtension.find((fe) => fe.extension === extension);
93-
if (group) {
94-
group.count += 1;
95-
} else {
96-
filesByExtension.push({ extension, count: 1 });
97-
}
91+
if (group) group.count += 1;
92+
else filesByExtension.push({ extension, count: 1 });
9893
};
9994

10095
console.log('Collecting source files');

0 commit comments

Comments
 (0)