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
Next Next commit
Improve detection of Rust in languages input
  • Loading branch information
henrymercer committed Aug 5, 2025
commit 83e92edc4b4bba4e3be47858adee3f94fa23d012
13 changes: 8 additions & 5 deletions lib/config-utils.js

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

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions lib/init-action.js

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

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,15 @@ export async function getLanguages(
return languages;
}

export function getRawLanguagesNoAutodetect(
languagesInput: string | undefined,
): string[] {
return (languagesInput || "")
.split(",")
.map((x) => x.trim().toLowerCase())
.filter((x) => x.length > 0);
}

Copilot AI Aug 5, 2025

Copy link

Choose a reason for hiding this comment

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

This function duplicates logic that was previously inline in getRawLanguages. Consider extracting this to a shared utility function to avoid code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

/**
* Gets the set of languages in the current repository without checking to
* see if these languages are actually supported by CodeQL.
Expand All @@ -416,12 +425,8 @@ export async function getRawLanguages(
rawLanguages: string[];
autodetected: boolean;
}> {
// Obtain from action input 'languages' if set
const languagesFromInput = (languagesInput || "")
.split(",")
.map((x) => x.trim().toLowerCase())
.filter((x) => x.length > 0);
// If the user has specified languages, use those.
const languagesFromInput = getRawLanguagesNoAutodetect(languagesInput);
if (languagesFromInput.length) {
Comment thread
mbg marked this conversation as resolved.
Outdated
return { rawLanguages: languagesFromInput, autodetected: false };
}
Expand Down
12 changes: 10 additions & 2 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,16 @@ async function run() {
}
core.endGroup();

// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
if (getOptionalInput("languages")?.includes(KnownLanguage.rust)) {
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust. We need to set this environment
// variable before initializing the config, otherwise Rust analysis will not be
// enabled.
if (
// Only enable Rust analysis if the user has explicitly requested it - don't
// enable it via language autodetection.
configUtils
.getRawLanguagesNoAutodetect(getOptionalInput("languages"))
.includes(KnownLanguage.rust)
) {
const feat = Feature.RustAnalysis;
const minVer = featureConfig[feat].minimumVersion as string;
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
Expand Down