Skip to content

Commit d3658a6

Browse files
committed
chore: improve readability / consistency
1 parent b33cacb commit d3658a6

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

lib/analyzer/image-inspector.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ async function pullWithDockerBinary(
5454
"using local docker binary credentials. the credentials you provided will be ignored",
5555
);
5656
}
57-
await docker.pullCli(targetImage, { platform });
57+
await docker.pullCli(targetImage, {platform});
5858
await docker.save(targetImage, saveLocation);
5959
return true;
6060
} catch (err) {
6161
debug(`couldn't pull ${targetImage} using docker binary: ${err.message}`);
62-
6362
handleDockerPullError(err.stderr, platform);
6463

6564
return false;
@@ -80,10 +79,7 @@ function handleDockerPullError(err: string, platform?: string) {
8079
"manifest unknown",
8180
];
8281
if (unknownManifestConditions.some((value) => err.includes(value))) {
83-
if (platform) {
84-
throw new Error(`The image does not exist for ${platform}`);
85-
}
86-
throw new Error(`The image does not exist for the current platform`);
82+
throw new Error(`The image does not exist for ${platform ?? "the current platform"}`);
8783
}
8884

8985
if (err.includes("invalid reference format")) {

lib/extractor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function layersWithLatestFileModifications(
254254
* https://www.madebymikal.com/interpreting-whiteout-files-in-docker-image-layers/
255255
*/
256256
export function isWhitedOutFile(filename: string) {
257-
return /\.wh\./.test(filename);
257+
return filename.includes(".wh.");
258258
}
259259

260260
function isBufferType(type: FileContent): type is Buffer {

lib/python-parser/requirements-parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ export function getRequirements(fileContent: string): PythonRequirement[] {
1515

1616
function parseLine(line: string): PythonRequirement | null {
1717
line = line.trim();
18-
if (line.length === 0) {
18+
// there's no point in calling the regex if the line is a comment
19+
if (line.length === 0 || line.startsWith("#")) {
1920
return null;
2021
}
2122
const parsedLine = VERSION_PARSE_REGEX.exec(line);
2223
if (!parsedLine?.groups) {
2324
return null;
2425
}
2526
const { name, extras, specifier, version } = parsedLine.groups;
26-
const correctedSpecifier = specifierValidRange(specifier, version);
2727
return {
2828
name: name.toLowerCase(),
29-
specifier: correctedSpecifier,
29+
specifier: specifierValidRange(specifier, version),
3030
version,
3131
extras: parseExtraNames(extras),
3232
} as PythonRequirement;

test/lib/extractor/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ describe("isWhitedOutFile", () => {
5454
expect(isWhitedOutFile("end.wh.")).toBe(true);
5555
expect(isWhitedOutFile("/deeply/nested/path/.wh.present")).toBe(true);
5656
});
57-
});
57+
});

0 commit comments

Comments
 (0)