Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify step.uses condition
  • Loading branch information
mbg committed Sep 10, 2025
commit 754f2e184f461607b45a1d55105127a48df3a7a9
2 changes: 1 addition & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ export async function getWorkflowErrors(
for (const job of Object.values(doc?.jobs || {})) {
if (Array.isArray(job.steps)) {
for (const step of job.steps) {
if (
step.uses !== undefined &&
step.uses.startsWith("github/codeql-action/")
) {
if (step.uses?.startsWith("github/codeql-action/")) {
const parts = step.uses.split("@");
if (parts.length >= 2) {
Comment on lines +172 to +173
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: don't we have this kind of parsing elsewhere already?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have

  const format = new RegExp(
    "(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)",
  );

in getRemoteConfig, but I thought I'd keep this simple.

codeqlStepRefs.push(parts[parts.length - 1]);
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic assumes that splitting on '@' will always produce the version as the last part, but this may not handle edge cases correctly. For example, if step.uses is 'github/codeql-action/init@v2@extra', this would extract 'extra' instead of 'v2@extra'. Consider using parts.slice(1).join('@') to handle multiple '@' characters properly.

Suggested change
codeqlStepRefs.push(parts[parts.length - 1]);
codeqlStepRefs.push(parts.slice(1).join("@"));

Copilot uses AI. Check for mistakes.
Expand Down
Loading