mirror of
https://github.com/github/codeql-action.git
synced 2026-01-01 04:00:24 +08:00
Change include path for lines of code counting
Previously, we were always using `**` in the include path. the effect of this was to always count lines in the entire repository unless explicitly added to the paths-ignore. This was incorrect behaviour. Now we only using `**` if the include path is otherwise empty.
This commit is contained in:
@@ -63,7 +63,23 @@ test("ensure lines of code can handle includes", async (t) => {
|
||||
);
|
||||
|
||||
t.deepEqual(results, {
|
||||
javascript: 15,
|
||||
javascript: 12,
|
||||
});
|
||||
});
|
||||
|
||||
test("ensure lines of code can handle empty includes", async (t) => {
|
||||
// note that "**" is always included. The includes are for extra
|
||||
// directories outside the normal structure.
|
||||
const results = await countLoc(
|
||||
path.join(__dirname, "../tests/multi-language-repo"),
|
||||
["idontexist"],
|
||||
[],
|
||||
[Language.javascript],
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
t.deepEqual(results, {
|
||||
// should get no results
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ export async function countLoc(
|
||||
): Promise<Partial<Record<Language, number>>> {
|
||||
const result = await new LocDir({
|
||||
cwd,
|
||||
include: ["**"].concat(include || []),
|
||||
include: Array.isArray(include) && include.length > 0 ? include : ["**"],
|
||||
exclude,
|
||||
analysisLanguages: dbLanguages.flatMap((lang) => nameToLinguist[lang]),
|
||||
}).loadInfo();
|
||||
|
||||
Reference in New Issue
Block a user